作者ric2k1 (Ric)
看板EE_DSnP
标题Re: [情报] gdb/ddd quick reference
时间Mon May 4 00:32:50 2009
去年写的, 也许大家会用到.
※ 引述《ric2k1 (Ric)》之铭言:
有监於许多同学遇到程式的 bug 但确不一定清楚如何使用 debugger,
这里写一个 quick reference 希望同学们可以多多使用 debugger.
**************************
* 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
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.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.121.132.127
1F:推 waytin:感谢老师 05/22 08:51
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.224.45.227
2F:推 suzuki1207:就这次作业的情形 还是不知道要怎麽进入func.内呀 05/05 23:01
3F:→ suzuki1207:应该是因为execOneCmd()那些code不在我们手中? 05/05 23:02
4F:→ ric2k1:就直接 break 在你想 break 的地方啊! 05/05 23:30
5F:→ ric2k1:比方说: b memMgr.h:200 上面有说明 05/05 23:31
6F:推 suzuki1207:原来是这个意思@ @ 谢谢老师~ 05/06 00:23