GDB manual: http://www.gnu.org/software/gdb/documentation/
1 break points
1.1 Display all break points
(gdb) info breakpoints
1.2 Set break point
(gdb) break [
:]
(gdb) break [:]
(gdb) break *
eg:
(gdb) b test.c:print_pre
(gdb) b test.c:150
(gdb) b *0x80483df
1.3 Conditional break point
(gdb) b ... if
eg:
(gdb) b 12 if i == 0
1.4 Run to the next break point
(gdb) continue
1.5 Run to the end of current function
(gdb) finish
1.6 Run to the specified source line
(gdb) until
eg:
(gdb) until 10
2 attach process
2.1 $ gdb
2.2 $ gdb
(gdb) attach
3 Variable
3.1 Set value to variable
(gdb)set(variable = value)
exec:
(gdb) set(iNum = 100)
3.2 Display the value of variable
(gdb) print
3.3 Display the value of address
(gdb) x/FMT
3.4 Set watch point to expression
(gdb) watch
(gdb) watch
eg:
(gdb) watch num
(gdb) watch i+j
4 Execute shell commond
(gdb) shell
exec:
(gdb) shell ps aux | grep test
5 Disassemble code
(gdb) disas []
If is omited, the code of function surrounding the pc of the selected frame will be disassemble
6 Register
6.1 List the contents of registers for selected stack frame, except float-pointer retisters
(gdb) info|i regiters|reg
6.2 List the contents of all registers
(gdg) info all-registers
6.3 Print content in the regisger
(gdb) p $register1 $register2 ... $registern
or
(gdb) i reg $register1 $ register2 ... $registern
eg:
(gdb) p $eax $ebx $eip $pc
(gdb) i reg $eax $ebx $eip $pc
7 step
7.1 Step probrem, proceeding through subroutine call
(gdb) n N
7.2 Step instruction
(gdb) ni N, proceeding through subroutine call
7.3 Step progrem until it reaches a different source line
(gdb) s N
7.4 Step one instruction exactly
(gdb) si N
8 set argument list
8.1 set argument list, then run program
(gdb) set args
(gdb) run
eg1:
(gdb) set args --user=user --passwd=user --verbose
(gdb) run
eg2:
(gdb) set args `perl -e 'print "ABCD\xff\xff\xffEFGHIJKL"'`
(gdb) run
8.2 run with argument list
(gdb) run
eg:
(gdb) run --user=user --passwd=user --verbose
9 Stack frame
9.1 Display backtrace of entire stack
(gdb) backtrace|bt
9.2 Display backtrace of innermost n stack frames
(gdb) backtrace|bt n
9.3 Display backtrace of outerrmost n stack frames
(gdb) backtrace|bt -n
9.4 Select frame(zero is innermost frame--current executing frame)
(gdb) frame|f n
9.5 Display description of selected stack frame(Details include frame address, programe counter saved in it, address of local variable and arguments, address of next and previous, and so on)
(gdb) info frame
10 info
10.1 Check execution status of program
(gdb) info program
11 Thread
11.1 Set break points on thread
(gdb) break thread [if ]
11.2 Show current known threads
(gdb) info thread
11.3 Switch between threads
(gdb) thread
11.4 System thread scheduler
11.4.1 Configure System thread scheduler
(gdb) set scheduler-locking [on|off]
on: disable system thread scheduler
off: enable system thread scheduler
11.4.2 Show system thread scheduler mode
(gdb) show scheduler-locking
阅读(1782) | 评论(0) | 转发(0) |