访问gdb在C+中看到的程序信息+; 我有一个用C++编写的程序,用Linux编写,用-g/

访问gdb在C+中看到的程序信息+; 我有一个用C++编写的程序,用Linux编写,用-g/,c++,gdb,C++,Gdb,当我在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). 现在,考虑到我的程序是用“-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).
现在,考虑到我的程序是用“-g”编译的——我的程序本身是否有这种能力

也就是说,如果我的程序是用“-g”编译的,是否有一些

std::vector<string> getStackFrame();
std::vector getStackFrame();
我可以调用函数来获取当前执行点的当前堆栈帧吗

给定一个指向对象及其类型的指针。。。我能做什么

std::vector getClassMember(类名称)

?

我意识到默认的答案是“不,C++不支持那种内省”——但是,回忆一下我在Linux上的情况,我的程序是用“-g”编译的,GDB可以做,所以很明显有信息。问题是:是否有访问它的API


编辑:PS Naysers,我想看看结束这个问题的原因。

我记得使用libbfd从对象文件获取函数名。它是一个用于读取对象格式的库,也许您还可以使用它读取其他调试信息。(老实说我不知道)


调试格式称为dwarf。这将提示您在何处进一步搜索


这一直是libcwd的目标,但由于社区对此不感兴趣,我只能从DWARF的.debug\u line部分读取源文件行号信息。

为什么有人想结束一个完全有效的问题?