在 Mac OSX 中读取 DWARF 文件
任何人都可以帮我编写一个可以读取 DWARF 文件并提供文件名、行号和函数名称详细信息的程序。
Can anybody help me writing a program which can read DWARF files and gives me the file name, line number and function name details.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
DWARF-2 和 DWARF-2 的规范 DWARF-3 在这里:
http://dwarfstd.org/dwarf-2.0.0.pdf< /a>
http://dwarfstd.org/Dwarf3.pdf
有一个不错的阅读 DWARF 的库文件在这里:
http://reality.sgiweb.org/davea/dwarf.html
您可以获取并使用该库来读取 DWARF 文件(它读取 DWARF-2 和 DWARF-3),或者您可以查看源代码来弄清楚如何编写自己的一组库/函数来执行以下操作工作。
The specification for DWARF-2 & DWARF-3 is here:
http://dwarfstd.org/dwarf-2.0.0.pdf
http://dwarfstd.org/Dwarf3.pdf
There is a decent library for reading DWARF files here:
http://reality.sgiweb.org/davea/dwarf.html
You can either get and use that library to read your DWARF files (it reads DWARF-2 and DWARF-3) or you can take a look at the source code to puzzle out how to write your own set of libraries/functions to do the job.
你可以看看 binutils 中的 avr-readelf 。 binutils/dwarf.c 中的 display_debug_lines() 函数负责解码 DWARF 行号信息。
另外,正如上面所建议的,您可以使用 libdwarf。 这很好地隐藏了 DWARF 的低级复杂性,让您专注于获取数据。
使用 elfdescriptor 设置 libdwarf 并获取 Dwarf_Debug 结构后,您可以执行以下操作:
You could have a look at avr-readelf in binutils. The display_debug_lines() function in binutils/dwarf.c does the job of decoding the DWARF linenumber information.
Also, as suggested above, you could use libdwarf. This does a nice job of hiding the low-level complexities of DWARF and lets you focus on getting the data out.
After setting up libdwarf with an elfdescriptor and getting a Dwarf_Debug struct, you can do the following: