[cfe-dev] [LLVMdev] Dumping memory layout with clang

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Jul 1 10:59:02 PDT 2014


+cfe-dev, bcc: llvm-dev

> On 2014-Jun-30, at 23:17, Matthias Goldhoorn <matthias.goldhoorn at uni-bremen.de> wrote:
> 
> 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.

This looks related to the clang API, so it probably belongs on cfe-dev
[1], although cfe-users [2] is another possibility.

[1]: http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
[2]: http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users

> 
> 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
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the cfe-dev mailing list