<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 22, 2014 at 3:40 PM, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca" target="_blank">nicholas@mxc.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">Robinson, Paul wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I think it comes down to how the information is planning to be used. A<br>
consumer with the dwarf information today could, in fact, get to the<br>
S<int> type from a user who types S<A> pretty easily right?<br>
<br>
If the typedef actually appears in the DWARF, the consumer could figure<br>
out what the user meant by typing S<A>, yes. In my experiments the<br>
typedef is not always present, which leaves the user up a creek with no<br>
paddle.<br>
<br>
How the debugger presents the types of things is also a consideration,<br>
however. This is more evident with a less trivial example, such as the<br>
vector typedef I described previously. It is clearly a step backward in<br>
the end-user debugging experience if people are used to seeing<br>
<br>
S<int4><br>
<br>
which the debugger has been displaying all along, but suddenly they<br>
start seeing instead<br>
<br>
S<int __attribute__((ext_vector_<u></u>type(4)))><br>
<br>
which is what has started happening. Especially if 'int4' no longer<br>
appears as a typedef at all, this is Just Wrong.<br>
</blockquote>
<br></span>
In clang, ConvertTypeToDiagnosticString deals with vectors specially. The rationale, I think, is to prevent the compiler from showing the internal implementation detail of how float4 and friends are defined. I think that this is the wrong approach and would have preferred a second attribute. Does attribute nodebug on a typedef have any meaning yet? Could we repurpose it to mean that you shouldn't look through this typedef for compiler diagnostics nor debug info? Any any case, our behaviour on diagnostics and debug info should probably match here.<br></blockquote><div><br></div><div><span style="font-family:monospace">One of the issues is that there's only /so/ different we can be from GCC here before types/declarations/definitions won't match up in GDB. I believe GCC has some smarts to tolerate differences like S<0> versus S<0u> or S<'\0'> I think... at least some of those, but I don't know how it'll go with:</span><br style="font-family:monospace"><br style="font-family:monospace"><span style="font-family:monospace">  S<__attribute__((__vector_</span><span style="font-family:monospace">size__(4 * sizeof(int)))) int></span><br style="font-family:monospace"><br style="font-family:monospace"><span style="font-family:monospace">V</span><br style="font-family:monospace"><br style="font-family:monospace"><span style="font-family:monospace">  S<__vector(4) int></span><br style="font-family:monospace"><br style="font-family:monospace"><span style="font-family:monospace">(using a GCC-compatible syntax, vector_size(sizeof(</span><span style="font-family:monospace">int) * 4) rather than the ext_vector_type which isn't supported by GCC)</span><br style="font-family:monospace"><br style="font-family:monospace"><span style="font-family:monospace">Huh... apparently GDB ignores the entire adornment and allows func(S<__vector(4) int>) to be called with a variable of type S<__attribute__((__vector_</span><span style="font-family:monospace">size__(5 * sizeof(int)))) int> even... not sure what to make of any of that.</span><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Nick<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">
Wolfgang did some bisection and traced this change to r205447, and the<br>
intent of that change was centered on default template arguments. This<br>
de-referencing of typedefs appears to have been an *unintended side<br>
effect* of that patch.<br>
<br>
I want my typedef'd template parameters back please…<br>
<br>
--paulr<br>
<br></span>
*From:*Eric Christopher [mailto:<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>]<br>
*Sent:* Thursday, September 18, 2014 10:07 PM<br>
*To:* Robinson, Paul<br>
*Cc:* David Blaikie; <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a>; <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a>;<br>
Frédéric Riss<br>
*Subject:* Re: [lldb-dev] [RFC][PATCH] Keep un-canonicalized template<span class=""><br>
types in the debug information<br>
<br>
On Thu, Sep 18, 2014 at 5:57 PM, Robinson, Paul<br>
<<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.<u></u>sony.com</a><br></span><div><div class="h5">
<mailto:<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@<u></u>playstation.sony.com</a>>> wrote:<br>
<br>
The (limited) feedback I've had from the committee is along these lines.<br>
<br>
    If the program uses the type name "S<A>" for something, the DWARF<br>
    should fully describe the type named "S<A>" because that's the name<br>
    as-in-the-source-program. If you use both S<A> and S<int> in the<br>
    program in different places, then you need to describe both in the<br>
    DWARF. There is sadly no standard way to associate the two as<br>
    aliases. Yes in C++ they are the same; in standard DWARF they are not.<br>
<br>
Yeah, I'm not sure I agree with this. I've seen the thread and I'm not<br>
sure I like the logic.<br>
<br>
    The typedef S<A> => S<int> hack might work [if the debugger can<br>
    tolerate that]. It is obviously not a real typedef. You could mark<br>
    it artificial as an indication that something funny is going on<br>
    (artificial typedefs being highly atypical).<br>
<br>
    The DW_AT_specification hack is just wrong, because neither S<A> nor<br>
    S<int> is completing the other.<br>
<br>
    I need to step back from the typedef hack. I believe our debugger<br>
    throws away the <brackets> on the theory that it can reconstruct<br>
    them from template-parameter children; that is, the <bracket> part<br>
    of the name is redundant. The typedef hack does not provide those<br>
    children, and the <brackets> are not redundant, so this is likely to<br>
    be a problem for us. Feh. I'd forgotten about that detail when I<br>
    started liking the typedef hack. Yes, this means I don't have a<br>
    suggestion, apart from emitting things redundantly as needed to<br>
    preserve as-in-the-source-program.<br>
<br>
    Here's a bizarre data point. Going back to at least 3.2, Clang has<br>
    emitted S<int> instead of S<A>. But with my vector example, it used<br>
    to use the typedef name up through 3.4. That changed in 3.5, where<br>
    the type name 'int4' has entirely disappeared from the DWARF.<br>
    Clearly that's a bug; the type name needs to be in there somewhere.<br>
<br>
    One more thing:<br>
<br>
    it'd be good to figure out how to deal with all possible names for<br>
    the type, even the ones the user hasn't written (eg: typedef int A;<br>
    typedef int B; and make sure that the debugger can handle S<int>,<br>
    S<A> and S<B> in their code, even though the user only wrote one of<br>
    those in the source).<br>
<br>
    The answer to this "how to deal" question is with debugger smarts,<br>
    not more complicated DWARF. DWARF is about the program as-written<br>
    and as-compiled, not about<br>
    anything-the-user-might-<u></u>conceivably-try-to-write-in-<u></u>the-debugger.<br>
    Handling this in DWARF is a combinatorial nightmare, for completely<br>
    speculative purposes. Not gonna happen.<br>
<br>
I think it comes down to how the information is planning to be used. A<br>
consumer with the dwarf information today could, in fact, get to the<br>
S<int> type from a user who types S<A> pretty easily right? Now if you'd<br>
like a way to print out the textual representation of every type as it<br>
was used in the program that's likely to be less possible without some<br>
serious duplication of dwarf. You could use an unnamed type for the base<br>
and then use DW_AT_specification with just a bare DW_AT_name to avoid<br>
some of the unpleasantness of the specification hack, but then you come<br>
to the problem of template arguments etc. It's fairly crazy to consider,<br>
but a user could quite easily write:<br>
<br>
new std::vector<int, allocator>()<br>
<br>
with some allocator that was never used in the program with vector and<br>
expect the code to be generated at run time and the rest of the type to<br>
be found.<br>
<br>
Anyhow, I think the best bet is for the most general type to be left in<br>
the debug information and then the typedefs etc to be their own DIEs.<br>
Unless we have some use that we're not talking about here?<br>
<br>
-eric<br>
<br>
    --paulr<br>
<br></div></div>
    *From:*David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a><br>
    <mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>>]<br>
    *Sent:* Thursday, September 18, 2014 4:03 PM<br>
<br>
<br>
    *To:* Robinson, Paul<br>
    *Cc:* <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a> <mailto:<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.<u></u>edu</a>>;<span class=""><br>
    Greg Clayton; Frédéric Riss; <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br></span>
    <mailto:<a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a>>; <a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a><br>
    <mailto:<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>><br>
    *Subject:* Re: [lldb-dev] [RFC][PATCH] Keep un-canonicalized<span class=""><br>
    template types in the debug information<br>
<br>
    On Thu, Sep 18, 2014 at 2:40 PM, Robinson, Paul<br>
    <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.<u></u>sony.com</a><br></span><div><div class="h5">
    <mailto:<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@<u></u>playstation.sony.com</a>>> wrote:<br>
<br>
    David,<br>
<br>
    Sorry, thought you were protesting the typedef idea as interfering<br>
    with deduplication or type-unit commonality.<br>
<br>
    So to recap, if we have source like this:<br>
<br>
    typedef int A;<br>
<br>
    template<typename T> struct S { T member; };<br>
<br>
    S<A> s_a;<br>
<br>
    then we'll get<br>
<br>
    DW_TAG_typedef<br>
<br>
    DW_AT_name "A"<br>
<br>
    DW_AT_type -> int<br>
<br>
    DW_TAG_structure_type<br>
<br>
    DW_AT_name "S<A>"<br>
<br>
    DW_TAG_member<br>
<br>
    DW_AT_name "member"<br>
<br>
    DW_AT_type -> int // or the typedef for "A" ?<br>
<br>
    DW_TAG_template_type_parameter<br>
<br>
    DW_AT_name "T"<br>
<br>
    DW_AT_type -> (the typedef for "A")<br>
<br>
    Are you suggesting putting the rest of S<int> here too? Or how would<br>
    S<A> refer to S<int> for the rest of the implementation?<br>
<br>
        DW_TAG_variable<br>
<br>
        DW_AT_name "s_a"<br>
<br>
        DW_AT_type -> (the above structure_type)<br>
<br>
    Ah, no - just a typedef of the template:<br>
<br>
    1: DW_TAG_structure_type // the debug info we already produce today<br>
    (S<int>)<br>
    ...<br>
