1

编辑:我尝试重新安装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
4

1 回答 1

1

现在,我必须使用(gdb) skip file malloc.c感谢 GDB 7.4。

我将不胜感激恢复 GDB 过去所做的任何替代方法,因此我不必手动手动添加所有标准库源文件(我(gdb) skip file stdlib.h只为那些想知道的人尝试过)

于 2013-04-30T00:43:43.913 回答