<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 11:34 AM, Robinson, Paul <span dir="ltr"><<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div><span class="">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">|
</span>I don't understand why "without requiring* additional smarts on the debugger side" is a goal. <u></u><u></u></p>
</span><p class="MsoNormal"><a name="14f42179c1c7eb41__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">It is explicitly a goal of DWARF to be language-neutral, </span></a></p></div></div></blockquote><div><br>This statement seems to be problematically ambiguous. The DWARF features are language neutral, certainly - so they can be used to describe a variety of language features. There are suggested ways that certain language features can be described in DWARF, but those are not required.<br><br>This does not imply that the DWARF produced by a debugger can be usefully interpreted to perform certain actions (such as name lookup) in a language neutral way.<br><br>DWARF is language neutral in the sense that it provides a bunch of tools and says "use these however you want (here are some suggestions) to communicate things between producers and consumers".<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><a name="14f42179c1c7eb41__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">and it is contrary to that goal to require a debugger to know a C++ rule
 about anonymous namespaces in order to conjure up a correct list of named entities.  I'd go so far as to say it's a bug in the producer.</span></a></p></div></div></blockquote><div><br>Again, the COBOL example ith regards to nested name lookup seems to provide the perfect counterexample to this idea.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><a name="14f42179c1c7eb41__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></a></p><span class="">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">|
</span>We require lots of additional smarts on the debugger side to deal with ABI knowledge<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">AFAICT all of those smarts are to deal with debugger features intended to imitate things a *compiler* would do, like support dynamically calling a function
 in the process-under-debug. </span></p></div></div></blockquote><div><br>"like performing name lookup" would seem like another thing that could be described in the same way as you've done here.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> Nobody has shown why a debugger needs ABI knowledge in order to interpret the DWARF correctly, in its intended mode of providing a language-neutral mapping of source to object.</span></p></div></div></blockquote><div><br>DWARF doesn't remove the language-ness from the mapping. We don't use it to encode all the language rules/notions into some common abstract representation. We use it to describe the source, generally.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Certainly if your fancy-pants debugger wants to pretend to be a compiler, JITting ABI-compatible code and such, it needs to know a bunch more stuff (like the
 ABI), but that's not a justification for emitting DWARF that *can't* be interpreted correctly without specific C++ rule knowledge.</span></p></div></div></blockquote><div><br>I don't see the distinction you're drawing. "can't be interpreted correctly" depends on what actions are being undertaken. If all I want to do is print out a rough summary of what the source looked like, using the debug info - I could totally do that with an anonymous namespace without any imported module directive.<br><br>Your debugger happens to be want to do name lookup in a particular way (it could do so by treating an anonymous namespace as not adding any extra qualification - that wouldn't be a language specific rule? (not any more than the "look in outer scopes" rule that consumers appear to use by default)) as one of its tasks.<br><br>Mine happens to want to be able to cal functions.<br><br>It's not like one of these is fundamental and the other is not. These are just two different scenarios that DWARF consumers may wish to support. (two of many)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p><span class="">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> 
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">|
</span>(SFINAE being an obvious example of happy fun times),<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">SFINAE (AFAIK) applies to template selection, and since you don't have a template declaration in the DWARF, that's irrelevant here.</span></p></div></div></blockquote><div><br>Yep, fair point. Thought about that more & realized that's the case - only the templates instantiated with the SFINAE Test passing would ever get generated & then be considered in the overload set.<br><br>I imagine there are toher complex lookup cases that there's insufficient DWARF to get right, though - none immediately spring to mind.<br><br>For now, my fundamental question is: How is this goal (adding imported modules for anonymous namespaces) consistent with the lack of imported modules for outer namespaces in nested ones? These two scenarios seem quite the same to me.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">--paulr<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Eric Christopher [mailto:<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>]
<br>
<b>Sent:</b> Tuesday, August 18, 2015 11:06 AM<br>
<b>To:</b> David Blaikie<br>
<b>Cc:</b> Robinson, Paul; <a href="mailto:reviews%2BD7895%2Bpublic%2B7827be49c0b04087@reviews.llvm.org" target="_blank">reviews+D7895+public+7827be49c0b04087@reviews.llvm.org</a>; Romanova, Katya; Frédéric Riss; Duncan P. N. Exon Smith; llvm-commits</span></p><div><div class="h5"><br>
<b>Subject:</b> Re: [PATCH] D7895: Anonymous namespaces are missing import DW_TAG_imported_module.<u></u><u></u></div></div><p></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Tue, Aug 18, 2015 at 11:03 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<p class="MsoNormal">On Tue, Aug 18, 2015 at 10:59 AM, Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>> wrote:<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Tue, Aug 18, 2015 at 10:55 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<p class="MsoNormal">On Tue, Aug 18, 2015 at 10:43 AM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">The as-if suggests that an explicit artificial import is an entirely appropriate, natural and good
 way to handle it, because it models the language behavior exactly without *requiring* additional smarts on the debugger side.</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
I agree it is a way to handle it - but I don't understand why "without requiring* additional smarts on the debugger side" is a goal. <u></u><u></u></p>
</div>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">That said, it seems to be a bit of a double standard here. We require lots of additional smarts on the debugger side to deal with ABI knowledge, and in fact have numerous odd workarounds in DWARF to deal with parameter passing that would
 be less of an issue if we had generalized ABI support (as an example). How is this case any different?<u></u><u></u></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">The conclusion with the ABI stuff was that it would be impossible for a client to model it correctly - there were cases Richard demonstrated that there was no reasonable extra DWARF we could produce in the type
 that would allow the debugger to make the right choice about the calling convention to use when that type was passed (I believe there were particular template cases?). Also, the argument was made that these rules change over time - and the debugger wouldn't
 know which set of rules to use without being told which ones the compiler had used when it compiled this file (OK, so if we had enough type information, we could've just put a "ABI rev number" on the CU).<br>
<br>
For both of those reasons, it is necessary that we actually just put a tag on the type specifying how it should be passed.<u></u><u></u></p>
</div>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Or specify ABI per function of course.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">These cases don't apply here - C++ has fun/weird/interesting name lookup rules (and, admittedly, I'd wager we still don't provide enough DWARF to make the name lookup work every time (SFINAE being an obvious
 example of happy fun times), but generally we rely on consumers to do best effort rather than by trying to describe it all explicitly in DWARF - the latter seems pretty much impractical)<u></u><u></u></p>
