[cfe-dev] Inheritance Information in Debug Information

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Fri Feb 24 09:22:38 PST 2017


On Fri, Feb 24, 2017 at 9:00 AM Jon Eyolfson <jon at eyl.io> wrote:

> Great, thanks a lot for the reply! That seems to do the trick for now.
> It's a
> shame about -gfull though, is there just really no use for it?
>

Not so far - debug info's pretty big as it is (even without
-fstandalone-debug, let alone what it might be with -gfull). I don't think
there'd necessarily be a problem with adding the option for users who
really want it - I don't think such a change would be terribly intrusive,
but I'm not sure.


> I'm using this information to create a class heirarchy for an LLVM static
> analysis. I need to use LLVM for the static analysis part but it seems
> like all
> of the class heirarchy information from clang is stripped away by then. So
> I'm
> using debugging information to re-create the class heirarchy.
>

Fair enough - I know people have talked about doing analysis at the IR
level - but not sure how much success has been had there, owing to the sort
of things you're running into in terms of loss of source fidelity/details.

- Dave


>
> Thanks!
>
> On Fri, Feb 24, 2017 at 04:15:19PM +0000, David Blaikie wrote:
> > Note that the TwoVirtual, NoSubOrSuper, and OneSuper types are all
> emitted
> > as declarations - so no inheritance information is provided in that case
> > (nor any member variables/functions, byte size, etc). This is a debug
> > information size optimization (GCC does a similar one) based on the
> > assumption that the whole program will be built with debug info, and in
> > that case some other file (the file with the 'key function' for each
> type)
> > so it doesn't need to be duplicated here.
> >
> > If you want to disable that optimization, you can pass -fstandalone-debug
> > (this tells the compiler not to assume that any other part of the program
> > is built with debug info) - but it increases the size of the debug info
> > quite a bit.
> >
> > (note that -femit-all-decls doesn't apply to debug info (ie: an unused
> type
> > will still not be emitted into the metadata/DWARF) GCC's -gfull would be
> > the right tool for this but it's not implemented in LLVM/Clang)
> >
> > What are you trying to do with this information?
> >
> > On Thu, Feb 23, 2017 at 3:52 PM Jon Eyolfson via cfe-dev <
> > cfe-dev at lists.llvm.org> wrote:
> >
> > > Hello, I'm trying to understand why I'm not getting all the inheritance
> > > information for the following example:
> > >
> > >     class TwoVirtual {
> > >     public:
> > >       virtual void foo();
> > >       virtual void bar() const;
> > >     };
> > >
> > >     class TwoImpl : public TwoVirtual {
> > >       TwoImpl() {}
> > >     public:
> > >       virtual void foo() {}
> > >       virtual void bar() const {}
> > >     };
> > >
> > >     class NoSubOrSuper {
> > >       TwoImpl t;
> > >       void baz() {}
> > >     };
> > >
> > >     class OneSuper : public TwoImpl {
> > >       void baz() {}
> > >     };
> > >
> > > I'm generating llvm code with the following command:
> > >
> > >     clang++ -std=c++14 -g -O1 -Xclang -disable-llvm-optzns -emit-llvm
> > >             -femit-all-decls -S -c TestFile.cpp -o TestFile.ll
> > >
> > > I'm using -O1 because I need TBAA information present.
> > >
> > > What I get is only one DIDerivedType with the DW_TAG_inheritance tag.
> > > This connects TwoImpl to TwoVirtual. However there isnt an inheritance
> > > tag between OneSuper and TwoImpl. Is there a reason for this? I'm
> trying
> > > to determine in the llvm code that NoSubOrSuper and OneSuper are
> different
> > > (on has an inheritance relation and the other doesn't). Thanks!
> > > _______________________________________________
> > > cfe-dev mailing list
> > > cfe-dev at lists.llvm.org
> > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> > >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170224/6923acf7/attachment.html>


More information about the cfe-dev mailing list