使用调试选项时,dwarfdump为空(dwarfdump is empty when using debug options)

系统教程 行业动态 更新时间:2024-06-14 16:52:52
使用调试选项时,dwarfdump为空(dwarfdump is empty when using debug options)

我试图使用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.

更多推荐

本文发布于:2023-04-05 12:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/21f0779422a6ecceb4c6069f3d8194a3.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:为空   选项   dwarfdump   options   empty

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!