[llvm-dev] [DebugInfo][DIBuilder] Good way to pass arguments to createClassType/createMemberType

Vivien Millet via llvm-dev
Fri, 08 Feb 2019 10:49:23 -0000

Thanks all, indeed it seems that the scope is not mandatory for fields and
other class members, the DINodeArray Elements seems to be the rule to
follow.

As a side note, this implementation of DebugInfo based on dynamic MetaData
structures and opaque construction is very hard to understand, read and
debug..
Each time you look at a DIXxx variable in the debugger, you just have
opaque variables even with the natvis..
That would be nice to be able to explore the whole DI hierarchy when
exploring a DINode, for example :
-DICompositeType "class Foo
    - DISubprogram "method0"
    - DISubprogram "method1"
    - DIDerivedType "field0
To at least know if you are doing the right thing.

For example I have another issue with template arguments I want to give to
createClassType.
The parameter type for TemplateArgs is MDNode .. ? What should I do with
that ? How can I understand what I need to give it except by exploring
CGDebugInfo code ? (which does not use it btw)
This is not intuitive.
The documentation is just only repeating what the code already tells,
without giving any hint on how to use the functions.
It's like "try your luck and prey it works as you imagined".
For template arguments I tried giving the class as the scope of a
TemplateTypeParameter, I tried to create a MDTuple with my parameters and
give it to the createClassType, nothing works.
I get out of ideas here.
In Clang it uses a "replaceArrays" somewhere to put template arguments
after a code that does replacements everywhere.
It looks like Clang never uses createClassType but always create
replaceable composite types (I will try this, but that would be
very bad news for the design that it works using replacements while not
working with the straightforward way...)
And the replaceArrays takes a TemplateParameterArray, why not a MDNode like
createClassType ? (or the other way)

I'm sorry If I'm a bit critical here, but it is very hard to work by
"hoping it is what i should have done"...

Anyway, If someone can help me with this template parameter thing it would
be very appreciated :))
Thank you !

Le jeu. 7 févr. 2019 à 17:43, <paul.robinson at sony.com> a écrit :

> Commentary in CGDebugInfo::CreateTypeDefinition says it first creates a
> forward declaration for the record, then adds the members to it using the
> forward declaration as the scope; then it does some sort of fixup. It looks
> like the fixup part is MDNode::replaceWithPermanent which is admittedly not
> a particularly smooth interface.
>
> Adrian or David might be able to comment on that part.
>
> --paulr
>
>
>
> *From:* llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] *On Behalf Of
*Adrian
> Prantl via llvm-dev
> *Sent:* Wednesday, February 06, 2019 1:26 PM
> *To:* David Blaikie
> *Cc:* Vivien Millet; llvm-dev
> *Subject:* Re: [llvm-dev] [DebugInfo][DIBuilder] Good way to pass
> arguments to createClassType/createMemberType
>
>
>
> At least for generating DWARF the scope of of a composite type member
> should be irrelevant since it will always be nested inside its parent.
>
>
>
> -- adrian
>
>
>
> On Feb 6, 2019, at 10:24 AM, David Blaikie <dblaikie at gmail.com>
wrote:
>
>
>
> A good rough rule of thumb here is "what would/does Clang do?"
& it looks
> (to me, on a very cursory glance) like Clang mostly passes the unit's
> DIFile as the scope parameter for a member - so perhaps it's just
ignored?
> not sure.
>
> On Tue, Feb 5, 2019 at 1:38 PM Vivien Millet via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
> Hi,
>
> I'm trying to use DIBuilder to build my debug info and export it into a
> PDB, but I don't understand the way some DIBuilder method work.
> My question might have a straightforward answer but I don't see it ...
> (and I can't find any example code using these methods anywhere).
> Indeed createClassType takes an "Elements" argument, and
createMemberType
> takes a "Scope" argument. Like the "who's first, egg or
hen", I don't know
> If I need to create my members first using le compilation unit as the
> scope, put them in an array and give them to createClassType Elements
> parameter. Or forget the Elements parameter, call createClassType first
> then give it as "Scope" of createMemberType..
> Thanks !
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20190208/c9b3b2f8/attachment.html>