如何使用 gdb-multiarch 调试 Yocto 生成的应用程序核心转储?

问题描述 投票:0回答:1

我有一个使用 Yocto 构建系统为 ARM 编译的应用程序,该应用程序崩溃并生成核心转储。

在目标上,我已经安装了 GDB 和我的应用程序 dbg ipk,我可以在 GDB 中加载核心转储文件并毫无问题地查看堆栈跟踪。

我希望能够在没有目标的情况下分析此核心转储。我尝试过使用 gdb-multiarch 但看不到堆栈跟踪的内容。

我可以从 dbg ipk 访问已安装的二进制文件和调试符号。 当我加载二进制 gdb-multiarch 日志时,它已从调试符号文件加载了符号,但我无法在堆栈跟踪中获取有效符号。

我不需要所有共享库的堆栈符号,仅需要来自我的应用程序。

有趣的是,如果我运行 gdb list,我可以看到 main.cpp 文件中的代码,但在崩溃时看不到代码。

# gdb-multiarch
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".

(gdb) file my_application
Reading symbols from my_application...
Reading symbols from .debug/my_application...

(gdb) core core-dump-file
warning: Can't open file /lib/libc-2.21.so during file-backed mapping note processing
warning: Can't open file /lib/libgcc_s.so.1 during file-backed mapping note processing
warning: Can't open file /lib/libm-2.21.so during file-backed mapping note processing
warning: Can't open file /lib/libstdc++.so.6.0.21 during file-backed mapping note processing
warning: Can't open file /usr/lib/libboost_system.so.1.60.0 during file-backed mapping note processing
warning: Can't open file /usr/lib/libboost_filesystem.so.1.60.0 during file-backed mapping note processing
warning: Can't open file /usr/lib/libcrypto.so.1.0.0 during file-backed mapping note processing
warning: Can't open file /usr/lib/libssl.so.1.0.0 during file-backed mapping note processing
warning: Can't open file /lib/librt-2.21.so during file-backed mapping note processing
warning: Can't open file /usr/lib/libjsoncpp.so.1.8.4 during file-backed mapping note processing
warning: Can't open file /lib/libpthread-2.21.so during file-backed mapping note processing
warning: Can't open file /lib/libatomic.so.1.1.0 during file-backed mapping note processing
warning: Can't open file /lib/libdl-2.21.so during file-backed mapping note processing
warning: Can't open file /lib/ld-2.21.so during file-backed mapping note processing
[New LWP 9334]
[New LWP 9344]
[New LWP 9346]
[New LWP 9347]
[New LWP 9348]
warning: Could not load shared library symbols for 14 libraries, e.g. /lib/libdl.so.2.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `/usr/sbin/my_application'.
Program terminated with signal SIGABRT, Aborted.
#0  0xb6aa0996 in ?? ()
[Current thread is 1 (LWP 9334)]

(gdb) bt
#0  0xb6aa0996 in ?? ()
#1  0xb6aae448 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

(gdb) list
warning: Source file is more recent than executable.
13      #include ....
14      ......
..... shows code from the main.cpp in my application
15      ......
(gdb)

有什么方法可以使用 gdb-multiarch 查看堆栈跟踪的内容吗?

c++ arm gdb yocto
1个回答
0
投票

您应该尝试设置一个 sysroot,以便 GDB 可以找到它尝试加载的所有库。

创建一个类似

/tmp/sysroot
的目录,然后从目标复制所有这些文件,这样你最终会得到:

/tmp/sysroot/lib/libc-2.21.so
/tmp/sysroot/lib/libgcc_s.so.1
... etc ...

然后在GDB中:

(gdb) set sysroot /tmp/sysroot
(gdb) file my_application
(gdb) core core-dump-file

如果幸运的话,GDB 现在应该从 sysroot 加载所有库,并且希望回溯符号将位于这些库之一中。

© www.soinside.com 2019 - 2024. All rights reserved.