...
However, that did not work for me. Instead, on the command line, I manually add the compiler flags like this:
Code Block | ||||
---|---|---|---|---|
| ||||
$ make BUILD_IOCS=YES USR_CFLAGS="-ggdb -O0" USR_CXXFLAGS="-ggdb -O0" |
With that, the debug symbols are included in the resulting executable (-ggdb) and all compiler optimizations are disabled (-O0).
...
And now you should be ok to debug.
Code Block | ||||
---|---|---|---|---|
| ||||
egumtow@lcls-dev3 ~/code/ipmiComm/iocs/ipmicomm-test-IOC/iocBoot/iocipmicomm-test-IOC> gdb ../../bin/rhel6-x86_64/ipmicomm-test-IOC |
...
[...] |
...
(gdb) b init_fru_stringin_record |
...
Breakpoint 1 at 0x447f25: file ../devMch.c, line 1509. |
...
(gdb) r ./st.cmd |
...
Breakpoint 1, init_fru_stringin_record (pstringin=0x8ab520) at ../devMch.c:1509 |
...
1509 MchRec recPvt = 0; /* Info stored with record */ |
...
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6_10.3.x86_64 ncurses-libs-5.7-4.20090207.el6.x86_64 readline-6.0-4.el6.x86_64 |
...
(gdb) bt |
...
#0 init_fru_stringin_record (pstringin=0x8ab520) at ../devMch.c:1509 |
...
#1 0x00000000004b4b79 in init_record (pcommon=0x8ab520, pass=<value optimized out>) at ../rec/stringinRecord.c:119 |
...
#2 0x00000000004fc2cd in doInitRecord1 () at ../misc/iocInit.c:553 |
...
#3 iterateRecords () at ../misc/iocInit.c:485 |
...
#4 initDatabase () at ../misc/iocInit.c:561 |
...
#5 iocBuild_2 () at ../misc/iocInit.c:163 |
...
#6 0x00000000004fc505 in iocBuild () at ../misc/iocInit.c:202 |
...
#7 0x00000000004fc569 in iocInit () at ../misc/iocInit.c:107 |
...
#8 0x0000000000500be9 in iocInitCallFunc (args=<value optimized out>) at ../misc/miscIocRegister.c:25 |
...
#9 0x000000000053eee2 in iocshBody (pathname=<value optimized out>, commandLine=0x0, macros=0x0) at ../iocsh/iocsh.cpp:925 |
...
#10 0x000000000043e9d0 in main (argc=2, argv=0x7fffffffad58) at ../ipmicomm-test-IOCMain.cpp:17 |
Note that you see some "value optimized out" in the backtrace. That is because those frames are inside libraries that we did not compile, but did link to. Whoever compiled those did so with optimization enabled. It is typical to have two versions of libraries, one of which is used for debugging like we want to do. By default the non-debugging libraries are linked in, and if needed the user can link in the debugging libraries by overriding the -L options to gcc and/or setting the LD_LIBRARY_PATH environment variable. But I don't know where the debugging libraries live or if they exist.