gpt4 book ai didi

c - GDB重置配置

转载 作者:行者123 更新时间:2023-11-30 17:52:20 25 4
gpt4 key购买 nike

编辑:我尝试重新安装gdbsudo apt-get autoremove gdb然后sudo apt-get install gdb 。仍然没有解决问题。

原始问题:

最近,大约 3 小时前,我安装了 valgrind检查内存泄漏,现在我尝试编译一些东西并运行 GDB(终端或在 Eclipse 中),所有 malloc/calloc命令也正在逐步调试。

测试文件:

#include<stdio.h>
#include<stdlib.h>

typedef struct tem{
int i;
} name;

int main() {
name *t;
printf("EASD");
t = malloc(sizeof(name));
return 0;
}

Eclipse 调试器错误(仍然显示 malloc 等函数中的变量):

Can't find a source file at "malloc.c" 
Locate the file or edit the source lookup path to include its location.




编译使用:cc -g -o asd a.c
调试使用:gdb asd

终端:

(gdb) run
Starting program: /home/userName/workspace/as/asd

Breakpoint 2, main () at a.c:10
10 t = malloc(sizeof(name));
(gdb) step 18442
Single stepping until exit from function _fini,
which has no line number information.
Single stepping until exit from function __do_global_dtors_aux,
which has no line number information.
Single stepping until exit from function _fini,
which has no line number information.
EASD33 ../sysdeps/unix/sysv/linux/_exit.c: No such file or directory.
(gdb) step
[Inferior 1 (process 6621) exited normally]

GDB 无断点:

(gdb) run
Starting program: /home/userName/workspace/as/asd
EASD[Inferior 1 (process 6631) exited normally]

我的问题是,如何重新配置​​/重置 GDB 以像以前一样跳过标准库函数?

从另一台计算机:

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/userName/a.out a.out
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Breakpoint 1, main () at a.c:10
10 printf("EASD");
(gdb) step
11 t = malloc(sizeof(name));
(gdb) step
12 return 0;
(gdb) step
13 }
(gdb) step
0xb7e067c3 in __libc_start_main () from /usr/lib/libc.so.6

最佳答案

现在,我必须使用(gdb)跳过文件malloc.c感谢GDB 7.4。

我希望有任何替代方法可以恢复 GDB 过去所做的事情,这样我就不必手动添加所有标准库源文件(我尝试了 (gdb) 跳过文件 stdlib.h 只是为了想知道的人)

关于c - GDB重置配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16269016/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com