[Linux]gdb调试

 1 exbot@ubuntu:~/CodeLearn/HelloWorld/src$ g++ -g main.cpp
 2 exbot@ubuntu:~/CodeLearn/HelloWorld/src$ ./a.out
 3 Hello world!10
 4 exbot@ubuntu:~/CodeLearn/HelloWorld/src$ gdb a.out
 5 GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
 6 Copyright (C) 2012 Free Software Foundation, Inc.
 7 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 8 This is free software: you are free to change and redistribute it.
 9 There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
10 and "show warranty" for details.
11 This GDB was configured as "x86_64-linux-gnu".
12 For bug reporting instructions, please see:
13 <http://bugs.launchpad.net/gdb-linaro/>...
14 Reading symbols from /home/exbot/CodeLearn/HelloWorld/src/a.out...done.
15 (gdb) list
16 1    #include<stdio.h>
17 2    #include<iostream>
18 3    using namespace std;
19 4    int main()
20 5    {
21 6        printf("Hello world!");
22 7        //system("pause");
23 8        int a=0;
24 9        int b=10;
25 10        int sum=a+b;
26 (gdb) b 10
27 Breakpoint 1 at 0x400699: file main.cpp, line 10.
28 (gdb) run
29 Starting program: /home/exbot/CodeLearn/HelloWorld/src/a.out 
30 warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
31 
32 Breakpoint 1, main () at main.cpp:10
33 10        int sum=a+b;
34 (gdb) print sum
35 $1 = 0
36 (gdb) print b
37 $2 = 10
38 (gdb) print a
39 $3 = 0
40 (gdb) next
41 11        printf("%d",sum);
42 (gdb) print sum
43 $4 = 10
44 (gdb) contine
45 Undefined command: "contine".  Try "help".
46 (gdb) continue
47 Continuing.
48 Hello world!10[Inferior 1 (process 5710) exited normally]
49 (gdb) quit

 

转载于:https://www.cnblogs.com/yhlx125/p/5149338.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值