gdb常用调试命令
作者:互联网
- help(h):查看命令帮助,具体查询可在gdb中输入h + 命令,
- run&start
- run: 重新开始运行文件;
- run argv[1] argv[2]:
- start:单步执行,运行程序,停在第一执行语句;
- list(l):查看源代码
- l n:从第n行开始查看代码,一般会展现n行上下文;
- l 函数名:查看具体函数;
- next(n)&step(s):单步调试
- n:单步调试(逐过程,函数直接执行)
- s:单步调试(逐语句:跳入自定义函数内部执行)
- break(b):设置断点
- b num:在第num行设置断点;
- info(i) b(breakpoints):查看当前设置的所有断点;
- enable b (breakpoints):启用断点;
- disable b (breakpoints):禁用断点;
- delete breakpoints(b) num: 删除第num个断点,简写d;
- backtrace & frame
- backtrace(bt):查看函数调用栈帧
- bt n:显示栈顶的几个层的信息;
- bt -n:显示栈底的几个层的信息;
- frame(f):查看某一层的信息,具体为代码调用处
- f n:n表示某一个栈帧的编号,默认为当前栈顶的栈信息(即frame 0);
- info(i) f:查看当前栈层的信息,大多数为运行时的内存地址;
- backtrace(bt):查看函数调用栈帧
- disassemble:查看汇编语言
- disassemble:就可以展现当前函数栈中的汇编语言;
- b *当前函数栈名+行号:在汇编语言上打断点;再运行disassemble就可以定位到断点处;
- disassemble /m 函数栈名:展现汇编语言的同时也展现源码;
- print,set&x:
- print(p):打印变量值及地址
- p 变量名;
- p *array@len:array为数组的首地址,len为数据的长度;
- p 数组名:可展现详细的数组信息
- set print pretty on:可以很漂亮的输出接口体
- set:设置变量的值
- x address:查看地址address的内存内容;
- print(p):打印变量值及地址
- finish, continue &quit:
- finish:结束当前函数,返回到函数的调用点;
- continue(c): 继续运行,直到有断点处,若没有断点,则一直运行下去;
- quit(q):退出gdb
- info(i):可以查看很多信息
-
i register
info address -- Describe where symbol SYM is stored. info all-registers -- List of all registers and their contents, for selected stack frame. info args -- All argument variables of current stack frame or those matching REGEXPs. info auto-load -- Print current status of auto-loaded files. info auxv -- Display the inferior's auxiliary vector. info bookmarks -- Status of user-settable bookmarks . info breakpoints -- Status of specified breakpoints (all user-settable breakpoints if no argument). info checkpoints -- IDs of currently known checkpoints. info classes -- All Objective-C classes, or those matching REGEXP. info common -- Print out the values contained in a Fortran COMMON block. info copying -- Conditions for redistributing copies of GDB. info dcache -- Print information on the dcache performance. info display -- Expressions to display when program stops, with code numbers. info exceptions -- List all Ada exception names. info extensions -- All filename extensions associated with a source language. info files -- Names of targets and files being debugged. info float -- Print the status of the floating point unit. info frame -- All about the selected stack frame. info frame-filter -- List all registered Python frame-filters. info functions -- All function names or those matching REGEXPs. info guile -- Prefix command for Guile info displays. info handle -- What debugger does when program gets various signals. info inferiors -- Print a list of inferiors being managed. info line -- Core addresses of the code for a source line. info locals -- All local variables of current stack frame or those matching REGEXPs. info macro -- Show the definition of MACRO, and it's source location. info macros -- Show the definitions of all macros at LINESPEC, or the current source location. info mem -- Memory region attributes. info module -- Print information about modules. info modules -- All module names, or those matching REGEXP. info os -- Show OS data ARG. info pretty-printer -- GDB command to list all registered pretty-printers. info probes -- Show available static probes. info proc -- Show additional information about a process. info program -- Execution status of the program. info record -- Info record options. info registers -- List of integer registers and their contents, for selected stack frame. info scope -- List the variables local to a scope. info selectors -- All Objective-C selectors, or those matching REGEXP. info set -- Show all GDB settings. info sharedlibrary -- Status of loaded shared object libraries. info signals -- What debugger does when program gets various signals. info skip -- Display the status of skips. info source -- Information about the current source file. info sources -- All source files in the program or those matching REGEXP. info stack -- Backtrace of the stack, or innermost COUNT frames. info static-tracepoint-markers -- List target static tracepoints markers. info symbol -- Describe what symbol is at location ADDR. info target -- Names of targets and files being debugged. info tasks -- Provide information about all known Ada tasks. info terminal -- Print inferior's saved terminal status. info threads -- Display currently known threads. info tracepoints -- Status of specified tracepoints (all tracepoints if no argument). info tvariables -- Status of trace state variables and their values. info type-printers -- GDB command to list all registered type-printers . info types -- All type names, or those matching REGEXP. info unwinder -- GDB command to list unwinders. info variables -- All global and static variable names or those matching REGEXPs. info vector -- Print the status of the vector unit. info vtbl -- Show the virtual function table for a C++ object. info warranty -- Various kinds of warranty you do not have. info watchpoints -- Status of specified watchpoints (all watchpoints if no argument). info win -- List of all displayed windows. info xmethod -- GDB command to list registered xmethod matchers.
-
标签:info,常用,--,frame,gdb,those,断点,matching,调试 来源: https://www.cnblogs.com/gwzz/p/15196657.html