Running HomeBrew gdb on macOS

So, if you try to run gdb from e.g. HomeBrew on macOS, you get an error like this:

Starting program: /Users/leif/apache/trafficserver/iocore/net/.libs/test_UDPNet
Unable to find Mach task port for process-id 42037: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))


I found this article / HowTo for doing a code signing certificate for the gdb binary, and sign it: