Brad Mitchell
Brad Mitchell

Reputation: 276

gdb stops at breakpoint, but no code is shown

I've recently changed compilers from the Oracle Studio compiler on RHEL7 to Clang on RHEL8 due to no support of the oracle compiler. I'm trying to debug our application using GDB, but running into some issues I am yet to find a solution for.

I can set a breakpoing with: b class::function or b file.cc:linenumber

It does break when it hits that breakpoint, but no code is shown at that location. Funnily enough, some stuff does, and in this case, it shows line numbers in the base class.

this is the stack on break:

Thread 41 "dms" hit Breakpoint 2, 0x0000000000880f44 in
User_Registrar::login(Address const*, int, char const*, Boolean,
RWCString) ()
(gdb) where
#0  0x0000000000880f44 in User_Registrar::login(Address const*, int,
char const*, Boolean, RWCString) ()
#1  0x0000000000878dfb in
User_Registrar::userLoginRequest(UserLoginRequest*) ()
#2  0x0000000000871597 in User_Registrar::processMessage(Message*) ()
#3  0x00000000009cd530 in MessageHandlerObject::processMessageQueue
(this=0x7fffe8068010) at BaseObjects.cc:488
#4  0x00000000009cd40e in
MessageHandlerObject::processMessageQueueStartup
(thisInstance=0x7fffe8068010) at BaseObjects.cc:447
#5  0x00007ffff69d887c in stl_thread_start_rtn () from
/opt1/dms/lib/libthread.so
#6  0x00007ffff643318a in start_thread () from /lib64/libpthread.so.0
#7  0x00007fffee095dd3 in clone () from /lib64/libc.so.6
(gdb) up
#1  0x0000000000878dfb in
User_Registrar::userLoginRequest(UserLoginRequest*) ()
(gdb) down
#0  0x0000000000880f44 in User_Registrar::login(Address const*, int,
char const*, Boolean, RWCString) ()
(gdb)

Am I missing something like a limit or something similar?

Things I have checked: Yes, it is being compiled with -g objdump does show the debug_info for the source file gdb does show it has loaded the source file

Upvotes: 1

Views: 563

Answers (2)

user888379
user888379

Reputation: 1467

If gdb doesn't know where to look for the source file, you can use the directory command to add a path: gdb directory command

Upvotes: -1

Employed Russian
Employed Russian

Reputation: 213375

(gdb) where
#0 0x0000000000880f44 in User_Registrar::login(Address const*, int, char const*, Boolean, RWCString) ()

Note that there is no file / line info for this level -- that is the reason GDB doesn't show source.

Why did this happen? Clang omits file/line info under certain conditions when optimization is in effect (as far as I understand, when code is inlined and re-ordered, it is sometimes hard to keep code to file/line association).

If you can disable optimizations, or add __attribute__((noinline)) to the login() function, you'll have a better debugging experience.

If you must debug this particular function with optimizations, you'll have to disassemble it and reconstruct the code to file/line association "by hand".

Upvotes: 2

Related Questions