Re: how to debug this error by gdb?

Michael Snyder
2009-05-11T17:21:38Z

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=Big5, Size: 1278 bytes --]

©úÄ± 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.