Find address information when debugging

I am learning to solve some runtime error with gdb. Here are my questions:

  • when a runtime error occurs because some access operations of some memory conflict, can I detect the address of this memory in the unloaded kernel?

  • Given the address, is it possible to find out which variable uses it (the address can be at the beginning, at the end or in the middle of the variable's memory)?

  • Given the memory used by the variable, is it possible to find its neighboring variables below and directly above it?

Thank you and welcome!

+3
source share
1 answer
  1. . , GDB - SIGSEGV , :
    A: , :

        (gdb) x/i $pc
    

    , . "movl $1,8(%eax)". .
    B. :

       (gdb) p/x $eax
    

    0 ( NULL), - , . 0x32314043 ( ASCII).

  2. GDB "info symbol" , ( ) .

  3. "info symbol" , .

:
info symbol () , ( ).

, "info locals".

(gdb) print &a_local_variable

, (.. ). , , "". , " " - , , , .

+5

Source: https://habr.com/ru/post/1716236/


All Articles