Find info from address in debugging-Collection of common programming errors

  • Usually yes. Assuming your program crashed outside GDB due to SIGSEGV and left a core dump, you can:
    A: find out which instruction actually caused the access violation:

        (gdb) x/i $pc
    

    This will usually be a memory access instruction, e.g. "movl $1,8(%eax)". What’s important is then what value does the register which is supposed to point to valid memory have.
    B. find out value of that register:

       (gdb) p/x $eax
    

    Often this would be 0 (you are writing through a NULL pointer), or some nonsense value, e.g. 0x32314043 (you’ve corrupted the pointer, or overwrote it with an ASCII string).

  • The GDB "info symbol" command will tell you which symbol (if any) is near the given address.

  • Use the same "info symbol" command for addresses slightly smaller and slightly larger the address of your “target” variable.