<br>
    2: DW_TAG_typedef<br>
    DW_AT_name "S<A>"<br>
    DW_AT_type (1)<br>
<br>
    And honestly, the variable would still be of type (1).<br>
<br>
    Duplicating the entire type for each way of naming the same type is,<br>
    I'm fairly sure, not going to work for debuggers today. If someone<br>
    wants to propose a way of encoding this that will need new<br>
    code/support from debuggers, etc, then I feel the right venue to<br>
    discuss that is the DWARF committee - because you'll need buy-in<br>
    from producers and consumers. Without having that discussion, I<br>
    believe just providing a typedef of the template specialization is<br>
    probably a benefit to users.<br>
<br>
    If we want to talk about a 'right' representation of this for DWARF<br>
    that would necessitate more substantial changes to both DWARF<br>
    producers and consumers... I think it'll be a bit more involved than<br>
    even what you're proposing. If we're going to deal with that, it'd<br>
    be good to figure out how to deal with all possible names for the<br>
    type, even the ones the user hasn't written (eg: typedef int A;<br>
    typedef int B; and make sure that the debugger can handle S<int>,<br>
    S<A> and S<B> in their code, even though the user only wrote one of<br>
    those in the source).<br>
<br>
        Yes?<br>
<br>
        --paulr<br>
<br></div></div>
        *From:*David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a><br>
        <mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>>]<br>
        *Sent:* Thursday, September 18, 2014 1:09 PM<br>
        *To:* Robinson, Paul<br>
        *Cc:* <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
        <mailto:<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.<u></u>edu</a>>; Greg Clayton; Frédéric Riss;<br>
        <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a> <mailto:<a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a>>;<br>
        <a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a> <mailto:<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>><br>
        *Subject:* Re: [lldb-dev] [RFC][PATCH] Keep un-canonicalized<span class=""><br>
        template types in the debug information<br>
<br>
        On Thu, Sep 18, 2014 at 1:05 PM, David Blaikie<br></span><span class="">
        <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a> <mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>>> wrote:<br>
<br>
        On Thu, Sep 18, 2014 at 1:00 PM, Robinson, Paul<br>
        <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.<u></u>sony.com</a><br></span><span class="">
        <mailto:<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@<u></u>playstation.sony.com</a>>> wrote:<br>
