GDB

Linux下gcc编译,动态库和静态库,makefile,gdb调试

1.编译过程 1.1 预处理(Pre-Processing) 展开头文件, 宏替换(变量宏、函数宏)、替换空格等 gcc -E hello.c -o hello.i // -E 预处理选项, -o 重命名 1.2 编译(Compilation) 逐行检查程序中出现的语法错误,简单的逻辑错误 gcc ......
静态 makefile 动态 Linux gcc

GDB 的使用

GDB 是一个共用工具,我贴两个链接,知道如何使用就行 https://blog.csdn.net/m0_65346989/article/details/130362796 https://blog.csdn.net/qq_41960196/article/details/121591749 ......
GDB

【gdb】打印函数局部变量的值

打印函数局部变量的值 1.例子: #include <stdio.h> void fun_a(void) { int a = 0; printf("%d\n", a); } void fun_b(void) { int b = 1; fun_a(); printf("%d\n", b); } voi ......
变量 局部 函数 gdb

【gdb】在匿名空间设置断点

在匿名空间设置断点 1. 例子 namespace Foo { void foo() { } } namespace { void bar() { } } 在gdb中,如果要对namespace Foo中的foo函数设置断点,可以使用如下命令: (gdb) b Foo::foo 如果要对匿名空间中的 ......
断点 空间 gdb

【gdb】为fork调用设置catchpoint

为fork调用设置catchpoint 1.例子: #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int main(void) { pid_t pid; pid = fork(); ......
catchpoint fork gdb

【gdb】为exec调用设置catchpoint

为exec调用设置catchpoint 1. 例子: #include <unistd.h> int main(void) { execl("/bin/ls", "ls", NULL); return 0; } 使用gdb调试程序时,可以用“catch exec”命令为exec系列系统调用设置cat ......
catchpoint exec gdb

【gdb】为vfork调用设置catchpoint

为vfork调用设置catchpoint 1.例子: #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int main(void) { pid_t pid; pid = vfork() ......
catchpoint vfork gdb

【gdb】同时调试父进程和子进程

同时调试父进程和子进程 1. 参考资料 1. gdb手册 2. 同时调试父进程和子进程 ......
进程 同时 gdb

【gdb】设置读写观察点

设置读写观察点 1.例子: #include <stdio.h> #include <pthread.h> #include <unistd.h> int a = 0; void *thread1_func(void *p_arg) { while (1) { a++; sleep(10); } } ......
观察点 gdb

【gdb】设置读观察点

设置读观察点 1. 例子 #include <stdio.h> #include <pthread.h> #include <unistd.h> int a = 0; void *thread1_func(void *p_arg) { while (1) { a++; sleep(10); } } ......
观察点 gdb

【gdb】

#include <stdio.h> #include <pthread.h> #include <unistd.h> int a = 0; void *thread1_func(void *p_arg) { while (1) { a++; sleep(10); } } void *thread2 ......
gdb

【gdb】显示gdb版权相关信息

显示gdb版权相关信息 使用gdb时,如果想查看gdb版权相关信息,可以使用“show copying”命令: (gdb) show copying GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free ......
gdb 版权 信息

【gdb】设置观察点

设置观察点 1. 例子 #include <stdio.h> #include <pthread.h> #include <unistd.h> int a = 0; void *thread1_func(void *p_arg) { while (1) { a++; sleep(10); } } i ......
观察点 gdb

【gdb】输出信息多时不会暂停输出

输出信息多时不会暂停输出 有时当gdb输出信息较多时,gdb会暂停输出,并会打印“ Type <return> to continue, or q <return> to quit ”这样的提示信息,如下面所示: 81 process 2639102 0xff04af84 in __lwp_park ......
信息 gdb

【gdb】gdb退出时不显示提示信息

gdb退出时不显示提示信息 gdb在退出时会提示: A debugging session is active. Inferior 1 [process 29686 ] will be killed. Quit anyway? (y or n) n 如果不想显示这个信息,则可以在gdb中使用如下命令 ......
gdb 信息

【gdb】启动时不显示提示信息

启动时不显示提示信息 $ gdb GNU gdb (GDB) 7.7.50.20140228-cvs Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http: ......
信息 gdb

