一、gdb,在shell窗口调试
main.c内容:
main.c
#include <stdio.h>
int main()
{
int y=0;
for (int i=0;i<10;i++){
y+=i;
}
return 0;
}
深未来技术原创文章,如转载,请注明来源http://deepfuture.iteye.com/
编译:
deepfuture@deepfuture-desktop:~/test$ gcc -ggdb -std=c99 -o main main.c
启动gdb
1、gdb 执行文件名
deepfuture@deepfuture-desktop:~/test$ gdb main
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 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 "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/deepfuture/test/main...done.
2、list为列出源代码
(gdb) list
1
2 #include <stdio.h>
3 int main()
4 {
5 int y=0;
6 for (int i=0;i<10;i++){
7 y+=i;
8 }
9 return 0;
10 }
3、运行
(gdb) run
Starting program: /home/deepfuture/test/main
Program exited normally.
4、退出gdb
5、启动gdb后,再设置要加载的文件
(gdb) file main
Reading symbols from /home/deepfuture/test/main...done.
6、设置断点,,使用break行号
(gdb) list
warning: Source file is more recent than executable.
1
2 #include <stdio.h>
3 int main()
4 {
5 int y=0;
6 for (int i=0;i<10;i++){
7 y+=i;
8 }
9 return 0;
10 }
(gdb) break 7
Breakpoint 1 at 0x80483ca: file main.c, line 7.
7、运行,run
(gdb) run
Starting program: /home/deepfuture/test/main
Breakpoint 1, main () at main.c:7
7 y+=i;
8、离开这个断点,继续运行
(gdb) c
Continuing.
9、监视变量
(gdb) watch y
Hardware watchpoint 2: y
10、检查变量变化
(gdb) c
Continuing.
Hardware watchpoint 2: y
Old value = 1
New value = 3
main () at main.c:6
6 for (int i=0;i<10;i++){
(gdb) c
Continuing.
Breakpoint 1, main () at main.c:7
7 y+=i;
(gdb) c
Continuing.
Hardware watchpoint 2: y
Old value = 3
New value = 6
main () at main.c:6
6 for (int i=0;i<10;i++){
二、ddd,使用
可以在选择行或某变量后,watch,break等按钮,很方便
右中部的面板是一些流程调试
图形方式调试
- 大小: 21.2 KB
分享到:
相关推荐
分享一套课程——Linux GDB C/C++调试基础与提升视频课程,提供源码+PPT下载。
linux - gcc/ gdb/ make 手册 .pdf 查询linux的工具。
Linux GDB C/C++调试基础与提升视频教程分享,视频+源码+PPT下载 一、gdb的概述 gdb是GNU开源组织发布的一个强大的UNIX下的程序调试工具。 二、gdb的使用场景 启动你的程序,可以按照你的自定义的要求随心所欲的...
linux c/c++ gdb调试手册
aarch64-linux-android-gdb 可调试arm64位内核的工具,目前自己测试可用
CAMBRICON CN-GDB这是CN-GDB,Linux上的BANG-C源代码级调试器,基于GNU-7.11(GNU源代码级调试器)。 有关gdb的更多信息,请参阅此文件夹中的README文件或检查GDB hom。CAMBRICON CN-GDB这是CN-GDB,Linux上的BANG-C...
官网下载最新的aarch64 gdb调试工具压缩包,有需要的可以看下
linux新手GDB入门,以c/c++为例,讲解GDB常用的操作。。。。。。
Linux-c-gdb调试.pdf 学习Linux编写C语言的资料
已往我们用的arm-linux-gcc都是一个压缩包解压来,导出环境变里的方式来安装。今天弄了一下直接从ubuntu的库来安装。其实我们用的arm-linux-gcc对应在ubuntu 中为arm-linux-gnueabi.
Dev-C++是一个Windows环境下的一个适合于初学者使用的轻量级 C/C++ 集成开发环境(IDE)。它是一款自由软件,遵守GPL许可协议分发源代码。它集合了MinGW中的GCC编译器、GDB调试器和 AStyle格式整理器等众多自由软件...
针对aarch64系统的gdb
arm-linux-gnueabihf端使用arm-linux-gnueabihf-gdb arm-linux-gnueabihf-gdb-8.2
Ubuntu16.04系统下使用arm-linux-gnueabihf-gdb arm-linux-gnueabihf-gdb-8.2_Ubuntu16.04
对Linux上的C-C++编译器和调试器 Gcc和Gdb的使用作了一定得介绍
/usr/local/gcc-4.8.5/bin/c++ -dumpversion 添加LD_LIBRARY_PATH 临时生效 export LD_LIBRARY_PATH="/usr/local/gcc-4.8.5/lib64:$LD_LIBRARY_PATH" 永久生效 echo '/usr/local/gcc-4.8.5/lib64' > /etc/ld.so....
arm-linux-gnueabihf-gdb工具包
建立jlink+arm-linux-insight+GDB Server调试环境
linux c++调试工具gdb方法使用,对于开发linux服务器程序非常有用