【问题标题】:analysis of core dump frame using gdb使用 gdb 分析核心转储帧
【发布时间】:2016-11-08 11:40:42
【问题描述】:

我正在分析我的应用程序生成的核心转储。从堆栈跟踪中,我可以看到以下几行 #0 0x00779eff in raise () from /lib/tls/libc.so.6

#1  0x0077b705 in abort () from /lib/tls/libc.so.6

#2  0x006554f7 in __cxa_call_unexpected () from /usr/lib/libstdc++.so.5

#3  0x00655544 in std::terminate () from /usr/lib/libstdc++.so.5

#4  0x006556b6 in __cxa_throw () from /usr/lib/libstdc++.so.5

#5  0x006558d2 in operator new () from /usr/lib/libstdc++.so.5


#6  0x006559bf in operator new[] () from /usr/lib/libstdc++.so.5
#7  0x090c15df in Buffer::resize ()

#8  0x090bd230 in Buffer::Buffer ()

Buffer函数定义如下

int
Buffer::resize (
    size_t      size    
    )
{
    …….
}

现在我选择了第 7 帧

    (gdb) f 7
#7  0x090c15df in Buffer::resize ()
(gdb) info frame
Stack level 7, frame at 0xbfff82f0:
 eip = 0x90c15df in Buffer::resize(unsigned int); saved eip 0x90bd230
 called by frame at 0xbfff8310, caller of frame at 0xbfff8280
 Arglist at 0xbfff82e8, args: 
 Locals at 0xbfff82e8, Previous frame's sp is 0xbfff82f0
 Saved registers:
  ebx at 0xbfff82e4, ebp at 0xbfff82e8, esi at 0xbfff8250, edi at 0xbfff8254, eip at 0xbfff82ec

但想检查传递给它的 size 值是多少 我怎么做 ?任何帮助将不胜感激

谢谢 SKP

【问题讨论】:

  • 这在一定程度上取决于您的代码是否使用调试符号编译。由于 resize 函数是从构造函数调用的,所以您不能检查从 this 使用的参数是什么值,还是作为参数给构造函数的大小也是如此?
  • 是的,它是用 -g 选项编译的
  • 您是否尝试调试优化代码?

标签: c++ linux gdb


【解决方案1】:

最简单的方法(因问题改变而调整):

p size

p(print 的缩写)将发出 size 的值。

专业提示:点击Ctrl+x+a 以查看您当前正在执行的代码。 (也可以使用listgdb-command。)

【讨论】:

  • 无法以这种方式打印
  • 你看到了什么?您确保使用 -g 进行编译(即使用 dbg 符号),对吗?
  • 如果我给出 list 它在 > 中显示为 (gdb) list 1
  • @user3160866 为什么你不能那样打印?你无法访问 GDB 中的 print (p) 命令吗?
猜你喜欢
  • 2023-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-22
  • 1970-01-01
相关资源
最近更新 更多