ubuntu 中gdb调试器

目录

         一,调试目标

二,调试的前提条件

三,调试的错误 

四,gdb调试器的相关命令 

1》进入gdb

2》查看源代码 ---- l 

3》设置断点 --- //b 行号

4》查看断点信息 ----- info b 

5》执行程序 ----- r 

6》删除断点 ---- d  断点编号

7》单步调试 ------ /n  或 s 

8》继续执行程序 ------ c 

9》查看变量的值 ----- p 

10》退出 


一,调试目标


    可执行文件

二,调试的前提条件

 
    1》编译时,必须加"-g"
        例如:gcc gdbtest.c -o gdbtest -g
        
    2》调试时,源文件必须在同一个目录中
    

三,调试的错误 


    gdb只能调试可执行文件,所以,当程序有语法错误是不能用gdb调试的
    gdb只能够调试以下错误:
    1》逻辑错误
    2》段错误
        


四,gdb调试器的相关命令 

    应为gdb为字符界面调试器,所以需要掌握调试的命令


1》进入gdb

        root@ubuntu:~/day01_code$ gdb gdbtest
        GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
        Copyright (C) 2018 Free Software Foundation, Inc.
        License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
        This is free software: you are free to change and redistribute it.
        There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
        and "show warranty" for details.
        This GDB was configured as "x86_64-linux-gnu".
        Type "show configuration" for configuration details.
        For bug reporting instructions, please see:
        <http://www.gnu.org/software/gdb/bugs/>.
        Find the GDB manual and other documentation resources online at:
        <http://www.gnu.org/software/gdb/documentation/>.
        For help, type "help".
        Type "ap
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值