GDB抱怨缺少raise.c [英] GDB complaining about missing raise.c
问题描述
我运行了下面的示例程序:
#include< stdexcept>
int main(){
throw std :: invalid_argument();
返回0;
}
运行gdb的结果是
在抛出'std :: invalid_argument'的实例后终止调用
what():
编程接收到的信号SIGABRT,Aborted 。
__GI_raise(sig = sig @ entry = 6)at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c : 无此文件或目录。
这并不是那么糟糕,因为我得到了我需要的信息,这只是让我烦恼。
有人知道如何解决这个问题吗? 在Ubuntu上进行C库的完整源代码调试,您需要:
$ b 1)安装libc6的debuginfo版本。
它可能已经安装,但如果不是,运行 sudo apt install libc6-dbg
。
)下载与所安装版本的C库对应的源代码。
首先,创建一个目录 - 我将使用 / opt / src
这里。然后执行以下操作:
$ $ $ p $ su $ apt安装dpkg-dev $ b $ cd / opt / src
apt源码libc6
find $ PWD -maxdepth 1 -type d -name'glibc *'
记住这个名字 - 它就像 /opt/src/glibc-2.23
现在运行gdb,运行你的程序直到它停止,并在gdb提示符下执行此操作:
(gdb)信息源
当前源文件是../sysdeps/unix/sysv/linux/raise.c
编译目录是/build/glibc-KM3i_a/glibc-2.23/signal
因此,gdb期望源代码位于与我们放置的目录不同的目录中。有两种方法可以解决此问题:a)移动或使用符号链接,以便源代码(或似乎是)位于 / build / glibc-KM3i_a / glibc-2.23
。
告诉gdb如何替换正确的源目录路径名:
<
(gdb)set substitute-path /build/glibc-KM3i_a/glibc-2.23 / opt / src / glibc- 2.23
现在,回到您的框架,gdb应该显示源代码行:
(gdb)frame 1
#1 0xb7e2fea9 in __GI_raise(sig = 6)at ../sysdeps/unix/sysv/ linux / raise.c:54
返回INLINE_SYSCALL(tgkill,3,pid,selftid,sig);
I'm getting an an annoying error every time gdb catches an exception. I've run the following example program
#include <stdexcept>
int main() {
throw std::invalid_argument("");
return 0;
}
And the result from running gdb is
terminate called after throwing an instance of 'std::invalid_argument'
what():
Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
It's not all that bad, as I do get the information I need, it's just bugging me...
Do anyone know how to fix this?
To do full source code debugging of the C library on Ubuntu, you need to:
1) install the debuginfo version of libc6.
It's probably already installed, but in case it isn't, run sudo apt install libc6-dbg
.
2) download the source code corresponding to the installed version of the C library.
First, create a directory anywhere - I'll use /opt/src
here. Then do the following:
sudo apt install dpkg-dev
cd /opt/src
apt source libc6
find $PWD -maxdepth 1 -type d -name 'glibc*'
Remember this name - it'll be something like /opt/src/glibc-2.23
Now, run gdb, run your program until it stops, and at the gdb prompt do this:
(gdb) info source
Current source file is ../sysdeps/unix/sysv/linux/raise.c
Compilation directory is /build/glibc-KM3i_a/glibc-2.23/signal
So gdb is expecting the source code to be in a directory that's different from where we put it. There are two ways to fix this:
a) move or use a symlink so that the source code is (or appears to be) in /build/glibc-KM3i_a/glibc-2.23
.
b) tell gdb how to substitute the correct source directory pathname:
(gdb) set substitute-path /build/glibc-KM3i_a/glibc-2.23 /opt/src/glibc-2.23
Now, go back to your frame, and gdb should show the source code line:
(gdb) frame 1
#1 0xb7e2fea9 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54
return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
这篇关于GDB抱怨缺少raise.c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!