我试图使用dwarfdump从C ++文件中获取DWARF信息。 C ++文件非常简单 -
int foo();我通过g++ -g -c test.cpp编译它。 然后我做了dwarfdump test.o ,但出于某种原因,我得到了
---------------------------------------------------------------------- File: test.o (x86_64) ---------------------------------------------------------------------- .debug_info contents: < EMPTY >为什么是这样? 我怎样才能得到我的调试矮人信息?
Im trying to get DWARF info from a C++ file using dwarfdump. The C++ file is very simple -
int foo();I compile it by doing g++ -g -c test.cpp. I then do dwarfdump test.o, but for some reason I get
---------------------------------------------------------------------- File: test.o (x86_64) ---------------------------------------------------------------------- .debug_info contents: < EMPTY >Why is this? And how can I get my debug dwarf info?
最满意答案
我弄清楚出了什么问题。 没有生成调试信息。 这是因为优化器实现了int foo(); 永远不会被调用,也没有声明,因此不需要调试信息。 将功能更改为
int foo(){ int x=5; }足以生成调试信息。
I figured out what was wrong. No debug information was generated. This is because the optimizer realizes that int foo(); is never called and has no declaration, and as such does not need debug info. Changing the function to
int foo(){ int x=5; }is enough to generate debug info.
更多推荐
发布评论