当前位置:网站首页>GDB debugging common commands

GDB debugging common commands

2022-06-11 09:39:00 ZBB's notes

title GDB Debugging steps

Use gdb During debugging , You need to use... At compile time -g Parameters

g++ -g test.cpp -o test
gdb ./test

Title Common Commands :

    start                   # Start debugging , Stop at the first line of code ,(gdb)start
    l                         #list See the source code ,(gdb) l [number/function]
    b <lines>           #b: Breakpoint Abbreviation , To set breakpoints .(gdb) b 10
    b <func>            #b: Breakpoint Abbreviation , To set breakpoints .(gdb) b main
    b filename:[line/function]  #b: In the file filename Set a breakpoint at a line or function of 
    i breakpoints  #i:info  Abbreviation .(gdb)i breakpoints
    d [bpNO]        #d: Delete breakpoint Abbreviation , Delete a breakpoint with a specified number , Or delete all breakpoints . Breakpoint number from 1 Began to increase . (gdb)d 1
    s                     #s: step Execute a line of source code , If there is a function call in this line of code , Enter the function ;(gdb) s
    n                     #n: next Execute a line of source code , The function call in this line of code is also executed .(gdb) n
    r                      #Run Abbreviation , Run the program being debugged . If you haven't hit a breakpoint before , Then execute the entire program ; If there's a breakpoint , The program pauses at the first available breakpoint .(gdb) r
    c                       #Continue Abbreviation , Continue to execute the debugged program , Until the next breakpoint or the end of the program .(gdb) c
    finish                # End of the function 
    p [var]              #Print Abbreviation , Display the specified variable ( Temporary or global variables   for example  int a) Value .(gdb) p a
    display [var]                #display, Set the variable you want to track ( for example  int a).(gdb) display a
    undisplay [varnum]     #undisplay Cancel tracking of variables , The tracked variable is identified by an integer .(gdb) undisplay 1
    set args               # Runtime parameters can be specified .(gdb)set args 10 20
    show args           # Look at the runtime parameters .
    q                          #Quit Abbreviation , sign out GDB Debug environment .(gdb) q 
    help [cmd]           #GDB Help order , Provide right GDB Explanation of the name and species command . If you specify “ Command name ” Parameters , The detailed description of the command is displayed ; If no parameter is specified , Then all the GDB command , For users to further browse and query .(gdb)help
     enter                     # Repeat the previous command ,(gdb) enter 

————————————————
Copyright notice : This paper is about CSDN Blogger 「Panix2n_n」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/mercy_ps/article/details/81542986

原网站

版权声明
本文为[ZBB's notes]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203012244364829.html