LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   How to interpret Stack trace from gdb out put (https://www.linuxquestions.org/questions/linux-desktop-74/how-to-interpret-stack-trace-from-gdb-out-put-505894/)

NeoMagic 11-29-2006 07:57 AM

How to interpret Stack trace from gdb out put
 
Hi
I have the following issue
I have some C code which is similar to the following snippet
All the Functions are Declared in K&R-Style

Function_A (args )
{
declarations;
assignments ;
Function_B( args1 );
}

Function_B (args1 )
{
declarations;
assignments ;
.........
.........

}

While debugging the issue with the help of DDD on linux I m facing following issues

Issue 1 :
---------
1. In the stack trace some library calls are getting embedded between the flow from functionA to function_B

I expect the stack trace should look some thing like the follwoing

#34 0x0807a4c1 in function_B
#35 0x0808036f in function_A
#36 0x080501b7 in main (argc=27, argv=0x82906c0)

But I am getting some thing like the below

#14 0x0807a4c1 in function_B
#15 0x00000089 in ?? ()
#16 0x000000cf in ?? ()
#17 0x00000001 in ?? ()
#18 0x09fbc008 in ?? ()
#19 0x09fa26e8 in ?? ()
#20 0x00000001 in ?? ()
#21 0x00000003 in ?? ()
#22 0x00411a78 in __DTOR_END__ () from /lib/tls/libc.so.6
#23 0x00000005 in ?? ()
#24 0x000001d9 in ?? ()
#25 0x000007b1 in ?? ()
#26 0x00000004 in ?? ()
#27 0x000007d6 in ?? ()
#28 0x0000000a in ?? ()
#29 0x0000001a in ?? ()
#30 0x00411a78 in __DTOR_END__ () from /lib/tls/libc.so.6
#31 0xfefe882c in ?? ()
#32 0x00000001 in ?? ()
#33 0xfefe87ec in ?? ()
#33 0xfefe87ef in ?? ()
#34 0x00370859 in __tz_convert () from /lib/tls/libc.so.6
#35 0x0808036f in function_A
#36 0x080501b7 in main (argc=27, argv=0x82906c0)

1.1 Why are these library calls coming into picture even if the
function_B is called directly by Function_A ?
1.2 Is there any way to avoid them ? any repurcations if we
avoid them ?

Issue 2
-------
While running DDD on the program I set a break point at the call to Function_B,in Function_A, at this point if you watch the values of the arguments ,the args are having correct values , on issuing 'Next' the control comes to the declarations section of the Function_B if you watch the arguments at this point the args are having some junk values

Now another 'Next' will take you to the assignments section in Function_B , at this point of time the args are having the correct values .

Why is this transistion in the values in the due course ?


Please let me know if any body faced the similar issues
Anticipating a quick reply

-Regards
Neo

dombrowsky 12-28-2006 11:52 PM

wow. no wonder this has gone unanswered for a month....

First, I've never used DDD. I've only used GDB, and done things the "hard way." Mostly becuase I don't usually have X running when I'm doing development anyway. So I'd first say RTFM on gdb to make sure your problems are coming from the debugger and not the buggy interface.

anywho...

issue #1
--------
The first thing to check is make sure your debug copiler flags are correct for the debugger you're using. After that, try stepping through the code assembly instruction by assembly instruction. I know GDB will show the source code line every time it hits it, so you can see exactly where the codepath is going.

issue #2
--------
try and reproduce the bug in GDB. its quite possible you found a bug in the debugger. Usually illogical program behaviour in GNU tools is the result of a bug. The GNU development tools are the most solid tools in computing, but bugs are found... continually and constantly.


All times are GMT -5. The time now is 01:14 AM.