您的位置:首页 > 其它

GDB常用命令快速查询(英文版)

2011-12-26 10:12 204 查看
节选自:http://beej.us/guide/bggdb/

Command parameters are in italics. Optional parameters are in square brackets. All commands can be abbreviated until they become ambiguous.
This list is very very incomplete, and only shows things talked about in this tutorial!

Help Commands
help commandGet help on a certain command
apropos keywordSearch help for a particular keyword
Starting and Quitting
gdb [-tui] [-c core] [exename](Unix Command) Start gdb on an executable or standalone; specify "-tui" to start the TUI GUI; specify "-c" with a corefile name to see where a crash occurred
run [arg1] [arg2] [...]Run the currently loaded program with the given command line arguments
quitExit the debugger
file exenameLoad an executable file by name
Breakpoints and Watchpoints
break locationSet a breakpoint at a location, line number, or file (e.g. "main", "5", or "hello.c:23")
watch expressionBreak when a variable is written to
rwatch expressionBreak when a variable is read from
awatch expressionBreak when a variable is written to or read from
info breakDisplay breakpoint and watchpoint information and numbers
info watchSame as info break
clear locationClear a breakpoint from a location
delete numDelete a breakpoint or watchpoint by number
Stepping and Running
nextRun to the next line of this function
stepStep into the function on this line, if possible
stepiStep a single assembly instruction
continueKeep running from here
CTRL-CStop running, wherever you are
finishRun until the end of the current function
advance locationAdvance to a location, line number, or file (e.g. "somefunction", "5", or "hello.c:23")
jump locationJust like continue, except jump to a particular location first.
Examining and Modifying Variables
display expressionDisplay the value of a variable or expression every step of the program—the expression must make sense in the current scope
info displayShow a list of expressions currently being displayed and their numbers
undisplay numStop showing an expression identified by its number (see info display)
print expressionPrint the value of a variable or expression
printf formatstr expressionlistDo some formatted output with printf() e.g. printf "i = %d, p = %s\n", i, p
set variable expressionSet a variable to value, e.g. set variable x=20
set (expression)Works like set variable
Window Commands
info winShows current window info
focus winnameSet focus to a particular window bby name ("SRC", "CMD", "ASM", or "REG") or by position ("next" or "prev")
fsAlias for focus
layout typeSet the window layout ("src", "asm", "split", or "reg")
tui reg typeSet the register window layout ("general", "float", "system", or "next")
winheight valSet the window height (either an absolute value, or a relative value prefaced with "+" or "-")
whAlias for winheight
set disassembly-flavor flavorSet the look-and-feel of the disassembly. On Intel machines, valid flavors are intel and att
Misc Commands
RETURNHit RETURN to repeat the last command
backtraceShow the current stack
btAlias for backtrace
attach pidAttach to an already-running process by its PID
info registersDump integer registers to screen
info all-registersDump all registers to screen
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: