在gdb中包含malloc.c的源代码? [英] Include source code of malloc.c in gdb?
问题描述
如何在gdb中包含/查看 malloc
的源代码?
我想做一个在 gdb
中逐步执行,当调用任何malloc函数时,进入 malloc.c
源代码。
目前gdb所说的是:
malloc.c:没有这样的文件或目录。
p>
此这里的人也面临着同样的问题,但他们并没有提到一个解决方案,即如何真正进入malloc的源代码。
我在 Ubuntu服务器14.04
,我已经尝试安装以下内容:
libc6-dbg
, libc6 -dev
和 libc6-dbgsym
。
我甚至不知道这些包之一可能有帮助,但安装 libc-dbgsym
给我以下错误:
dpkg:错误处理归档/var/cache/apt/archives/libc6-dbgsym_2.19-0ubuntu6.6_amd64.ddeb(--unpack):尝试覆盖
'/usr/lib/debug/usr/lib/x86_64-linux-gnu/audit/sotruss-lib.so',其中
也在包libc6-dbg:amd64 2.19-0ubuntu6中。 6 dpkg-deb:错误:
子程序粘贴被信号(Broken pipe)杀死
以下为我工作。不确定是否有更好的方法。
- 安装libc6-dbg(您已经完成):
sudo apt-get install libc6-dbg
- 安装eglibc-source软件包(ubuntu实际使用eglibc):
sudo apt -get install eglibc-source
。 - 解压缩/ usr / src / glibc中安装的tar文件:
/ usr / src / glibc $ sudo tar xvf eglibc-2.19.tar.xz
- 打开gdb并添加到malloc源的路径:
(gdb)dir /usr/src/glibc/eglibc-2.19/malloc
(gdb)n
13 char * c = malloc(100);
(gdb)s
__ GI___libc_malloc(bytes = 100)at malloc.c:2876 2876
{
(gdb)
How can I include/view the source code of malloc
in gdb?
I want to do a step by step execution in gdb
, and step into malloc.c
source code when any of the malloc functions is called.
Currently what gdb says is:
malloc.c: No such file or directory.
This guy here faced the same problem, but they do not mention a solution, ie how to actually step into the source code of malloc.
I am on Ubuntu server 14.04
, and I have already tried to install the following:
libc6-dbg
, libc6-dev
, and libc6-dbgsym
.
I don't even know if one of these packages might help, but installing the libc-dbgsym
gives me the following error:
dpkg: error processing archive /var/cache/apt/archives/libc6-dbgsym_2.19-0ubuntu6.6_amd64.ddeb (--unpack): trying to overwrite
'/usr/lib/debug/usr/lib/x86_64-linux-gnu/audit/sotruss-lib.so', which
is also in package libc6-dbg:amd64 2.19-0ubuntu6.6 dpkg-deb: error:
subprocess paste was killed by signal (Broken pipe)
The following worked for me. Not sure whether there is a better way.
- Install libc6-dbg (which you have already done):
sudo apt-get install libc6-dbg
- Install the eglibc-source package (ubuntu actually uses eglibc):
sudo apt-get install eglibc-source
. - Unpack the tar file that was installed in /usr/src/glibc:
/usr/src/glibc $ sudo tar xvf eglibc-2.19.tar.xz
- Crank up gdb and add in the path to the malloc source:
(gdb) dir /usr/src/glibc/eglibc-2.19/malloc
(gdb) n
13 char *c = malloc(100);
(gdb) s
__GI___libc_malloc (bytes=100) at malloc.c:2876 2876
{
(gdb)
这篇关于在gdb中包含malloc.c的源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!