How do I get debug information from a function?

自闭症网瘾萝莉.ら 提交于 2019-12-04 07:26:01

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.

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.

I think you need to use the DebugInfoFinder. Here is a sample code:

DebugInfoFinder Finder;
Finder.processModule(M);
for (DebugInfoFinder::iterator i = Finder.subprogram_begin(),
                    e = Finder.subprogram_end();
                    i != e; ++i) {
                DISubprogram S(*i);

                if (S.getFunction() == F) {
                    errs() << S.getLineNumber(); << "\n";
                }
            }

where F is the function you are looking for.

you can use getSubprogram() as describled in doxygen: Function class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!