I was using gdb 8.3 on MacOSX 10.14.6 Mojave.
I had conquered the code signing issue by following the procedure:
https://sourceware.org/gdb/wiki/PermissionsDarwin
(Pasting the issue statement here for others to search and fix.)
Unable to find Mach task port for process-id 57304: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
But my later issue is '~/.gdbinit' does not work for gdb.
GDB would start 'New Thread' for the debugged program:
~/.gdbinit content: set startup-with-shell off
```
Reading symbols from a.out...
Reading symbols from /Users/zong/GitRepos/local/test-gdb/a.out.dSYM/Contents/Resources/DWARF/a.out...
(gdb) b 4
Breakpoint 1 at 0x100000f66: file a.c, line 4.
(gdb) run
Starting program: /Users/zong/GitRepos/local/test-gdb/a.out
[New Thread 0x1103 of process 1905]
```
After searching, instead of ~/.gdbinit, we can explicitly appoint .gdbinit file for gdb to use, like gdb -x ~/.gdbinit <executable file> (for VSCode, set "miDebuggerArgs": "-x ${workspaceFolder}/.gdbinit" in launch.json).
My question is why ~/.gdbinit doesn't work?