</div>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Oh I agree. :)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">-eric<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<div>
<p class="MsoNormal">- Dave<u></u><u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<p class="MsoNormal"><span style="color:#888888"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#888888">-eric<u></u><u></u></span></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<div>
<p class="MsoNormal">natural/good - I just don't agree with. The stated goal in many cases has been that the DWARF model the source as written. This is a case where that's easy and obvious to do.<br>
<br>
* it's not requiring - it's just a degraded experience (as you say, quality of implementation - as with many places where, if the debugger doesn't understand C++, it gets a less-than-ideal user experience)<br>
 <u></u><u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Not all as-if statements have to be modeled directly in the DWARF, because they aren't relevant to
 DWARF or DWARF has other ways of achieving the same effect.  For example, [namespace.udir]/2 says a using-directive means "the names appear
<b>as if<i> </i></b>they were declared in the nearest enclosing namespace…" but there's no reason to generate piles of declarations in the outer namespace because, we have DW_TAG_imported_module which means exactly that.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I don't see any good reason for artificial namespaces to be treated specially just because the namespace
 is anonymous and the 'using' directive isn't explicit in the source.</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">From my perspective it seems like you're asking the producer to special case anonymous namespaces so the debugger doesn't have to. I'd simply argue the opposite - I'd like to not special case them in the producer, instead producing source-accurate
 debug info as much as possible, and leave it to the debugger to implement appropriate behavior.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">The Cobol example seems perfect: We rely on consumers modeling languages correctly to import outer namespaces into inner ones in languages that support that. In the languages that don't, we rely on the consumer to know that and model it
 differently. If a consumer does not do this, the user gets a degraded experience (their cobol name lookup is wrong (or perhaps their non-cobol name lookup is wrong, if the debugger decided to only model the cobol side and assume all other languages work that
 way too)).<br>
<br>
This seems directly analogous to anonymous namespaces - we describe the source and let the consumer model it appropriately. <u></u><u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">--paulr</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>]
<br>
<b>Sent:</b> Tuesday, August 18, 2015 10:27 AM<br>
<b>To:</b> Robinson, Paul<br>
<b>Cc:</b> <a href="mailto:reviews%2BD7895%2Bpublic%2B7827be49c0b04087@reviews.llvm.org" target="_blank">
reviews+D7895+public+7827be49c0b04087@reviews.llvm.org</a>; Romanova, Katya; Eric Christopher; Frédéric Riss; Duncan P. N. Exon Smith; llvm-commits<br>
<b>Subject:</b> Re: [PATCH] D7895: Anonymous namespaces are missing import DW_TAG_imported_module.</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Tue, Aug 18, 2015 at 10:23 AM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">| suggests that DW_TAG_imported_module could be used for C++ using directives (of which there are none in the source code in question).<u></u><u></u></p>
<p class="MsoNormal"><a name="14f42179c1c7eb41_msg-f:1509866609394360306_14f41f7742b004"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></a><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">[namespace.unnamed]/1 says there is an implicit (as-if) using directive.</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Lots of things are as-if, doesn't mean we model them in the DWARF that way, it's just an easy way of defining the behavior in terms of other stuff that's already defined in the
 standard. Generally we try to model things like the actual source where possible, it seems/usually sounds like/etc.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">--paulr</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>]
<br>
<b>Sent:</b> Tuesday, August 18, 2015 10:15 AM</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><br>
<b>To:</b> Robinson, Paul<br>
<b>Cc:</b> <a href="mailto:reviews%2BD7895%2Bpublic%2B7827be49c0b04087@reviews.llvm.org" target="_blank">
reviews+D7895+public+7827be49c0b04087@reviews.llvm.org</a>; Romanova, Katya; Eric Christopher; Frédéric Riss; Duncan P. N. Exon Smith; llvm-commits<br>
<b>Subject:</b> Re: [PATCH] D7895: Anonymous namespaces are missing import DW_TAG_imported_module.<u></u><u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">All I'm saying is that I think this is a fine thing to have as a debugger-specific tuning for your debugger.<br>
<br>
DWARF-the-standard is language neutral, yes, so it provides features that can be used to describe many different languages. It describes (non-normatively) possible uses of DWARF features for language features, and suggests that DW_TAG_imported_module could
 be used for C++ using directives (of which there are none in the source code in question). It doesn't suggest anywhere that it should, let alone must, be used to explicitly describe name lookup rules (or we'd need those using directives in nested scopes for
 all outer scopes, for example).<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br></div></div>