C 为什么在我运行gdb/bin/ls时gdb不显示错误上下文?
为什么在我运行gdb/bin/ls时gdb不显示错误上下文 我使用malloc教程()实现了我的malloc,在一个共享库中编译了它,我想用我的malloc替换系统上当前的malloc,使用LD_PRELOAD来练习调试。 但是当我通过gdb运行它时,我看不到教程中详细的错误上下文。为什么? 我的: 在教程中:C 为什么在我运行gdb/bin/ls时gdb不显示错误上下文?,c,linux,debugging,gdb,C,Linux,Debugging,Gdb,为什么在我运行gdb/bin/ls时gdb不显示错误上下文 我使用malloc教程()实现了我的malloc,在一个共享库中编译了它,我想用我的malloc替换系统上当前的malloc,使用LD_PRELOAD来练习调试。 但是当我通过gdb运行它时,我看不到教程中详细的错误上下文。为什么? 我的: 在教程中: $ gdb /bin/ls (gdb) set environment LD_PRELOAD=./malloc.so (gdb) run Program received signal
$ gdb /bin/ls
(gdb) set environment LD_PRELOAD=./malloc.so
(gdb) run
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bd7dbd in free (ptr=0x0) at malloc.c:113
113 assert(block_ptr->free == 0);
我注意到当我运行gdb/bin/ls
时,符号是从usr/lib/debug/…
读取的。这样行吗
gdb /bin/ls
Reading symbols from /bin/ls...
Reading symbols from /usr/lib/debug/.build-id/2f/15ad836be3339dec0e2e6a3c637e08e48aacbd.debug...
如果我除了调试符号外还需要源代码,我如何正确安装它
顺便说一下,这里没有提到()我需要安装源代码进行调试
以下是有关我的coreutils和coreutils dbgsym的一些信息:
$ sudo apt-get install coreutils-dbgsym
Reading package lists... Done
Building dependency tree
Reading state information... Done
coreutils-dbgsym is already the newest version (8.30-3ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
$ apt-cache policy coreutils
coreutils:
Installed: 8.30-3ubuntu2
Candidate: 8.30-3ubuntu2
Version table:
*** 8.30-3ubuntu2 500
500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
100 /var/lib/dpkg/status
您没有在预期位置安装C库程序的实际源代码。问题在于此文件
src/ls.C
。你有什么?在本教程中,我没有看到称为ls.c的实现。您是否实现了自己的ls
命令?
$ sudo apt-get install coreutils-dbgsym
Reading package lists... Done
Building dependency tree
Reading state information... Done
coreutils-dbgsym is already the newest version (8.30-3ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
$ apt-cache policy coreutils
coreutils:
Installed: 8.30-3ubuntu2
Candidate: 8.30-3ubuntu2
Version table:
*** 8.30-3ubuntu2 500
500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
100 /var/lib/dpkg/status