gdb 退出循环,函数,设置条件断点

原文:https://blog.csdn.net/caspiansea/article/details/37887969

  1. until

这个用于执行完循环。

在执行完循环体内的最后一条语句之后执行 until, 就会执行完循环体到后面的一个语句停下。

  1. finish

执行完当前的函数。

  1. 设置条件断点的方法:

4.1 break [location] if condition

(gdb) l
2 {
3 int i;
4 int k = 0;
5 for(i = 0; i < 10; i++)
6 {
7 k = i * i;
8 }
9
10 return 0;
11 }
(gdb) break 7 if i == 5 //此处的7为行号
Breakpoint 4 at 0x80483ca: file testloop.c, line 7.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/charles/code/testloop

Breakpoint 4, main () at testloop.c:7
7 k = i * i;
(gdb) p i
$7 = 5
(gdb)
4.2 使用 condition N condition. N是一个 breakpoint number.
(gdb) l
1 int main(void)
2 {
3 int i;
4 int k = 0;
5 for(i = 0; i < 10; i++)
6 {
7 k = i * i;
8 }
9
10 return 0;
(gdb) break 7
Breakpoint 1 at 0x80483ca: file testloop.c, line 7.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x080483ca in main at testloop.c:7
(gdb) help condition
Specify breakpoint number N to break only if COND is true.
Usage is `condition N COND’, where N is an integer and COND is an
expression to be evaluated whenever breakpoint N is reached.
(gdb) condition 1 i == 4 //此处的1为info break中的断点号
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x080483ca in main at testloop.c:7
stop only if i == 4
(gdb) r
Starting program: /home/charles/code/testloop

Breakpoint 1, main () at testloop.c:7
7 k = i * i;
(gdb) p i
$1 = 4

  1. 多线程下禁止线程切换:

set scheduler-locking on

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值