Another Japan in the World

Jun Aruga's blog, who lived in Japan, Singapore, live in Czech Republic. Mainly about IT and travel.

Caution when using gdb on Mac 10.9

Install GDB on Mac 10.9.

$ brew install gdb

Load one c compiled binary file.

$ gdb bin/thread
GNU gdb (GDB) 7.10.1

Got an error.

(gdb) run
Starting program: /Users/jun.aruga/git/multi_test/bin/thread
Unable to find Mach task port for process-id 54060: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

You have to run gdb with "sudo" on Mac.
And normally finished.

$ sudo gdb bin/thread

(gdb) run
Job 2 started, sleep sec: 9.
Job 1 started, sleep sec: 7.
Job 3 started, sleep sec: 3.
Job 4 started, sleep sec: 8.
Job 3 ended.
Job 1 ended.
Job 4 ended.
Job 2 ended.
[Inferior 1 (process 54144) exited normally]

Let's set "gcc -g -O0" when using gdb.

$ view Makefile
# Production
# CFLAGS = -Wall -O2
# Development
CFLAGS = -Wall -g -O0


That's all.