<br>
         >From: David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a><br>
        <mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>>]<br>
         >On Wed, Sep 17, 2014 at 11:54 AM, Robinson, Paul<br>
        <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.<u></u>sony.com</a><br></span><span class="">
        <mailto:<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@<u></u>playstation.sony.com</a>>> wrote:<br>
         >> From: David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a><br></span><span class="">
        <mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>>]<br>
         >> > On Wed, Sep 17, 2014 at 7:45 AM, Robinson, Paul<br>
        <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.<u></u>sony.com</a><br></span><span class="">
        <mailto:<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@<u></u>playstation.sony.com</a>>> wrote:<br>
         >> > > From: David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a><br></span><span class="">
        <mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>>]<br>
         >> > > On Sat, Sep 13, 2014 at 6:54 PM, Robinson, Paul<br>
        <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.<u></u>sony.com</a><br></span><span class="">
        <mailto:<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@<u></u>playstation.sony.com</a>>> wrote:<br>
         >> > > > > > On 09 Sep 2014, at 00:01, <a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a><br></span><div><div class="h5">
        <mailto:<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>> wrote:<br>
         >> > > > > > ><br>
         >> > > > > > > From the debugger's standpoint, the functional<br>
        concern is that if you do<br>
         >> > > > > > something more real, like:<br>
         >> > > > > > ><br>
         >> > > > > > > typedef int A;<br>
         >> > > > > > > template <typename T><br>
         >> > > > > > > struct S<br>
         >> > > > > > > {<br>
         >> > > > > > > T my_t;<br>
         >> > > > > > > };<br>
         >> > > > > > ><br>
         >> > > > > > > I want to make sure that the type of my_t is<br>
        given as "A" not as "int".<br>
         >> > > > > > The reason for that is that it is not uncommon to<br>
        have data formatters<br>
         >> > > > > > that trigger off the typedef name. This happens<br>
        when you use some common<br>
         >> > > > > > underlying type like "int" but the value has some<br>
        special meaning when it<br>
         >> > > > > > is formally an "A", and you want to use the data<br>
        formatters to give it an<br>
         >> > > > > > appropriate presentation. Since the data<br>
        formatters work by matching type<br>
         >> > > > > > name, starting from the most specific on down, it<br>
        is important that the<br>
         >> > > > > > typedef name be preserved.<br>
         >> > > > > > ><br>
         >> > > > > > > However, it would be really odd to see:<br>
         >> > > > > > ><br>
         >> > > > > > > (lldb) expr -T -- my_s<br>
         >> > > > > > > (S<int>) $1 = {<br>
         >> > > > > > > (A) my_t = 5<br>
         >> > > > > > > }<br>
         >> > > > > > ><br>
         >> > > > > > > instead of:<br>
         >> > > > > > ><br>
         >> > > > > > > (lldb) expr -T -- my_s<br>
         >> > > > > > > (S<A>) $1 = {<br>
         >> > > > > > > (A) my_t = 5<br>
         >> > > > > > > }<br>
         >> > > > > > ><br>
         >> > > > > > > so I am in favor of presenting the template<br>
        parameter type with the most<br>
         >> > > > > > specific name it was given in the overall template<br>
        type name.<br>
         >> > > > > ><br>
         >> > > > > > OK, we get this wrong today. I’ll try to look into it.<br>
         >> > > > > ><br>
         >> > > > > > What’s your take on the debug info representation<br>
        for the templated class<br>
         >> > > > > > type? The tentative patch introduces a typedef<br>
        that declares S<A> as a<br>
         >> > > > > > typedef for S<int>. The typedef doesn’t exist in<br>
        the code, thus I find it<br>
         >> > > > > > a bit of a lie to the debugger. I was more in<br>
        favour of something like :<br>
         >> > > > > ><br>
         >> > > > > > DW_TAG_variable<br>
         >> > > > > > DW_AT_type: -> DW_TAG_structure_type<br>
         >> > > > > > DW_AT_name: S<A><br>
         >> > > > > > DW_AT_specification: -> DW_TAG_structure_type<br>
         >> > > > > > DW_AT_name: S<int><br>
         >> > > > > ><br>
         >> > > > > > This way the canonical type is kept in the debug<br>
        information, and the<br>
         >> > > > > > declaration type is a real class type aliasing the<br>
        canonical type. But I’m<br>
         >> > > > > > not sure debuggers can digest this kind of aliasing.<br>
         >> > > > > ><br>
         >> > > > > > Fred<br>
         >> > > > ><br>
         >> > > > > Why introduce the extra typedef? S<A> should have a<br>
        template parameter<br>
         >> > > > > entry pointing to A which points to int. The info<br>
        should all be there<br>
         >> > > > > without any extra stuff. Or if you think something<br>
        is missing, please<br>
         >> > > > > provide a more complete example.<br>
         >> > > > My immediate concern here would be either loss of<br>
        information or bloat<br>
         >> > > > when using that with type units (either bloat because<br>
        each instantiation<br>
         >> > > > with differently spelled (but identical) parameters is<br>
        treated as a separate<br>
         >> > > > type - or loss when the types are considered the same<br>
        and all but one are<br>
         >> > > > dropped at link time)<br>
         >> > > You'll need to unpack that more because I'm not<br>
        following the concern.<br>
         >> > > If the typedefs are spelled differently, don't they<br>
        count as different types?<br>
         >> > > DWARF wants to describe the program as-written, and<br>
        there's no S<int> written<br>
         >> > > in the program.<br>
         >> > ><br>
         >> > > Maybe not in this TU, but possibly in another TU? Or by<br>
        the user.<br>
         >> > ><br>
         >> > > void func(S<int>);<br>
         >> > > ...<br>
         >> > > typedef int A;<br>
         >> > > S<A> s;<br>
         >> > > func(s); // calls the same function<br>
         >> > ><br>
         >> > > The user probably wants to be able to call void func<br>
        with S<int> or S<A><br>
         >> > Sure.<br>
         >> ><br>
         >> > > (and, actually, in theory, with S<B> where B is another<br>
        typedef of int, but<br>
         >> > > that'll /really/ require DWARF consumer support and/or<br>
        new DWARF wording).<br>
         >> ><br>
         >> > Not DWARF wording. DWARF doesn't say when you can and<br>
        can't call something;<br>
         >> > that's a debugger feature and therefore a debugger decision.<br>
         >> ><br>
         >> What I mean is we'd need some new DWARF to help explain<br>
        which types are<br>
         >> equivalent (or the debugger would have to do a lot of<br>
        spelunking to try<br>
         >> to find structurally equivalent types - "S<B>" and "S<A>",<br>
        go look through<br>
         >> their DW_TAG_template_type_params, see if they are typedefs<br>
        to the same<br>
         >> underlying type, etc... )<br>
         >> ><br>
         >> ><br>
         >> > > We can't emit these as completely independent types - it<br>
        would be verbose<br>
         >> > > (every instantiation with different typedefs would be a<br>
        whole separate type<br>
         >> > > in the DWARF, not deduplicated by type units, etc) and wrong<br>
         >> ><br>
         >> > Yes, "typedef int A;" creates a synonym/alias not a new<br>
        type, so S<A> and S<int><br>
         >> > describe the same type from the C++ perspective, so you<br>
        don't want two complete<br>
         >> > descriptions with different names, because that really<br>
        would be describing them<br>
         >> > as separate types. What wrinkles my brow is having S<int><br>
        be the "real"<br>
         >> > description even though it isn't instantiated that way in<br>
        the program. I wonder<br>
         >> > if it should be marked artificial... but if you do<br>
        instantiate S<int> in another<br>
         >> > TU then you don't want that. Huh. It also seems weird to<br>
        have this:<br>
         >> > DW_TAG_typedef<br>
         >> > DW_AT_name "S<A>"<br>
         >> > DW_AT_type -> S<int><br>
         >> > but I seem to be coming around to thinking that's the most<br>
        viable way to have<br>
         >> > a single actual instantiated type, and still have the<br>
        correct names of things<br>
         >*mostly* correct; this still loses "A" as the type of the data<br>
        member.<br>
         ><br>
         >For the DW_TAG_template_type_<u></u>parameter, you mean? No, it wouldn't.<br>
         ><br>
         > (as a side note, if you do actually have a data member (or<br>
        any other mention) of<br>
         >the template parameter type, neither Clang nor GCC really get<br>
        that 'right' -<br>
         >"template<typename T> struct foo { T t; }; foo<int> f;" - in<br>
        both Clang and GCC,<br>
         >the type of the 't' member of foo<int> is a direct reference<br>
        to the "int" DIE, not<br>
         >to the DW_TAG_template_type_parameter for "T" -> int)<br>