【gdb】显示gdb版本信息

显示gdb版本信息 使用gdb时,如果想查看gdb版本信息,可以使用“show version”命令: (gdb) show version GNU gdb (GDB) 7.7.1 Copyright (C) 2014 Free Software Foundation, Inc. License G ......
gdb 版本 信息

【gdb】只允许一个线程运行

只允许一个线程运行 1. 例子: #include <stdio.h> #include <pthread.h> #include <unistd.h> int a = 0; int b = 0; void *thread1_func(void *p_arg) { while (1) { a++; ......
线程 gdb

【gdb】调试子进程

调试子进程 1. 例子 #include <stdio.h> #include <sys/types.h> #include <unistd.h> int main(void) { pid_t pid; pid = fork(); if (pid < 0) { exit(1); } else if ......
进程 gdb

【gdb】调试已经运行的进程

调试已经运行的进程 1.例子: #include <stdio.h> #include <pthread.h> void *thread_func(void *p_arg) { while (1) { printf("%s\n", (char *)p_arg); sleep(10); } } int ......
进程 gdb

【gdb】打印内存的值

打印内存的值 1. 例子 #include <stdio.h> int main(void) { int i = 0; char a[100]; for (i = 0; i < sizeof(a); i++) { a[i] = i; } return 0; } gdb中使用“x”命令来打印内存的值, ......
内存 gdb

【gdb】让catchpoint只触发一次

让catchpoint只触发一次 1. 例子: #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int main(void) { pid_t pid; int i = 0; for ( ......
catchpoint gdb

【gdb】进入和退出图形化调试界面

进入和退出图形化调试界面 1. 例子 #include <stdio.h> void fun1(void) { int i = 0; i++; i = i * 2; printf("%d\n", i); } void fun2(void) { int j = 0; fun1(); j++; j = ......
图形 界面 gdb

【gdb】打印数组的索引下标

打印数组的索引下标 1. 例子 #include <stdio.h> int num[10] = { 1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9 }; int main (void) { ......
下标 数组 索引 gdb

【gdb】打印ASCII和宽字符字符串

打印ASCII和宽字符字符串 1. 例子: #include <stdio.h> #include <wchar.h> int main(void) { char str1[] = "abcd"; wchar_t str2[] = L"abcd"; return 0; } 用gdb调试程序时,可以使 ......
字符 字符串 ASCII gdb

【gdb】设置观察点

设置观察点 1. 例子: #include <stdio.h> #include <pthread.h> typedef struct { int a; int b; int c; int d; pthread_mutex_t mutex; } ex_st; int main(void) { ex_ ......
观察点 gdb

【gdb】run和start区别

run和start区别 gdb调试器提供了多种方式来启动目标程序,其中最常用的就是 run 指令,其次为 start 指令。也就是说,run 和 start 指令都可以用来在gdb调试器中启动程序,它们之间的区别是: 1、默认情况下,run 指令会一直执行程序,直到执行结束。如果程序中手动设置有断点 ......
start gdb run

【gdb】断点管理

断点管理 命令说明: 命令 说明 breakb 断点命令 break 函数名 为函数设置断点 break 代码函数 为某一行设置断点 break 类名:函数名 在某个类的函数设置断点 break 文件名:函数名 在文件名指定某个函数设置断点 break 文件名:行数 在文件名执行的代码行设置断点 b ......
断点 gdb

【gdb】向上或向下切换函数堆栈帧

向上或向下切换函数堆栈帧 1. 例子: #include <stdio.h> int func1(int a) { return 2 * a; } int func2(int a) { int c = 0; c = 2 * func1(a); return c; } int func3(int a) ......
堆栈 函数 gdb

ubuntu18.04环境下编译支持debuginfod的gdb

ubuntu18.04环境下编译支持debuginfod的gdb 介绍 Ubuntu 22.10 版本才默认安装debuginfod,对于之前的发行版都需要手动配置。gdb从10.1版本才开始支持debuginfod,而Ubuntu旧的发行版里gdb都低于10.1版本。另外,debuginfod被包 ......
下编 debuginfod 环境 ubuntu 18.04