0

Previously in LLVM version 4 and lower, it was possible to access the debug information for program constructs via some API calls. For example, to get the DWARF info of a struct I could write:

MDNode* structNode;
DIType structType(structNode);
assert(strType.getTag() == dwarf::DW_TAG_structure_type);

With the current version of LLVM, these functions are gutted out. Do you know the alternative approach for accessing the debug info such as the example above?

Arya Mz
  • 581
  • 3
  • 7
  • 20
  • Still you can dump using `dwarfdump -a lib.a/binary` command. to access from program check the source code of this command. I'm using `Apple LLVM version 9.1.0` – ntshetty Dec 20 '18 at 02:39
  • You can still use libdwarf. There is libdwarf++ or some wrapper library if you prefer using C++ – jclin Jan 05 '19 at 16:58

1 Answers1

0

I think it should work pretty much the same way, just use llvm::dyn_cast (as is the currently suggested way of working with LLVM in general):

llvm::MDNode* md;

if (const auto di = llvm::dyn_cast<llvm::DINode>(md)) {
  assert(di->getTag() == llvm::dwarf::DW_TAG_structure_type);
}
Cherusker
  • 1,576
  • 1
  • 9
  • 18
  • If that doesn't work please specify where you get your `MDNode` from (which call to `getMetadata` exactly) and I'll gladly help you find your path to `DIType`. – Cherusker Jan 20 '19 at 19:19