<br>
        Huh. And DWARF doesn't say you should point to the<br>
        template_type_parameter...<br>
        I thought it did, but no. Okay, so nothing is lost, but it feels<br>
        desirable<br>
        to me, that uses of the template parameter should cite it in the<br>
        DWARF as well.<br>
        But I guess we can leave that part of the debate for another time.<br>
<br>
         ><br>
         >Crud.<br>
         >But I haven't come up with a way to get that back without<br>
        basically instantiating<br>
         >S<A> and S<int> separately.<br>
         ><br>
         >> ><br>
         >> Yep - it's the only way I can think of giving this<br>
        information in a way that's<br>
         >> likely to work with existing consumers. It would probably be<br>
        harmless to add<br>
         >> DW_AT_artificial to the DW_TAG_typedef, if that's any help<br>
        to any debug info<br>
         >> consumer.<br>
         ><br>
         >Hmmm no, S<A> is not the artificial name;<br>
         ><br>
         >It's not the artificial name, but it is an artificial typedef.<br>
<br>
        If the source only says S<A>, then the entire S<int> description<br>
        is artificial,<br>
        because *that's not what the user wrote*. So both the typedef<br>
        and the class type<br>
        are artificial. Gah. Let's forget artificial here.<br>
<br>
         ><br>
         >some debuggers treat DW_AT_artificial<br>
         >as meaning "don't show this to the user."<br>
         ><br>
         >In some sense that's what I want - we never wrote the typedef<br>
        in the source<br>
         >so I wouldn't want to see it rendered in the "list of<br>
        typedefs" (or even<br>
         >probably in the list of types, maybe).<br>
         ><br>
         >But S<A> is the name we *do* want to<br>
         >show to the user.<br>
         ><br>
         >Maybe. Sometimes. But there could be many such aliases for the<br>
        type. (& many<br>
         >more that were never written in the source code, but are still<br>
        valid in the<br>
         >source language (every other typedef of int, every other way<br>
        to name the int<br>
         >type (decltype, etc)))<br>
<br>
        But you *lose* cases where the typedef is the *same*<br>
        *everywhere*. And in<br>
        many cases that typedef is a valuable thing, not the trivial<br>
        rename we've<br>
        been bandying about. This is a more real example:<br>
<br>
        typedef int int4 __attribute__((ext_vector_<u></u>type(4)));<br>
        template<typename T> struct TypeTraits {};<br>
        template<><br>
        struct TypeTraits<int4> {<br>
        static unsigned MysteryNumber;<br>
        };<br>
        unsigned TypeTraits<int4>::<u></u>MysteryNumber = 3U;<br>
