有人可以帮我理解这个: -
(gdb) info frame
Stack level 0, frame at 0xb75f7390:
eip = 0x804877f in base::func() (testing.cpp:16); saved eip 0x804869a
called by frame at 0xb75f73b0
source language c++.
Arglist at 0xb75f7388, args: this=0x0
Locals at 0xb75f7388, Previous frame's sp is 0xb75f7390
Saved registers:
ebp at 0xb75f7388, eip at 0xb75f738c
Run Code Online (Sandbox Code Playgroud)
什么是"ebp,eip Locals at和Previous Frame's sp"是什么意思?请解释
正如标题所提到的,我的问题很明显,我详细描述了这个场景.在文件singleton.h中有一个名为singleton的类,由singleton模式实现,如下所示:
/*
* singleton.h
*
* Created on: 2011-12-24
* Author: bourneli
*/
#ifndef SINGLETON_H_
#define SINGLETON_H_
class singleton
{
private:
singleton() {num = -1;}
static singleton* pInstance;
public:
static singleton& instance()
{
if (NULL == pInstance)
{
pInstance = new singleton();
}
return *pInstance;
}
public:
int num;
};
singleton* singleton::pInstance = NULL;
#endif /* SINGLETON_H_ */
Run Code Online (Sandbox Code Playgroud)
然后,有一个名为hello.cpp的插件如下:
#include <iostream>
#include "singleton.h"
extern "C" void hello() {
std::cout << "singleton.num in hello.so : " << singleton::instance().num << std::endl;
++singleton::instance().num; …
Run Code Online (Sandbox Code Playgroud) 我一生中见过许多核心垃圾场,但这一次让我难过.
语境:
以下是崩溃的详细信息:
Program terminated with signal 11, Segmentation fault.
#0 0x00000000017bd9fd in Foo()
(gdb) x/i $pc
=> 0x17bd9fd <_Z3Foov+349>: rex.RB orb $0x8d,(%r15)
(gdb) x/6i $pc-12
0x17bd9f1 <_Z3Foov+337>: mov (%rbx),%eax
0x17bd9f3 <_Z3Foov+339>: mov %rbx,%rdi
0x17bd9f6 <_Z3Foov+342>: callq *0x70(%rax)
0x17bd9f9 <_Z3Foov+345>: cmp %eax,%r12d
0x17bd9fc <_Z3Foov+348>: mov %eax,-0x80(%rbp)
0x17bd9ff <_Z3Foov+351>: jge 0x17bd97e <_Z3Foov+222>
Run Code Online (Sandbox Code Playgroud)
您会注意到崩溃发生在指令中间0x17bd9fc
,即从调用返回0x17bd9f6
到虚函数之后.
当我检查虚拟表时,我发现它没有以任何方式损坏:
(gdb) x/a $rbx
0x2ab094951f80: 0x3f8c550 <_ZTI4Foo1+16>
(gdb) x/a 0x3f8c550+0x70
0x3f8c5c0 <_ZTI4Foo1+128>: 0x2d3d7b0 …
Run Code Online (Sandbox Code Playgroud) 所以我在GDB中启动我的c ++应用程序,当它退出时,我基本上得到:
[Thread 0x7fff76e07700 (LWP 6170) exited]
[Thread 0x7fff76f08700 (LWP 6169) exited]
[Thread 0x7fff77009700 (LWP 6168) exited]
...
Program terminated with signal SIGKILL, Killed. The program no longer exists.
(gdb)
Run Code Online (Sandbox Code Playgroud)
我真的不知道为什么会发生这种情况,为什么我不能做回溯看它是如何退出的呢?有人有主意吗?它应该永远不会结束:(
谢谢!
我的问题听起来很具体,但我怀疑它仍然可能是C++调试问题.
我正在使用omnet ++来模拟无线网络.omnet ++本身就是一个c ++程序.
当我运行我的程序时遇到了一个奇怪的现象(在Ubuntu 12.04中使用omnet ++ 4.2.2修改了inet框架):程序退出时退出代码139(人们说这意味着内存碎片)当触摸代码的某一部分时,当我尝试调试,gdb没有报告模拟退出的"有问题"代码有什么问题,实际上,调试通过这部分代码并输出预期结果.
gdb版本信息:GNU gdb(Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1)7.4-2012.04
有谁可以告诉我为什么运行失败但调试没有?
非常感谢!
我刚刚尝试在BackTrack Linux上使用gdb ,我必须说它很棒.我想知道回溯中的gdb如何配置为以这种方式运行.
当我设置断点时,将打印所有寄存器值,堆栈的一部分,数据部分的一部分以及要执行的下一个10-15指令.当我step
或next
通过指示时也会发生同样的情况.
我觉得这很神奇,也很想在我的Ubuntu机器上拥有它; 我怎么能这样做呢?
我试图在 Ubuntu 22.04 LTS 上运行 flutter 应用程序。一切都工作正常。但是,今天运行应用程序时出现了这个问题。Flutter SDK 无法构建应用程序并抛出以下错误。
/snap/flutter/130/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/../../../../lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so)
Failed to load module: /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so
Run Code Online (Sandbox Code Playgroud)
在互联网上搜索后,我意识到我需要 libc 的向后版本。如果我做file /snap/flutter/130/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/../../../../lib/x86_64-linux-gnu/libc.so.6
。
我得到结果了/snap/flutter/130/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/../../../../lib/x86_64-linux-gnu/libc.so.6: symbolic link to libc-2.31.so
。
可能我需要安装libc-2.31。但是,怎么样?我没有找到任何解决方案。Flutter 和 Ubuntu 均已升级到最新版本。
我最近需要在汇编级调试程序.我没有很多汇编程序经验,所以我想我会编写一些简单的C程序并单步执行它们,以便在我开始调试其他人的代码之前感受一下这种语言.但是,我真的不知道gcc用这两行代码(用-ggdb -O0编译):
items[tail] = i;
tail = (tail+1) % MAX_SIZE;
Run Code Online (Sandbox Code Playgroud)
其中MAX_SIZE #defined为5,i是局部变量(存储在0x8(%ebp)中,我猜).根据gdb,这变为:
0x08048394 <queue+17>: mov 0x8049634,%edx
0x0804839a <queue+23>: mov 0x8(%ebp),%eax
0x0804839d <queue+26>: mov %eax,0x804963c(,%edx,4)
0x080483a4 <queue+33>: mov 0x8049634,%eax
0x080483a9 <queue+38>: lea 0x1(%eax),%ecx
0x080483ac <queue+41>: movl $0x66666667,-0xc(%ebp)
0x080483b3 <queue+48>: mov -0xc(%ebp),%eax
0x080483b6 <queue+51>: imul %ecx
0x080483b8 <queue+53>: sar %edx
0x080483ba <queue+55>: mov %ecx,%eax
0x080483bc <queue+57>: sar $0x1f,%eax
0x080483bf <queue+60>: mov %edx,%ebx
0x080483c1 <queue+62>: sub %eax,%ebx
0x080483c3 <queue+64>: mov %ebx,-0x8(%ebp)
0x080483c6 <queue+67>: mov -0x8(%ebp),%eax
0x080483c9 <queue+70>: shl $0x2,%eax
0x080483cc <queue+73>: add -0x8(%ebp),%eax …
Run Code Online (Sandbox Code Playgroud) 有很多关于设计和实现编译器的信息,但我找不到任何关于链接器的信息.
我对这些主题很感兴趣,但我找不到任何关于连接子的信息.有没有人知道有关链接器设计和实现的教程,书籍等?