GDB设置step-mode
test.c文件代码展示如下:
#include <stdio.h>
#include "add.h"
int main(void)
{
int a = 10;
int b = 20;
int c = add(20,10);
printf("%d\n",c);
return 0;
}
#include <stdio.h>
#include "add.h"
int add(int a,int b)
{
return a + b;
}
#ifndef ADD_H__
#define ADD_H__
int add(int a, int b);
#endif
gcc -c -g test.c
gcc -c add.c
gcc test.o add.o -o test
gdb test
使用step-mode调试程序
(gdb) show step-mode
Mode of the step operation is off.
(gdb) run
Starting program: /home/wjc/test2/test
Breakpoint 1, main () at test.c:9
(gdb) s
9 int c = add(20,10);
(gdb) s
10 printf("%d\n",c);
(gdb) c
Continuing.
30
[Inferior 1 (process 3423) exited normally] (gdb) set step-mode on
(gdb) run
Starting program: /home/wjc/test2/test
Breakpoint 1, main () at test.c:9
(gdb) s
9 int c = add(20,10);
(gdb) s
0x000055555555468f in add ()
(gdb) c
Continuing.
30
[Inferior 1 (process 3424) exited normally]
所有教程
- C语言入门
- C语言编译器
- C语言项目案例
- 数据结构
- C++
- STL
- C++11
- socket
- GCC
- GDB
- Makefile
- OpenCV
- Qt教程
- Unity 3D
- UE4
- 游戏引擎
- Python
- Python并发编程
- TensorFlow
- Django
- NumPy
- Linux
- Shell
- Java教程
- 设计模式
- Java Swing
- Servlet
- JSP教程
- Struts2
- Maven
- Spring
- Spring MVC
- Spring Boot
- Spring Cloud
- Hibernate
- Mybatis
- MySQL教程
- MySQL函数
- NoSQL
- Redis
- MongoDB
- HBase
- Go语言
- C#
- MATLAB
- JavaScript
- Bootstrap
- HTML
- CSS教程
- PHP
- 汇编语言
- TCP/IP
- vi命令
- Android教程
- 区块链
- Docker
- 大数据
- 云计算