gdb列表错误“没有这样的文件或目录”(gdb list error “No such file or directory”)

编程入门 行业动态 更新时间:2024-10-28 15:23:59
gdb列表错误“没有这样的文件或目录”(gdb list error “No such file or directory”)

我目前正在运行一个文件管理器程序,该程序突然崩溃并出现分段错误并转储了一个核心文件。 所以我使用gdb来调试核心文件:

gdb /path/to/executable /path/to/core

我运行的程序是用C ++编写的。 当我运行GDB并尝试使用“list”打印源代码行时,出现以下错误:

(gdb) bt #0 0x0000000000554286 in MyFSEventManager::AddEvent(wxFileSystemWatcherEvent&) () #1 0x00000000005ab2e8 in MyGenericDirCtrl::OnFileWatcherEvent(wxFileSystemWatcherEvent&) () (gdb) f 0 #0 0x0000000000554286 in MyFSEventManager::AddEvent(wxFileSystemWatcherEvent&) () (gdb) l 1 /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gmain.c: No such file or directory.

为什么gdb会这样说“/build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gmain.c:没有这样的文件或目录。” 我没有使用gdb调试的其他程序遇到此问题。

使用的操作系统是在Oracle虚拟机上运行的Ubuntu 16.04。 我想可能是没有加载的gdb符号。 因为我使用“-g”选项编译程序,所以我不确定为什么。 我真的需要知道代码通过gdb崩溃的源代码行。

有什么建议么?

编辑:在受雇俄语的建议后更改

我正在使用“-g”选项编译我的main并将其链接到“现有”目标文件,这些文件显然不是使用“-g”编译的,所以当核心转储时,我看不到这些文件的来源。 所以我继续用“-g”选项重新编译这些文件并重现核心转储。 它现在能够向我显示源代码行。

I'm currently running a file manager program that abruptly crashed with a segmentation fault and dumped a core file. So I used gdb to debug the core file as:

gdb /path/to/executable /path/to/core

The program which I was running is written in C++. When I ran GDB and tried to print the source lines using "list", I got the following error:

(gdb) bt #0 0x0000000000554286 in MyFSEventManager::AddEvent(wxFileSystemWatcherEvent&) () #1 0x00000000005ab2e8 in MyGenericDirCtrl::OnFileWatcherEvent(wxFileSystemWatcherEvent&) () (gdb) f 0 #0 0x0000000000554286 in MyFSEventManager::AddEvent(wxFileSystemWatcherEvent&) () (gdb) l 1 /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gmain.c: No such file or directory.

Why does gdb say this "/build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gmain.c: No such file or directory." I do not hit this issue with some other programs that I've debugged using gdb.

The operating system used is Ubuntu 16.04 running on Oracle virtual box. I think may be the gdb symbols were not loaded. I'm not sure why since I compiled the program using the "-g" option. I really need to know the source lines where the code crashes via gdb.

Any suggestions?

EDIT: changes after suggestions from Employed Russian

I was compiling my main using "-g" option and linking it to "existing" object files which were obviously not compiled using "-g" so when the core dumped, I could not see the source for these files. So I went ahead and recompiled those files with "-g" option and reproduced the core dump. It's able to show me the source lines now.

最满意答案

为什么gdb会这样说“/build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gmain.c:没有这样的文件或目录。”

因为您的系统上确实没有该文件。 但这与您的实际问题无关。

使用的操作系统是Ubuntu 16.04

那是无关紧要的

我想可能是没有加载的gdb符号

GDB 确实加载了glib的调试符号,但没有加载主可执行文件。

因为我使用“-g”选项编译程序,所以我不确定为什么。

有很多方法可以错误地构建程序。 您没有显示编译和链接行,因此我们无法确切地告诉您哪种方式搞砸了。

一些常见的方法:

你的链接行上有一个“stray” -s或-Wl,-s (这会从生成的二进制文件中删除调试信息)。 在编译main.c时有-g ,但在编译定义了MyFSEventManager::AddEvent()的源时没有

PS

(gdb) bt

这不能完全从bt命令输出。 通过删除部分输出,您已经帮助您更难

Why does gdb say this "/build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gmain.c: No such file or directory."

Because you really don't have that file on your system. But this is irrelevant for your actual problem.

The operating system used is Ubuntu 16.04

That is irrelevant.

I think may be the gdb symbols were not loaded

GDB did load debug symbols for glib, but not for your main executable.

I'm not sure why since I compiled the program using the "-g" option.

There are many ways to build program incorrectly. You didn't show your compile and link lines, so we can't tell you exactly which way you screwed up.

Some of the common ways:

You have a "stray" -s or -Wl,-s on your link line (this strips debug info from the resulting binary). You have -g when compiling your main.c, but not when compiling the source in which MyFSEventManager::AddEvent() is defined

P.S.

(gdb) bt

This can't be complete output from bt command. By removing parts of the output, you've made helping you harder.

更多推荐

本文发布于:2023-07-17 04:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1139282.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   文件   目录   列表   gdb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!