Need help with a backtrace
Fernando Nasser
fnasser@redhat.com
Thu Feb 15 06:17:00 GMT 2001
Matt Schalit wrote:
>
> Ok. It looks like it only lists an entry when a function
> calls another function, like main() calling printf()?
> But it doesn't seem to list things like loops or if/case tests
> or variable values?
>
Yes, because all information it has are the stack frames, which are
created when a function is called.
When you want to debug something in between, you set a breakpoint in a
line of source code and tell your program to run (or continue if you had
stopped somewhere else before). Of course, all this only work before you
program crashes.
> I know how to write C programs. How would I backtrace or
> step my way through hello-world.c if it exits normally, and
> I just want to see how the trace looks?
>
Insert a breakpoint at that last function (look at the source file and
line number in the bad backtrace). Run your program. When it stops at
the breakpoint use the backtrace command.
> I say that as a possibility, because I read a Solairis Gnome
> Install Howto that mentioned those were needed, and I've noticed,
> when doing a truss on some of these programs that I get an extra '/'
> showing up in paths to applications that are being called, as in:
>
> xstat(2, "./gnome/config-override//Gnome", 0x08047614) Err#2 ENOENT
> xstat(2, "/usr/local/etc/gnome/config//Gnome", 0x08047614) Err#2 ENOENT
> xstat(2, "./gnome/config//Gnome", 0x08047614) Err#2 ENOENT
> xstat(2, "/home/matthew/.gnome//Gnome", 0x08047674) = 0
> open("/home/matthew/.gnome//Gnome", O_RDONLY, 0666) = 6
>
> I guess the last two lines do show a file being found
> using the odd path.
>
Yes, AFAIK the extra "/" won't hurt.
> Is up and down how I see what variables get set to which values
> while moving through a function?
>
You only see what the values of these variables where when the next
function was called. It is a "snapshot".
> And finally, where does
>
> > > #4 0xbfd95397 in create_label
> ^^^^^^^^^^
>
This is the instruction pointer (PC). That is where the CPU was
executing instructions when another function was called or your program
stopped/crashed.
> that value come from, or what man page should I look at
> for the decoding formula?
>
With the GDB sources, there is a nice user manual. It is in the sources
under gdb/doc. It is in a format called "texinfo" which can produce
several different formats like Postcript for instance. You just have to
use "make" with the appropriate type on that directory.
I am sure that if you do a Web search you'll find a HTML on line
version.
W.r.t. your original problem, maybe if you post it to the Gnome list
people will recognize that as a known problem or something. It worth a
try.
Cheers,
Fernando
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
More information about the Gdb
mailing list