[LLVMdev] Dumping memory layout with clang

Matthias Goldhoorn matthias.goldhoorn at uni-bremen.de
Mon Jun 30 23:17:42 PDT 2014


Dear dev's,
first sorry for this "user" question here, but i don't found a llvm-user 
Mailinglist. I hope it is okay to ask here.

Hi search for a way to dump the memory layout of a 
class/structure/datatype with clang (x64 primary target).
I have a simple application based on [1].

I also added this function


      bool VisitFieldDecl(FieldDecl *F)
     {
       F->dump();
       std::cerr << F->getQualifiedNameAsString()  << " " << 
F->getBitWidthValue(*Context) << " " << std::endl;
       F->dump() ;
       std::cerr << "-----------------------------------------" << 
std::endl;
       return true;
     }


Unfortunately getBitWidthValue also returns zero for my types.

I need the complete memory-layout recursively for each class and all 
nested types. Including sizes/offsets.

Maybe the AST is the wrong place, and i need a other hook to start, can 
you give me some hints?

   [1]: http://clang.llvm.org/docs/RAVFrontendAction.html

-- 
  Dipl.-Inf. Matthias Goldhoorn
  Space and Underwater Robotic

  Universität Bremen
  FB 3 - Mathematik und Informatik
  AG Robotik
  Robert-Hooke-Straße 5
  28359 Bremen, Germany

  Tel.:     +49 421 178 45-4193
  Zentrale: +49 421 178 45-6550
  Fax:      +49 421 178 45-4150
  E-Mail:   matthias.goldhoorn at uni-bremen.de

  Weitere Informationen: http://www.informatik.uni-bremen.de/robotik

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140701/e84d6d97/attachment.html>


More information about the llvm-dev mailing list