如何从函数中获取调试信息? [英] How do I get debug information from a function?
问题描述
我使用Clang编译了启用了调试信息的函数.对于Instruction
,有一个方便的getDebugLoc()
,但是对于Function
,没有这样的东西.给定一个Function
实例,我如何获取它的调试信息(我猜为DISubProgram
形式)?
I've used Clang to compile a function with debug information enabled. For Instruction
s there's the handy getDebugLoc()
, but there's no such thing for Function
s. Given a Function
instance, how can I get the debug information (I'm guessing in DISubProgram
form) for it?
我已经看过该指南条目,说明了如何表示调试信息 ,并且元数据确实包含指向该函数的链接,但是显然没有链接返回.我是否应该遍历模块中的所有元数据?
I've seen the guide entry explaining how that debug information is represented, and the metadata does contain a link back to the function, but there's apparently no link back. Am I supposed to iterate over all the metadata in the module?
推荐答案
我认为目前没有更简单的方法.过去曾经有一个全局元数据节点收集所有功能元数据条目(llvm.dbg.sp
),但不久前为了支持llvm.dbg.cu
而将其删除,这更紧密地反映了DWARF结构.
I don't think there's currently an easier way. There used to be a global metadata node that collected all function metadata entries (llvm.dbg.sp
) but it was removed a while ago in favor of llvm.dbg.cu
which reflects the DWARF structure more closely.
我想调试元数据的常见用法不需要按功能查找,并且可以删除的所有多余信息,因为节省空间很重要并且IR中的元数据是已经太大了.
I suppose that the common uses of debug metadata don't require by-function lookup, and any extra information that could be removed, was removed, because saving space is important and metadata in IR is already way too big.
这篇关于如何从函数中获取调试信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!