[LLVMdev] How to access Debug Type Information (from Cbackend)
Devang Patel
devang.patel at gmail.com
Fri Aug 6 11:15:40 PDT 2010
Hi Alexander,
On Fri, Aug 6, 2010 at 3:59 AM, Alexander Herz <alexander.herz at mytum.de> wrote:
> Hi,
>
> I'm trying to recover the inheritance relations for a class type (so a
> list of base classes) from a llvm ir file generated via compiling some
> cpp file using clang.
>
> I have access to the TypeSymbolTable and have found the class type I
> want to know the base classes for in the table.
> How do I go about extracting this (debug) information?
>
> I'm stuck here:
>
> if(StructType* pST=dyn_cast<StructType*>(I)) //check it's a struct
> (or class)
> {
> LLVMContext c;
> pST->getMetadataTy(c); //get the context
>
I am not sure what this does.
> //how do I get the debug info
> //how do I enumerate the base classes??
> //MDNode *N=c.getMDKindID("dbg");
getMDKindID() and related APIs are related to instruction location.
> I spend some time looking at the doxygen docu etc but didn't find a
> useful hint.
There is not any direct way to go from LLVM Type to corresponding
debug info MDNode for the type in LLVM IR.
Use DebugInfoFinder from DebugInfo.h to collect all debug info in a
module and then iterator over types to find the one you want based on
name. Once you have a MDNode for the given type you can use one of the
DIDescriptor wrapper (from DebugInfo.h) to access relevant fields.
-
Devang
More information about the llvm-dev
mailing list