網頁

2017年11月21日 星期二

gdb/ddd quick reference


************************** 
* gdb/ddd survival guide * 
************************** 

[Commonly used commands] 
======================== 

r [options]: run the program with [options] 
n: execute the next line of the program 
s: step into the function under current line 
b [funcName | lineNo]: set break point on (funcName) or (lineNo), break on current line if no parameter is specified. e.g. b BSTree::insert b adtTest.h:106 
del (breakPointId): delete the break point by ID 
c: continue the execution to the next break or watch point 
p (var): print the content of the variable 
p* (var): print the content of the memory pointed by the varaible 
display (var): display the content of the variable 
display* (var): display the content of the memory pointed by the varaible 
undisplay (displayId): undisplay by ID 
up: move up one level of source code (for viewing; won't affect the execution) 
down: move down one level of source code (for viewing) 
where: show the calling trace to the current line 
info breakpoints: show the information of breakpoints (e.g. how many times breakpoints have been visited)
dir (dirName): add (dirName) for the look-up of the source code 
(Ctrl-c): force to break the execution 
q: quit the debugger 


[Less common commands]
====================== 

call (funcName): call the function 
set (varName) = (value): force to set the variable value 
watch (expression): set the watch point (used with 'continue') e.g. watch (idx = 10) // note: not "==" 
tbreak [funcName | lineNo]: set the temporary break point. Voided after the first encounter. 
b if (expression): conditional break point 


[Note] 
====== 
You can add a number to most of the commands to specify the "repeating times".For example, "n 10" will execute the next 10 lines of codes. "c 100" means you will ignore the next 99 break points and stop at the 100th one.

沒有留言:

張貼留言