- 论坛徽章:
- 0
|
小弟这几天因工作需要,要用到ladebug调试器,翻译了一下帮忙文档
有不对之处,请指教:
学习ladebug调试工具
获得在线帮忙,请使用命令help.
help [topic] 查看topic的帮忙主题
help command 查看命令的帮忙
help ladebug 查看以功能模块划分的帮忙
启动图形调试界面
1: %ladebug -gui
2: 或者在调试态下输入命令gui
(ladebug)gui
我的机器上是出不来图形界面,好象是少一个什么东西
一: 启动ladebug调试器,有四种基本方法:
1:
% ladebug a.out
Welcome to the Ladebug Debugger Version n
------------------
object file name: /usr/users/user1/a.out
Reading symbolic information ...done
(ladebug) stop in main
[#1: stop in int main(void) ]
(ladebug) run
2:
% ladebug
Welcome to the Ladebug Debugger Version n
(ladebug) load a.out
Reading symbolic information ...done
(ladebug) stop in main
[#1: stop in int main(void) ]
(ladebug) run
3:
% a.out &
[2] 27859
% jobs
[2] Running
...
% ladebug a.out -pid 27859
Attached to process id 27859
....
4:
% a.out &
[2] 27859
% jobs
[2] Running
...
% ladebug
(ladebug) attach 27859 a.out
Attached to process id 27859
....
二:
1: 命令source
(ladebug) source filename
从脚本文件finename读取命令并执行.
2: 命令file
不带任何参数时,显示现在所在的文件名
当带参数.如file filename,时,切换到文件filename,
当你想要在文件filename中某个函数上设置断点时,需要先切换该文件中去.
3:
命令fileexpr
当文件名是用一个字符串变量表示,以这个字符串变量进行引用的时,需要用到这个命令
如:
(ladebug) run
[1] stopped at [void main(void):114 0x120004040]
114 unsigned int j = 1; // for scoping examples
(ladebug) file
solarSystemSrc/main/solarSystem.cxx
(ladebug) set $originalFile = "solarSystem.cxx"
(ladebug) file star.cxx
(ladebug) list 24: 10
24 // Stars are simple objects
25 //
26 Star::Star(
27 char* name,
28 StellarClass classification,
29 StellarSubclass subclassification)
30 : HeavenlyBody(name),
31 _classification(classification),
32 _subclassification(subclassification)
33 {
(ladebug) stop at 26
[#2: stop at "solarSystemSrc/star.cxx":26 ]
(ladebug) cont
[2] stopped at [Star::Star(char*, enum StellarClass, StellarSubclass):26 0x120004b4c]
26 Star::Star(
(ladebug) file
solarSystemSrc/star.cxx
(ladebug) fileexpr $originalFile
(ladebug) file
solarSystemSrc/main/solarSystem.cxx
4:
命令list
list startline : addline 从startline开始显示addline行
list startline , endline 显示startline到endline之间的行
list 从当前行开始向下显示默认的addline行
5:
命令/ ?
/str : 向下查找str,对大小写敏感
?str : 向上查找str,对大小写敏感
6:
命令alias
对一些命令作一个别名
alias 显示所有的别名
alias str 显示str别名的信息
alias str = "string" 把str当做string的别名
7:
命令process
调试进程有以下几种方法:
当进程是一个简单的程序,你可以这样启动调试它:
@ % ladebug a.out #这里a.out是你要调试的可执行程序
@ % ladebug
*(ladebug) load a.out #用命令load命令加载要调试的可执行程序
当要调试程序是下面几种情况之一:
@ 是一个已经在运行了的程序
@ 程序有复杂的命令行参数
@ 是管道程序的一部分
@ 程序是从一个很难修改的脚本文件执行的
这时你可以用下面二种方法进行调试:
@ %ladebug -pid process_id a.out
@ %ladebug
(ladebug) attach process_id a.out #在这里process_id你可以运行sh命令jobs查看到
命令show process [all] 可选项all,可是是单词all,也可以是*,以显示所有进程信息
命令process pid :切换到进程pid,
如果参数pid没有指定,则显示当前所有进程信息,同show process [all]效果一样
调试fork产生的进程
ladebug中的调试变量:
$catchforks : 为非零时,指示调试器在fork/vfork调用结束时停止子进程的执行,父进程可以继续执行,它的默认值为0.
$stopparentonfork : 为非零时,指示调试器在fork/vfork产生子进程后调用结束时,停止父进程的招待,它的默认值也为0,
这时如果$catchforks为0,子进程可以继续运行。
$catchforkinfork : 为非零时,指示调试器在fork/vfork调用结束时,停留在fork/vfork函数调用中,并提示你fork了一进程。
你可以通过设置这个调试变量,来调试fork进程,因为调试器会停留在这个系统调用中,这里你可能需要用到
命令up以返回到你自己的用户代码中去.
当系统调用fork调用结束时,调试器会设置调试变量$childprocess,$parentprocess分别为子进程和父进程的id号。
ladebug) set $catchforks = 1 #设置它以停止子进程的招待
(ladebug) run
Process 29027 forked. The child process is 29023.
Process 29023 stopped on fork.
stopped at [int main(void):6 0x120001178]
6 int pid = fork();
fork.c: I am the parent.
Process has exited with status 0 #父进程已经执行完
(ladebug) show process
>;localhost:29028 (/usr/examples/fork) loaded.
localhost:29023 (/usr/examples/fork) paused #子进程的状态是paused
现在我们切换到子进程
(ladebug) process $childprocess # 切换到子里程,$childprocess,代表了子进程的id号,
(ladebug) show process #显示所有进程信息
localhost:29028 (/usr/examples/fork) loaded.
>;localhost:29023 (/usr/examples/fork) paused. # >; 指示当前进程
(ladebug) list # 显示子进程 要执行的代码
7
8 if (pid == 0)
9 {
10 printf("fork.c: I am the child.\n" ;
11 }
12 else
13 {
14 printf("fork.c: I am the parent.\n" ;
15 }
16 }
调试exec产生的进程
调试变量$catchexecs :
$catchexecs : 为非零时,指示调试器停止这个进程的运行,并提示你开始了一个exec系统调用。
(ladebug) set $catchforks = 1
(ladebug) set $catchexecs = 1
(ladebug) run
Process 14839 forked. The child process is 14835.
Process 14835 stopped on fork.
stopped at [int main(void):8 0x1200011f8]
8 if ((pid = fork()) == 0) #当前停止在第8行
x_exec.c: I am the parent.
Process has exited with status 0 #父进程已经执行完毕,因为没有设置$stopparentonfork = 1
(ladebug) show process
>;localhost:14918 (x_exec) loaded.
localhost:14835 (x_exec) paused.
(ladebug) process $childprocess #切换到子进程
(ladebug) list 6: 13 #从第6行开始向下显示13行
6 int pid;
7
>; 8 if ((pid = fork()) == 0)
9 {
10 printf("About to exec \n" ;
11 fflush(stdout); /* Make sure the output gets out! */
12 execlp("announcer", "announcer", NULL); #这里有一个exec系统调用
13 printf("After exec \n" ;
14 }
15 else
16 {
17 printf("x_exec.c: I am the parent.\n" ;
18 }
(ladebug) cont #继续运行 提示停止在exec处,因为设置了$catchexecs = 1
About to exec
The process 14835 has execed the image "./announcer".
Reading symbolic information ...done
stopped at [ 0x3ff8001bf48]
5 printf("announcer.c: I am here!! \n" ;
7:
命令thread
显示线程的一些信息
线程有二种级别:
decthreads--posix线程
native --内核级线程
设置线程级别:
(ladebug) set $threadlevel = "decthreads"
(ladebug) print $threadlevel
"decthreads"
(ladebug) show thread
Thread Name State Substate Policy Pri
------ ------------------------- --------------- ----------- ------------ ---
* 1 default thread running VP 3 SCHED_OTHER 19
-1 manager thread blk SCS SCHED_RR 19
-2 null thread for slot 0 running VP 1 null thread -1
-3 null thread for slot 1 ready VP 3 null thread -1
-4 null thread for slot 2 new new null thread -1
-5 null thread for slot 3 new new null thread -1
>; 2 threads(0x14000079 blocked cond 3 SCHED_OTHER 19
3 threads+8(0x1400007a0) blocked cond 3 SCHED_OTHER 19
4 threads+16(0x1400007a blocked cond 3 SCHED_OTHER 19
5 threads+24(0x1400007b0) blocked cond 3 SCHED_OTHER 19
6 threads+32(0x1400007b blocked cond 3 SCHED_OTHER 19
(ladebug) set $threadlevel = "native"
(ladebug) print $threadlevel
"native"
(ladebug) show thread #用show thread 命令不带参数,以显示对调试器知道的所有线程
Id State
* 0x9 stopped
* 0x9 unstarted
0x3 unstarted
0x7 unstarted
(ladebug) thread
Thread Name State Substate Policy Pri
------ ------------------------- --------------- ----------- ------------ ---
>;* 1 default thread running VP 3 SCHED_OTHER 19
*表示最近被中断的线程
>;表示当前的线程
调试变量$curthread,表示当前线程,你可以运行 p $curthread来查看它
你可以切换到具体某个线程,以查看它的信息
命令thread thread_id
(ladebug) thread 2
Thread Name State Substate Policy Pri
------ ------------------------- --------------- ----------- ------------ ---
>; 2 threads(0x14000079 blocked cond 3 SCHED_OTHER 19
命令show thread 的完整形式是这样的:
(ladebug)show thread thread_id_list thread_state_filter
在这里:
thread_id_list有几种表现形式:
@ thread_id1,thread_id2,... #以逗号间隔表示多个线程id
@ * #以*表示所有线程
thread_state_filter的表现形式:
with state eq thread_state 在这个表态式中,对于c/c++语言,eq的表现形式是"=="
thread_state的值可以为下面几个
@ ready
@ running
@ terminated
@ blocked
显示互斥体的信息
命令show mutex mutex_id_list mutex_state_filter
mutex_id_list 表现形式为,以逗号为间隔分开: mutex_id1 , mutex_id2
mutex_state_filter 表现形式为:
with state eq mutex_state
对于 c /c++ 语言,eq的表现形是"=="
mutex_state的值为
@ locked
具体使用方法和show thread的使用方法一样
显示条件变量的信息
命令show condition condition_id_list condition_state_filter
condition_id_list 表现形式为,以逗号为间隔分开: condition_id1 , condition_id2
condition_state_filter 表现形式为:
with state eq condition_state
对于 c /c++ 语言,eq的表现形是"=="
condition_state的值为
@ wait
具体使用方法和show thread的使用方法一样
8:
命令where : 查看椎栈的信息
where expression thread_specifier
expression : 是一个非负整数,如果expression没有指定,则显示该线程所有的椎栈中函数调用情况
(ladebug) where 4 #查看椎栈4层的信息
>;0 0x12000226c in ((Node*)0x140004000)->;Node::Node() "x_list.cxx":77
#1 0x1200022b8 in ((IntNode*)0x140004000)->;IntNode::IntNode(data=2) "x_list.cxx":88
#2 0x120002358 in ((CompoundNode*)0x140004000)->;CompoundNode::CompoundNode(fdata=12.345000267028809, idata=2) "x_list.cxx":101
#3 0x12000251c in main() "x_list.cxx":189
(ladebug) up 2 #
>;2 0x120002358 in ((CompoundNode*)0x140004000)->;CompoundNode::CompoundNode(fdata=12.345000267028809, idata=2) "x_list.cxx":101
101 CompoundNode::CompoundNode(float fdata, int idata)
(ladebug) list $curline - 10: 20
91 void IntNode::printNodeData() const
92 {
93 cout << " type is integer, value is ";
94 cout << _data << endl;
95 }
96
97
98 //=============================================================================
99 // CompoundNode definition
100 //
>; 101 CompoundNode::CompoundNode(float fdata, int idata)
102 :
103 IntNode(idata),
104 _fdata (fdata)
105 {
106 }
107 void CompoundNode::printNodeData() const
108 {
109 cout << " type is compound, value is ";
110 cout << _fdata << endl;
(ladebug) down 1
>;1 0x1200022b8 in ((IntNode*)0x140004000)->;IntNode::IntNode(data=2) "x_list.cxx":88
88 IntNode::IntNode(int data) : _data(data)
命令up/down/func
up expression : 在当前的椎栈层向上移动expression层,当不带参数运行时,默认向上移动一层。
down expression : 在当前的椎栈层向下移动expression层,当不带参数运行时,默认向下移动一层
func loc : 改变椎栈中当前的func为loc函数,如果不带参数运行,则显示当前运行的函数
具体有那些函数在椎栈中运行,可以运行命令where查看.
在这里loc,可以是函数名,也可以是从命令where中查看到椎栈层序号.
命令up/down组合起来能完成命令func的功能,所以我觉得用命令func更省事,输入函数名或者椎栈层序号,
则直接转入到那个函数调用,而不要用命令up/down上上下下.
但当函数名很复杂时,还是用up/down打字来得快,呵呵
命令dump : 查看椎栈中函数调用的参数和局部变量值
如果不带参数运行dump,则显示当前函数中的参数和局部变量,
如果带参数 . 运行,则显示椎栈中所有函数调用的参数和局部变量
这个命令比较有用,与print相比,它能一下子查看到函数中所有的变量值
9:
命令print : 查看变量或者表达式的值.
(ladebug) print fdata
12.345000267028809
(ladebug) print idata
2
(ladebug) print idata + 59
61
(ladebug) print this
0x140004000
(ladebug) print *this
class CompoundNode {
_fdata = 0;
_data = 0; // class IntNode
_nextNode = 0x0; // class IntNode::Node
}
10:
命令wi 是 ($curpc-20)/10 i 的别名.查看数据及指令
(ladebug) alias wi
wi ($curpc - 20)/10 i
(ladebug) wi
CompoundNode::CompoundNode(float, int): x_list.cxx
[line 105, 0x120002348] cpys $f17,$f17,$f0
[line 105, 0x12000234c] bis r31, r18, r8
[line 101, 0x120002350] bis r31, r19, r16
[line 101, 0x120002354] bis r31, r8, r17
[line 101, 0x120002358] bsr r26, IntNode::IntNode(int)
*[line 101, 0x12000235c] ldq r18, -32712(gp)
[line 101, 0x120002360] lda r18, 48(r1
[line 101, 0x120002364] stq r18, 8(r19)
[line 101, 0x120002368] sts $f0, 24(r19)
[line 106, 0x12000236c] bis r31, r19, r0
(ladebug) $pc/10x
0x12000235c: 0x8038 0xa65d 0x0030 0x2252 0x0008 0xb653 0x0018 0x9813
0x12000236c: 0x0400 0x47f3
(ladebug) $pc/6xx
0x12000235c: 0xa65d8038 0x22520030 0xb6530008 0x98130018
0x12000236c: 0x47f30400 0x47f5041a
(ladebug) $pc/2X
0x12000235c: 0x22520030a65d8038 0x98130018b6530008
用命令printregs也可以查看寄存器的值.
(ladebug) printregs
$r0 [$v0] = 1 $r1 [$t0] = 5
$r2 [$t1] = 4 $r3 [$t2] = 3
$r4 [$t3] = 2 $r5 [$t4] = 5
$r6 [$t5] = 0 $r7 [$t6] = 4
$r8 [$t7] = 2 $r9 [$s0] = 3
$r10 [$s1] = 0 $r11 [$s2] = 4
$r12 [$s3] = 351841472 $r13 [$s4] = 4
$r14 [$s5] = 340620416 $r15 [$s6] = 1
$r16 [$a0] = 5368717312 $r17 [$a1] = 2
$r18 [$a2] = 2 $r19 [$a3] = 5
$r20 [$a4] = 5368717360 $r21 [$a5] = 4
$r22 [$t8] = 1 $r23 [$t9] = 5
$r24 [$t10] = 4396973371008 $r25 [$t11] = 1
$r26 [$ra] = 4831847228 $r27 [$t12] = 0
$r28 [$at] = 4831845184 $r29 [$gp] = 5
$r30 [$sp] = 4831834640 $r31 [$zero]= 0
$f0 = 12.34500026702881 $f1 = 0
$f2 = 0 $f3 = 0
$f4 = 0 $f5 = 0
$f6 = 0.10000000000000001 $f7 = 0.20000000000000001
$f8 = 0.29999999999999999 $f9 = 0.40000000000000002
$f10 = 0.5 $f11 = 0
$f12 = 0 $f13 = 0
$f14 = 0 $f15 = 0
$f16 = 0 $f17 = 0
$f18 = 0 $f19 = 0
$f20 = 0 $f21 = 0
$f22 = 0 $f23 = 0.59999999999999998
$f24 = 12.34500026702881 $f25 = 0
$f26 = 0.69999999999999996 $f27 = 0.80000000000000004
$f28 = 0.90000000000000002 $f29 = 1
$f30 = 1.1000000000000001 $f31 = 0
$pc = 0x12000226c $ps = 0x8
$fpcr = 0x0 $uniq = 0x0
$vfp = 0x11ffff210
11:
继续运行程序
命令 别名 简短描述
cont c 继续运行到下一个断点处
next n 向前单步运行一行,但不进入函数里
step s 向前单步运行一行,进入到函数里
return 继续运行直到本函数调用者
nexti ni 单指令运行,不进入到函数里
stepi si 单指令运行,进入到函数里
12:
快照snapshot: 保存当前进程的状态
当你在调试程序时,经常可能需要返回到原来某个地方,这时你可以在某个重要位置先保存好snapshot,
以便后面可能要撤消到这步
命令save snapshot --保存当前进程的状态
命令clone snapshot --返回到前一个snapshot状态
13:
重复执行命令或者以脚本执行命令
@ 输入!!或者 回车 重复上一次命令.
@ !num 重复历史命令中第num个命令,具体那个num,可以运行history查看先前都运行了什么命令
@ !-num 运行历史命令流中倒数第num个命令,
@ !str 运行历史命令流中以str打头的命令
14:
命令whereis whereis_name
显示whereis_name所有声明信息
在c++语言中用的比较多,你可以用这个查看该whereis_name在不同类的重载信息
ladebug) whereis print
"solarSystemSrc/base_class_includes/heavenlyBody.h"`HeavenlyBody::print(unsigned int)
"solarSystemSrc/derived_class_includes/planet.h"`Moon::print(unsigned int)
"solarSystemSrc/derived_class_includes/planet.h"`Planet::print(unsigned int)
"solarSystemSrc/derived_class_includes/star.h"`Star::print(unsigned int)
命令which which_name
在当前范围显示which_name的信息
在实际应用当中,应该用命令where和which组合起来,以确定一个变量的信息
ladebug) where 4 #显示椎栈中4层信息
>;0 0x1200047dc in ((Planet*)0x140004060)-> lanet::print(i=2) "solarSystemSrc/planet.cxx":19
#1 0x12000422c in ((HeavenlyBody*)0x140004060)->;HeavenlyBody::printBodyAndItsSatellites(i=2) "solarSystemSrc/heavenlyBody.cxx":62
#2 0x120004254 in ((HeavenlyBody*)0x140002c00)->;HeavenlyBody::printBodyAndItsSatellites(i=1) "solarSystemSrc/heavenlyBody.cxx":68
#3 0x120004110 in main() "solarSystemSrc/main/solarSystem.cxx":120
(ladebug) which i #查看当前函数中的i信息
"solarSystemSrc/planet.cxx"`Planet::print(unsigned int)`i
(ladebug) assign i = 10
(ladebug) print i
10
(ladebug) whereis i # i在下面这么多函数中有定义
"solarSystemSrc/heavenlyBody.cxx"`HeavenlyBody::printBodyAndItsSatellites(unsigned int)`i
"solarSystemSrc/heavenlyBody.cxx"`HeavenlyBody::printBodyAndItsSatellites(unsigned int)`i
"solarSystemSrc/heavenlyBody.cxx"`HeavenlyBody::satelliteNumber(class HeavenlyBody*)`i
"solarSystemSrc/main/solarSystem.cxx"`main`i
"solarSystemSrc/main/solarSystem.cxx"`printBiggestMoons`i
"solarSystemSrc/main/solarSystem.cxx"`trackBiggestMoons(class Moon*)`i
"solarSystemSrc/planet.cxx"`Moon::print(unsigned int)`i
"solarSystemSrc/planet.cxx"`Planet::print(unsigned int)`i
"solarSystemSrc/star.cxx"`Star::print(unsigned int)`i
(ladebug) func HeavenlyBody::printBodyAndItsSatellites #切换到函数HeavenlyBody::printBodyAndItsSatellites
void HeavenlyBody::printBodyAndItsSatellites(unsigned int) in solarSystemSrc/heavenlyBody.cxx line No. 62:
62 print(i);
(ladebug) which i #显示在该函数HeavenlyBody::printBodyAndItsSatellites中的i信息
"solarSystemSrc/heavenlyBody.cxx"`HeavenlyBody::printBodyAndItsSatellites(unsigned int)`i
(ladebug) print i
2
命令whatis whatis_expression
显示whatis_expression的类型信息
如果whatis_expression 是一个变量,则显示则变量的类型名信息,
如果whatis_expression 是一个类型,则显示该类型里面所有成员的具体信息
ladebug) whatis StellarClass
enum StellarClass {O, B, A, F, G, K, M, R, N, S}
15:
命令enable /disable 使能和禁止断点的运行
16:
设置断点
可以和以下几种形式:
@ breakpoint_definition_command
@ simple_stop_command
@ signal_command #信号
@ obsolete_breakpoint_definition_command #老的调试命令,为了兼容
@ breakpoint_table_command
对于 @ breakpoint_definition_command
它有下面的表现形式:
: disposition [quiet] detector [thread_filter] [logical_filter] [breakpoint_actions]
对于disposition
可以有二种表现形式: stop / when
命令stop : 当breakpoint指定的事件发生,程序停止运行,调试器提示用户进行下一步操作.
命令when : 当breakpoint指定的事件发生,程序继续进行程序,它和命令stop是二个相反的概念.
对于quiet,
通常地,调试器探测到一个事件,会显示该断点的信息,但如果指定quiet,则会忽略这些信息,而不显示出它们.
(ladebug) when in main { stop }
[#1: when in int main(void) { stop } ]
(ladebug) run
[1] when [int main(void):182 0x120002418] #下面这二行显示了断点信息
[1] stopped at [int main(void):182 0x120002418]
182 List<Node>; nodeList;
如果指定了quiet
(ladebug) when quiet in main { stop }
[#11: when quiet in int main(void) { stop } ]
(ladebug) run
(ladebug) list $curline: 1
>; 182 List<Node>; nodeList;
对于detector :
可以有下面几个表现形式
@ place_detector #具体到某行,某个函数,某个指令
@ watch_detector #具体到某个变量或者某个内存区
@ signal_detector #具体到信号
@ unaligned_detector # 具体到地址不对齐
而对于具体的 @ place_detector
又有下面几种具体表现形式:
@ in function_name
@ in all function_name
@ pc address_expression
@ at line_specifier
@ every proc entry
@ every procedure entry
@ every instruction
@ expression
@ in function_name : 指示调试器停止在函数function_name上,如果在程序中有好几个函数名匹配,
调试器会进一步提示你选择具体那个
@ in all function_name : 指示调试器停止在函数function_name上,如果在程序中有好几个函数名匹配,则会选择所有的
@ pc address_expression : 停止在指定的机器地址上
@ at line_specifier : 停止在源程序当前文件中指定的行.
@ every proc entry : 停止在每个函数调用口上.
@ every procedure entry : 停止在每个函数调用口上. 这二个慎重使用,会非常耗时,因为他可能会产生成百上千个断点
@ every instruction : 在每个指令上设置一个断点,这个命令也会减慢程序执行的速度
@ expression :
而对于具体的 @ watch_detector
它的表现形式为:
: basic_watch_detector watch_detector_modifiers
对于它其中的basic_watch_detect,又有下面几种具体形式:
@ variable expression
@ memory start_address_expression
@ memory start_address_expression , end_address_expression
@ memory start_address_expression : byte_count_expression
对于 它其中的watch_detector_modifiers,它的表现形式为:
:[access_modifier] [within_modifier]
对于access_modifier,它有下面几种具体的形式:
@ write
@ read
@ changed
@ any
对于within_modifier,它的表现形式为:
: within function_name
而对于具体的 @ signal_detector
它的表现形式为:
: signal signal_id
而signal_id 可以下面二种形式:
@ 整形数,用以表示那个信号,因为每个信号是用一个数字表示的
@ 信号名,也可以直接用信号名来表示
(ladebug) stop signal SEGV, 3, SIGINT
[#2: stop signal SEGV, 3, SIGINT ]
而对于具体的 @ unaligned_detector (tru64 unix only)
它的表现形式为:unaligned
有时你程序运行可能会出现这种错误:
Unaligned access pid=30231 va=0x11ffff791 pc=0x120001af4 ra=0x120001b84 inst=0xa0220000
这时你可以:
(ladebug) stop unaligned
[#1: stop unaligned ]
(ladebug) run
Thread encountered Unaligned Access
[1] stopped at [int unalignedAccess(void):27 0x120001af8]
27 return y;
对于thread_filter:
thread thread_id,...
对于logical_filter
if expression
当表态式expression为真时,设置该断点。
表态式expression符合当前编程语言的语法,调试器会在断点处的上下文中检查expression,
如果表态式expression没有被评估,或者在这此表态式不可见,则在这检查后,会把它当作一个内部
形式,而在后续过程中不再检查。
如果在检查的过程中,发生了一个错误,比方说,表态式中的一个变量名没有定义,则会产生一个错误,
并假定该表态式的值为真。
(ladebug) when in List<Node>;::append if x
[#5: when in void List<Node>;::append(class Node* const) if x ]
(ladebug) cont
Symbol "x" is not defined.
[Error while evaluating breakpoint condition - taken as true]
[5] when [void List<Node>;::append(class Node* const):148 0x120001dbc]
Symbol "x" is not defined.
[Error while evaluating breakpoint condition - taken as true]
[5] when [void List<Node>;::append(class Node* const):148 0x120001dbc]
[4] stopped at [int main(void):195 0x120002600]
195 nodeList.append(new IntNode(3));
对于Breakpoint Actions :
它的表现形式为:
action_list
而action_list的表现形式为:
@ command
@ command ;
@ command ; ...
而具体有那些命令呢:
@ alias_command
@ attach_command
@ braced_command_list
@ breakpoint_command
@ browse_source_command
@ call_stack_command
@ command_repetion_command
@ continue_command
@ detach_command
@ edit_file_command
等等.
(ladebug) when in List<Node>;::print { stop ; print "*** stopped ***"}
[#6: when in void List<Node>;::print(void) { stop ; print "*** stopped ***"} ]
(ladebug) cont
[6] when [void List<Node>;::print(void):162 0x120001e90]
*** stopped ***
[6] stopped at [void List<Node>;::print(void):162 0x120001e90]
162 Node* currentNode = _firstNode;
对于signal_command:
它有二种表现形式:
@ catch command
@ ignore command
对于 @ cathc command
:catch signal_id : 信号id可以为表示信号的数字值,也可以直接为信号名,但信号名要去掉前缀"SIG",
如果不带参数signal_id运行,则显示当前所有要捕捉到的signal
对于 @ ignore command
:ignore signal_id :信号id可以为表示信号的数字值,也可以直接为信号名,但信号名要去掉前缀"SIG"
如果不带参数signal_id运行,则显示当前所有要忽略的signal.
下面二个命令等效:
ladebug) catch BUS #注意之处是BUS,还没有前缀SIG
or
(ladebug) stop signal SIGBUS
[#1: stop signal SIGBUS ]
但它们之间也有一些细微的区别:
@ 对于catch命令,在断点表中没有它相应的条目.
@ 对于catch命令,它只能捕捉到该信号一次,而不会二次或者多次。
对于@ breakpoint_table_command
每当一个断点被设置,都会在断点表有一个条目。
breakpoint_table_commande 有下面几种形式:
@ show_all_breakpoint_command
@ delete_breakpoint_command
@ enable_breakpoint_command
@ disable_breakpoint_command
对于 @ show_all_breakpoint_command:
使用命令: status
(ladebug) status
#1 PC==0x120002418 in int main(void) "x_list.cxx":182 { stop }
#2 PC==0x120001dbc in void List<Node>;::append(class Node* const) "x_list.cxx":148 { break }
#3 Access memory (write) 0x11fffbf90 to 0x11fffbf97 { stop }
对于@ delete_breakpoint_command
它有二种表现形式:
@ delete all
@ delete breakpoint_number_expression
对于@ enable_breakpoint_command
它有二种表现形式:
@ enable all
@ enable breakpoint_number_expression
对于@ disable_breakpoint_command
它有二种表现形式:
@ disable all
@ disable breakpoint_number_expression
(ladebug) disable 1
(ladebug) status
#1 PC==0x120002418 in int main(void) "x_list.cxx":182 { stop } Disabled
#2 PC==0x120001dbc in void List<Node>;::append(class Node* const) "x_list.cxx":148 { break }
#3 Access memory (write) 0x11fffbf90 to 0x11fffbf97 { stop }
(ladebug) disable 10 - 8,1 + 1 + 1
(ladebug) status
#1 PC==0x120002418 in int main(void) "x_list.cxx":182 { stop } Disabled
#2 PC==0x120001dbc in void List<Node>;::append(class Node* const) "x_list.cxx":148 { break } Disabled
#3 Access memory (write) 0x11fffbf90 to 0x11fffbf97 { stop } Disabled
(ladebug) delete 1
(ladebug) status
#2 PC==0x120001dbc in void List<Node>;::append(class Node* const) "x_list.cxx":148 { break } Disabled
#3 Access memory (write) 0x11fffbf90 to 0x11fffbf97 { stop } Disabled
(ladebug) enable all
(ladebug) status
#2 PC==0x120001dbc in void List<Node>;::append(class Node* const) "x_list.cxx":148 { break }
#3 Access memory (write) 0x11fffbf90 to 0x11fffbf97 { stop } |
|