<br>
        Displaying "TypeTraits<int __attribute__((ext_vector_<u></u>type(4)))>"<br>
        is much<br>
        worse than "TypeTraits<int4>" (and not just because it's shorter).<br>
        More to the point, having the debugger *complain* when the user says<br>
        something like "ptype TypeTraits<int4>" is a problem.<br>
<br>
        Reducing debug-info size is a worthy goal, but don't degrade the<br>
        debugging<br>
        experience to get there.<br>
<br>
        I'm not sure which part of what I've said seemed like a<br>
        suggestion to degrade the debugging experience to minimize debug<br>
        info size (the proposition that we should use a typedef or other<br>
        alias on top of the canonical type? It wouldn't cause "ptype<br>
        TypeTraits<int4>" to complain - indeed for GDB ptyping a typedef<br>
        gives /exactly/ the same output as if you ptype the underlying<br>
        type - it doesn't even mention that there's a typedef involved:<br>
<br>
        typedef fooA foo<int>;<br>
<br>
        (keyboard shortcuts are hard - accidentally sent before I finished)<br>
<br>
        (gdb) ptype fooA<br>
<br>
        type = struct foo<int> [with T = int] {<br>
<br>
        <no data fields><br>
<br>
        }<br>
<br>
        But in any case, I think what I'm saying boils down to:<br>
<br>
        Short of changing debug info consumers, I think the only thing<br>
        we can do is DW_TAG_typedef. That'll work for existing consumers.<br>
<br>
        Anything else will need possibly new DWARF wording, or at least<br>
        an agreement between a variety of debug info consumers and<br>
        producers that some new cliche/use of existing DWARF be used to<br>
        describe these situations.<br>
<br>
        I could be wrong - if someone wants to try prototyping the<br>
        DW_TAG_structure_type proposal Fred had and see if existing<br>
        debuggers work with that, sure.<br>
<br>
        I'm not opposed to someone coming up with a standardizable more<br>
        descriptive form than DW_TAG_typedef, but that conversation<br>
        probably needs to happen with the DWARF Committee more than the<br>
        LLVM community.<br>
<br>
        - David<br>
<br>
                --paulr<br>
<br>
<br>
                 ><br>
                 ><br>
                 >> That said, I'm not opposed to proposing something to<br>
                DWARF to define some more<br>
                 >> 'proper' way to describe this.<br>
                 ><br>
                 >Yah. I've been thinking about the DW_AT_specification<br>
                idea too, which would be<br>
                 >something like this:<br>
                 > DW_TAG_class_type<br>
                 > DW_AT_name "S<A>"<br>
                 > DW_AT_specification -> S<int><br>
                 ><br>
                 > DW_TAG_template_type_parameter<br>
                 > DW_AT_name "T"<br>
                 > DW_AT_type -> A<br>
                 ><br>
                 >The problem with this is you don't know where T is<br>
                used in the template, so<br>
                 >you *still* don't know when to use A as the type of<br>
                "field". Also it's kind<br>
                 >of an abuse of DW_AT_specification. If we can't get A<br>
                as the type of "field"<br>
                 >then the typedef is more straightforward and<br>
                understandable.<br>
                 ><br>
                 >It's still a lot of DWARF to emit for every way the<br>
                user has named the template<br>
                 >& I'm not sure how much value it provides - are there<br>
                use cases you have in mind<br>
                 >that would benefit from the increased fidelity of<br>
                knowing which template argument<br>
                 >corresponds to the way the user wrote the type.<br>
                 ><br>
                 > (& what would we emit if the user named the type in<br>
                some other more exotic way:<br>
                 >int func(); template<typename T> struct S { }; ...<br>
                S<decltype(func())> s; )<br>
                 ><br>
                 ><br>
                 >Maybe I'll pop a note to the DWARF committee for a<br>
                broader set of opinions.<br>
                 ><br>
                 >><br>
                 >> One other open question is then, when, if ever, to<br>
                reference the DW_TAG_typedef<br>
                 >> rather than the underlying type? Do we just<br>
                reference it whenever the user<br>
                 >> writes using that name?<br>
                 >><br>
                 >> void f(S<A>);<br>
                 >> ...<br>
                 >> void f(S<B>) { ... }<br>
                 >><br>
                 >> etc... (this would be just as possible/we could<br>
                maybe treat it the same as if<br>
                 >> the user wrote "void f(A); ... void f(B) { ... }")<br>
                 ><br>
                 >That's what I would do, and I think is more conformant<br>
                to the DWARF spec.<br>
                 >--paulr<br>
                 ><br>
                 >><br>
                 >> > (because DWARF is all about the name "as it<br>
                appears in the source program.")<br>
                 >> ><br>
                 >> > > (the debugger wouldn't know these are actually<br>
                the same type so wouldn't<br>
                 >> > > allow function calls, etc).<br>
                 >> > ><br>
                 >> > > - David<br>
                 >> > ><br>
                 >> > > ><br>
                 >> > > ><br>
                 >> > > > > Jim<br>
                 >> > > > ><br>
                 >> > > >> On Sep 8, 2014, at 12:38 PM, Frédéric Riss<br></div></div><span class="">
                <<a href="mailto:friss@apple.com" target="_blank">friss@apple.com</a> <mailto:<a href="mailto:friss@apple.com" target="_blank">friss@apple.com</a>>> wrote:<br>
                 >> > > >><br>
                 >> > > >><br>
                 >> > > >>> On 08 Sep 2014, at 19:31, Greg Clayton<br></span><div><div class="h5">
                <<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a> <mailto:<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>>> wrote:<br>
                 >> > > >>><br>
                 >> > > >>> This means you will see "S<A>" as the type<br>
                for your variables in the<br>
                 >> > > debugger when you view variables or children of<br>
                structs/unions/classes. I<br>
                 >> > > think this is not what the user would want to<br>
                see. I would rather see<br>
                 >> > > "S<int>" as the type for my variable than see<br>
                "S<A>”.<br>
                 >> > > >><br>
                 >> > > >> I find it more accurate for the debugger to<br>
                report what has actually<br>
                 >> > > been put in the code. Moreover when a typedef is<br>
                used, it’s usually to<br>
                 >> > > make things more readable not to hide<br>
                information, thus I guess it would<br>
                 >> > > usually be as informative while being more<br>
                compact. The debugger needs to<br>
                 >> > > have a way to describe the real type behind the<br>
                abbreviated name though,<br>
                 >> > > we must not have less information compared to<br>
                what we have today.<br>
                 >> > > >><br>
                 >> > > >> Another point: this allows the debugger to<br>
                know what S<A> actually is.<br>
                 >> > > Without it, the debugger only knows the<br>
                canonical type. This means that<br>
                 >> > > currently you can’t copy/paste a piece of code<br>
                that references that kind<br>
                 >> > > of template names and have it parse correctly. I<br>
                /think/ that having this<br>
                 >> > > information in the debug info will allow more of<br>
                this to work.<br>
                 >> > > >><br>
                 >> > > >> But we can agree to disagree :-) It would be<br>
                great to have more people<br>
                 >> > > chime and give their opinion.<br>
                 >> > > >><br>
                 >> > > >> Fred<br>
                 >> > > >><br>
                 >> > > >>>> On Sep 5, 2014, at 4:00 PM, Adrian Prantl<br></div></div><span class="">
                <<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a> <mailto:<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>>> wrote:<br>
                 >> > > >>>><br>
                 >> > > >>>><br>
                 >> > > >>>>> On Sep 5, 2014, at 3:49 PM, Eric<br></span>
                Christopher <<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a> <mailto:<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>>><span class=""><br>
                 >> > > wrote:<br>
                 >> > > >>>>><br>
                 >> > > >>>>><br>
                 >> > > >>>>><br>
                 >> > > >>>>><br>
                 >> > > >>>>> On Fri, Sep 5, 2014 at 3:43 PM, Duncan P.<br>
                N. Exon Smith<br>
                 >> > > <<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a><br></span><span class="">
                <mailto:<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>>> wrote:<br>
                 >> > > >>>>><br>
                 >> > > >>>>>> On 2014 Sep 5, at 16:01, Frédéric Riss<br></span><div><div class="h5">
                <<a href="mailto:friss@apple.com" target="_blank">friss@apple.com</a> <mailto:<a href="mailto:friss@apple.com" target="_blank">friss@apple.com</a>>> wrote:<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> I couldn’t even find a subject expressing<br>
                exactly what this patch<br>
                 >> > > is about… First of all, it’s meant to start a<br>
                discussion, and I’m not<br>
                 >> > > proposing it for inclusion right now.<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> The issue I’m trying to address is that<br>
                template types are always<br>
                 >> > > canonicalized when emitted in the debug<br>
                information (this is the desugar()<br>
                 >> > > call in UnwrapTypeForDebugInformation)<u></u>.<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> This means that if the developer writes:<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> typedef int A;<br>
                 >> > > >>>>>> template <typename T><br>
                 >> > > >>>>>> struct S {};<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> S<A> var;<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> The variable var will have type S<int><br>
                and not S<A>. In this simple<br>
                 >> > > example, it’s not that much of an issue, but for<br>
                heavily templated code,<br>
                 >> > > the full expansion might be really different<br>
                from the original<br>
                 >> > > declaration.<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> The attached patch makes us emit an<br>
                intermediate typedef for the<br>
                 >> > > variable’s type:<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> 0x0000002a: DW_TAG_variable [2]<br>
                 >> > > >>>>>> DW_AT_name [DW_FORM_strp] (<br>
                 >> > > .debug_str[0x00000032] = “var")<br>
                 >> > > >>>>>> DW_AT_type [DW_FORM_ref4] (cu + 0x0040 =><br>
                 >> > > {0x00000040})<br>
                 >> > > >>>>>> DW_AT_external [DW_FORM_flag] (0x01)<br>
                 >> > > >>>>>> DW_AT_decl_file [DW_FORM_data1] (0x01)<br>
                 >> > > >>>>>> DW_AT_decl_line [DW_FORM_data1] (8)<br>
                 >> > > >>>>>> DW_AT_location [DW_FORM_block1] (<0x09><br>
                03 70 6c 00 00<br>
                 >> > > 00 00 00 00 )<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> 0x00000040: DW_TAG_typedef [3]<br>
                 >> > > >>>>>> DW_AT_type [DW_FORM_ref4] (cu + 0x004b =><br>
                 >> > > {0x0000004b})<br>
                 >> > > >>>>>> DW_AT_name [DW_FORM_strp] (<br>
                 >> > >.debug_str[0x00000035] = “S<A>")<br>
                 >> > > >>>>>> DW_AT_decl_file [DW_FORM_data1] (0x01)<br>
                 >> > > >>>>>> DW_AT_decl_line [DW_FORM_data1] (6)<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> 0x0000004b: DW_TAG_structure_type [4] *<br>
                 >> > > >>>>>> DW_AT_name [DW_FORM_strp] (<br>
                 >> > >.debug_str[0x0000003e] = “S<int>")<br>
                 >> > > >>>>>> DW_AT_byte_size [DW_FORM_data1] (0x01)<br>
                 >> > > >>>>>> DW_AT_decl_file [DW_FORM_data1] (0x01)<br>
                 >> > > >>>>>> DW_AT_decl_line [DW_FORM_data1] (6)<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> Which basically is what I want, although<br>
                I don’t like that it<br>
                 >> > > introduces a typedef where there is none in the<br>
                code. I’d prefer that to<br>
                 >> > > be:<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> DW_TAG_variable<br>
                 >> > > >>>>>> DW_AT_type: -> DW_TAG_structure_type<br>
                 >> > > >>>>>> DW_AT_name: S<A><br>
                 >> > > >>>>>> DW_AT_specification: -> DW_TAG_structure_type<br>
                 >> > > >>>>>> DW_AT_name: S<int><br>
                 >> > > >>>>>> …<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> The patch also has the nice property of<br>
                omitting the defaulted<br>
                 >> > > template arguments in the first level typedef.<br>
                For example you get<br>
                 >> > > vector<A> instead of vector<int,<br>
                std::__1::allocator<int> >.<br>
                 >> > > >>>>><br>
                 >> > > >>>>> If you specify `vector<int>` in C++ do you<br>
                get that instead of<br>
                 >> > > >>>>> `vector<int, std::__1::allocator<int>>`?<br>
                 >> > > >>>>><br>
                 >> > > >>>>> Yeah, I mentioned this as possibly causing<br>
                problems with debuggers<br>
                 >> > > or other consumers, but I don't have any proof<br>
                past "ooooo scary!”.<br>
                 >> > > >>>><br>
                 >> > > >>>> Well, [+lldb-dev], could this confuse<br>
                debuggers? :-)<br>
                 >> > > >>>><br>
                 >> > > >>>> -- adrian<br>
                 >> > > >>>>><br>
                 >> > > >>>>> That said, I like the idea personally :)<br>
                 >> > > >>>>><br>
                 >> > > >>>>> -eric<br>
                 >> > > >>>>><br>
                 >> > > >>>>><br>
                 >> > > >>>>>> Now there is one thing I really don’t<br>
                like about the patch. In<br>
                 >> > > order not to emit typedefs for types that don’t<br>
                need it, I use string<br>
                 >> > > comparison between the desugared and the<br>
                original type. I haven’t<br>
                 >> > > quantified anything, but doing the construction<br>
                of the type name for every<br>
                 >> > > template type and then comparing it to decide to<br>
                use it or not seems like<br>
                 >> > > a big waste.<br>
                 >> > > >>>>><br>
                 >> > > >>>>> Maybe someone on cfe-dev knows a better way.<br>
                 >> > > >>>>><br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> Thoughts?<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> <template-arg-typedefs.diff><br>
                 >> > > >>>>>><br>
                 >> > > >>>>>> Fred<br>
                 >> > > >>>>>><br>
                 >> > > >>>>>><br>
                 >> > > >>>>>><br>
                 >> > > >>>>>><br>
                 >> > > >>>>>><br>
                 >> > > >>>>>><br>
                ______________________________<u></u>_________________<br>
                 >> > > >>>>>> llvm-commits mailing list<br>
                 >> > > >>>>>> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br></div></div>
                <mailto:<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.<u></u>edu</a>><span class=""><br>
                 >> > > >>>>>><br>
                <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
                 >> > > >>>>><br>
                 >> > > >>>>><br>
                 >> > > >>>><br>
                 >> > > >>>> ______________________________<u></u>_________________<br>
                 >> > > >>>> lldb-dev mailing list<br>
                 >> > > >>>> <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br></span>
                <mailto:<a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a>><span class=""><br>
                 >> > > >>>><br>
                <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/lldb-dev</a><br>
                 >> > > >>><br>
                 >> > > >><br>
                 >> > > >><br>
                 >> > > >> ______________________________<u></u>_________________<br>
                 >> > > >> lldb-dev mailing list<br>
                 >> > > >> <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br></span>
                <mailto:<a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a>><span class=""><br>
                 >> > > >><br>
                <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/lldb-dev</a><br>
                 >> > > ><br>
                 >> > ><br>
                 >> > ><br>
                 >> > > ______________________________<u></u>_________________<br>
                 >> > > llvm-commits mailing list<br>
                 >> > > <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br></span>
                <mailto:<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.<u></u>edu</a>><span class=""><br>
                 >> > ><br>
                <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
                 >> ><br>
                 >> > ______________________________<u></u>_________________<br>
                 >> > llvm-commits mailing list<br>
                 >> > <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br></span>
                <mailto:<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.<u></u>edu</a>><span class=""><br>
                 >> ><br>
                <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
<br>
<br>
    ______________________________<u></u>_________________<br>
    lldb-dev mailing list<br></span>
    <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a> <mailto:<a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a>><span class=""><br>
    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/lldb-dev</a><br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</span></blockquote><div class=""><div class="h5">
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>