Search code examples
gdbgssapi

can the return value from finish in gdb be different from the actual one in execution


I am a gdb novice, and I was trying to debug some GSSAPI code, and was using fin to see the return value from the frame. As seen in the snip pasted below, the call from gssint_mechglue_initialize_library() seems to be 0 but the actual check seems to fail. Can someone please point out if I am missing something obvious here?

Thanks in advance!

gdb snip for return value


Solution

  • One possible explanation for the observed behavior is that you are debugging optimized code, and that line 1001 isn't really executed.

    You can confirm this with a few nexts, or by executing fin again and observing whether GSS_S_COMPLETE or something else is returned from gssint_select_mech_type.

    When optimization is on, code motion performed by the optimizer often prevents correct assignment of actual code sequences to line numbers (as instructions "belonging" to different lines are mixed and re-ordered). This often causes the code to "jump around" when e.g. doing nexti command.

    For ease of debugging, recompile with -O0, or make sure to remove any -O2 and the like from your compile lines.