我交叉编译了使用boost :: asio库的应用程序,并在我的目标系统上对其进行了测试。它正常工作。但是,当我尝试调试我用gdb的应用程序,我得到了GDB的控制台此消息:仅在GDB调试期间出现分段错误
Program received signal SIGSEGV, Segmentation fault.
_dl_debug_initialize (ldbase=4294967292, ns=1996288212) at dl-debug.c:55
55 if (r->r_map == NULL || ldbase != 0)
结果是对远程和本地调试一样,和其他几个Boost库(但不是全部) 。在搜索到任何信息后,我发现这个文档中存在类似的问题(p.63):http://support.garz-fricke.com/products/Santaro/Linux-Yocto/Releases/Yocto-jethro-5.1-r6859-0/GUF-Yocto-jethro-5.1-r6859-0-IMX6GUF-Manual.pdf 正如文档中所说,问题可能是由“隐式实现的C++方法中的静态实例”导致的,并且与glibc 。所以,我想通过这种方式与代码重现此错误:
#include <iostream>
using namespace std;
class AClass
{
public:
void foo()
{
static int NmbOfInvokes = 0;
NmbOfInvokes++;
cout << NmbOfInvokes << endl;
}
};
int main(void)
{
cout << "Hello World" << endl;
AClass anInstance;
anInstance.foo();
anInstance.foo();
return 0;
}
这个程序工作正常,但在调试失败,出现相同的错误SIGSEGV。
要修复它足以改写类ACLASS这样:
class AClass
{
public:
void foo();
};
void AClass::foo()
{
static int NmbOfInvokes = 0;
NmbOfInvokes++;
cout << NmbOfInvokes << endl;
}
的编译标志:
arm-poky-linux-gnueabi-g++ -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -DHAVE_CONFIG_H -I. -I.. --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -g -O0 --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -MT SegFault_Reproduce.o -MD -MP -MF .deps/SegFault_Reproduce.Tpo -c -o SegFault_Reproduce.o SegFault_Reproduce.cpp mv -f .deps/SegFault_Reproduce.Tpo .deps/SegFault_Reproduce.Po
../arm-poky-linux-gnueabi-libtool --tag=CXX --mode=link arm-poky-linux-gnueabi-g++ -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -g -O0 --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -o SegFault_Reproduce SegFault_Reproduce.o
arm-poky-linux-gnueabi-libtool: link: arm-poky-linux-gnueabi-g++ -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -g -O0 --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -o SegFault_Reproduce SegFault_Reproduce.o
我想,在某些Boost库中使用类似的静态instanciation,因为症状完全一样。
如何才能接收调试应用程序的可能性?
我使用的软件包版本:yocto 2.0.1,gcc 5.2.0,gdb 7.9.1,boost 1.58。
@Employed_Russian,谢谢你的回复! 'set disable-randomization off'没有帮助我,所以我会尝试更新版本的GDB并报告结果。 –
@Employed_Russian,你是非常正确的!在将GDB更新到7.11.1后,我的问题消失了。非常感谢! –