【问题标题】:gdb corrupt stack issue, not function and line number displayedgdb 损坏的堆栈问题,不显示函数和行号
【发布时间】:2016-12-24 23:56:27
【问题描述】:

我知道有一个类似的 question。但我认为这个问题是不同的。

我正在使用 gdb-cross-aarch64 分析在 arm arch64 设备上生成的转储核心文件。

我的命令行是这样的:

gdb-cross-aarch64 /path_to/gst-launch-1.0 /path_to/core.2135

gst-launch-1.0 依赖于共享库libOmxCore.so

这是gdb的输出:

GNU gdb (GDB) 7.9.1
Copyright (C) 2015 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 "--host=x86_64-linux --target=aarch64-poky-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://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"...
Reading symbols from ./work/aarch64-poky-linux/gstreamer1.0/1.4.5-r0/image/usr/bin/gst-launch-1.0...done.
[New LWP 2135]
[New LWP 2137]
[New LWP 2141]
[New LWP 2139]
[New LWP 2138]
[New LWP 2136]
[New LWP 2143]
[New LWP 2142]
[New LWP 2140]

warning: Could not load shared library symbols for 46 libraries, e.g. linux-vdso.so.1.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `gst-launch-1.0 filesrc location=samplevideo.mp4 ! decodebin ! fakesink'.
Program terminated with signal SIGABRT, Aborted.
#0  0x0000007fa1d42cb0 in ?? ()
(gdb) set sysroot /Disk_1/Alan_s_Work/path_to/image/
Reading symbols from /Disk_1/Alan_s_Work/path_to/libOmxCore.so...done.
(gdb) bt
#0  0x0000007fa1d42cb0 in ?? ()
#1  0x0000007fa1d46120 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) 

如上图,我在gdb中设置了sysrootlibOmxCore.sogst-launch-1.0中的符号被gdb读取。

但我仍然无法通过gdb 看到有效的堆栈回溯。

我很确定signal SIGABRT 是由libOmxCore.so 引起的。

我在这里做错了什么?或者我还应该做什么?

谢谢

【问题讨论】:

    标签: c debugging gdb


    【解决方案1】:

    这些是要查找的棘手错误。调试器通过向上遍历您提供的核心转储的堆栈帧来获取它通常显示的回溯信息。

    如果堆栈损坏,显然没有任何有用的信息可用于创建回溯或反向论证:如果您看不到正确的回溯,则您的代码损坏了堆栈。调试器无法为您提供太多事后分析帮助。

    损坏的堆栈,尤其是在使用外部库时,可能有很多原因。有些是:

    1. 移交库希望在堆栈上的堆上看到的内存
    2. 将指针移交给不再有效的堆栈变量(如返回指向局部变量的指针)
    3. 错误地告诉图书馆你给它的变量或缓冲区大小。
    4. 传递标量而不是指针
    5. 假设库会分配缓冲区并返回指针,但库会假设其他情况。
    6. ...以及大量其他可能的原因...

    手动检查您的代码,将您需要分配的内存区域与库的要求对齐。找出该库使用的内存归谁所有(是您的代码还是分配它的库)并仔细检查它是否足够大以满足要求。

    发送 SIGABRT 的原因有很多,您可能想更深入地了解一些原因:

    1. 一个线程狂奔(即不是join ed for
    2. 有关堆管理的任何信息,例如 mallocfree 的指针不正确
    3. 以及您的图书馆发现自己处于无法继续执行程序的任何情况。

    【讨论】:

    • 谢谢@tofro。 “我很确定信号 SIGABRT 是在 libOmxCore.so 中引起的”因为我故意在 libOmxCore.so 中的函数中植入了assert(0)。因为我想自学如何使用gdb
    猜你喜欢
    • 2013-01-27
    • 2017-06-07
    • 1970-01-01
    • 1970-01-01
    • 2012-04-06
    • 2021-11-14
    • 1970-01-01
    • 2014-11-13
    相关资源
    最近更新 更多