访问gdb在C++中看到的程序信息

ano*_*non 6 c++ gdb

我有一个用C++编写的程序,在Linux上,用-g编译.

当我在gdb下运行它时,我可以

1) set breakpoints
2) at those breakpoints, print out variables
3) see the stackframe
4) given a variable that's a structure, print out parts of the structure (i.e. how ddd displays information).
Run Code Online (Sandbox Code Playgroud)

现在,鉴于我的程序是用"-g"编译的 - 无论如何,我可以在我的程序中访问这个功能吗?

即我的程序是用"-g"编译的,有一些

std::vector<string> getStackFrame();
Run Code Online (Sandbox Code Playgroud)

我可以调用函数来获取当前执行点的堆栈帧吗?

给定指向对象的指针及其类型......我能做到吗?

std :: vector getClassMember(class_name);

我意识到默认答案是"不,C++不支持这种内省级别" - 但是,回想一下我在linux上,我的程序是用"-g"编译的,而gdb可以做到这一点,所以显然是信息在那儿.问题是:是否有一些用于访问它的API?

编辑:PS Naysers,我很想看到关闭这个问题的理由.

Ron*_*del 3

调试格式称为 dwarf。这应该会提示您在哪里进一步搜索。

读取ELF文件DWARF调试信息的库