Linux_gdb debugger

gdb debugger

First, understand the relevant information

  1, the release process has two modes: "debug" and "release"

  2, executable under Linux gcc / g ++ is generated by default "release" mode

  3, when debugging with gdb, you must add the -g option when generating executable program

    Why? In order to generate debug symbols gdb debugging information needed, if not the option, debug debug operation is not related to the use of dogs

Second, the basic operation of gdb

  <L / list> followed by a number, the display lines of code before and after each of 5, then the last position to the following, each row 10 column

        Followed by the function name, the code function inside the display

  <R / run> Run Program

  <N / next> by the process, a single execution

  <S / step> stepping into, enter function calls

  <B / break> break point

    b # marked with a breakpoint in a row

    b function names marked with a breakpoint at the head of the function

    disable Num disable the line break

    enable Num to enable the bank breakpoint

    ib (info breakpoints) View breakpoint information

    delete breakpoints [] [] indicate the internal breakpoint information without deleting all breakpoints, plus digital representation remove a breakpoint 

  Value <p / print> print the expression may be modified variable values ​​or a function call by the expression

  Value <i locals> Print scope of temporary variables

  <C / continue> continue

  <Display> value [Variable Name] tracking variables

  <Bt / where> view the call stack

  <Q / quit> Exit gdb

Three, readelf command calls

    What is? To display information about ELF object file format, can be controlled by parameters option to display certain information
      *> ELF file format: is for binary files, executable files, object code, shared libraries, and core dump file format
      *> ELF file part: ELF header, the program header table, and section head tables
    What?
    1> View shared library dependencies (NEEDED) and search for the name (SONAME)
            readelf -d <file_name> 
    2> ELF header Display
            readelf -h <file_name>
    And objdump command difference:
        objdump uses bfd library file read, but did not readelf and write another piece of code, to determine some of the conditions is not very strict;
        readelf can display debugging information, but did not objdump, but objdump after simple treatment can be achieved debugging information display

Guess you like

Origin www.cnblogs.com/bj3251101/p/11820962.html
Recommended