This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: how to debug this error by gdb?
- From: Michael Snyder <msnyder at vmware dot com>
- To: =?big5?b?qfrEsQ==?= <shi dot minjue at gmail dot com>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Mon, 11 May 2009 10:22:38 -0700
- Subject: Re: how to debug this error by gdb?
- References: <6a8fced30905101934j2aa94d27i210484a99a523ce5@mail.gmail.com>
©úı wrote:
> I'm debugging a application, for it crashes at line 660 of file
> glxcmds.c, which is a file of mesa-7.4.1
> here is the source code at which it crashes:
> ---------------------------------------------------------------------------------------
> PUBLIC void glXWaitX(void)
> {
> ......
> if (psc->driScreen->waitX != NULL)
> [line 660] (*psc->driScreen->waitX)(pdraw);
> .....
> }
> ---------------------------------------------------------------------------------------
>
>
> and here is the gdb info:
> ---------------------------------------------------------------------------------------
> (gdb) break glxcmds.c:660
> Breakpoint 1 (glxcmds.c:660) pending.
> (gdb) run
> Breakpoint 1, glXWaitX () at glxcmds.c:660
> (gdb) print psc->driScreen->waitX
> $3 = (void (*)(__GLXDRIdrawable *)) 0x47206769666e6f63
> (gdb) print *psc->driScreen->waitX
> Cannot access memory at address
> (gdb) step
> Program received signal SIGSEGV, Segmentation fault.
> ---------------------------------------------------------------------------------------
First you need to "print psc", to see if that pointer is valid.
Then print psc->driScreen, to see if that pointer is valid.
Only then can you examine something pointed to by psc->driScreen.