<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Feb 26, 2013, at 4:09 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Debug Info: for static member variables, add AT_MIPS_linkage_name to the<br>
definition DIE, to make old GDB happy.<br>
<br></blockquote><div><br></div><div style="">Again, is this for compatibility or for correctness?</div></div></div></div></blockquote>To me this is to fix a regression. Not sure whether that belongs to compatibility or correctness.<br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
We have a regression for old GDB when Clang uses DW_TAG_member to declare<br>
static members inside a class, instead of DW_TAG_variable. This patch will fix<br>
this regression.<br><br></blockquote><div><br></div><div style="">So, did you check the other uses of AT_MIPS_linkage_name?</div></div></div></div></blockquote>Do you mean uses of AT_MIPS_linkage_name by the debuggers?<br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><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; position: static; z-index: auto;">

<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=176143&r1=176142&r2=176143&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=176143&r1=176142&r2=176143&view=diff</a><br>


==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Tue Feb 26 18:02:32 2013<br>
@@ -1348,9 +1348,15 @@ void CompileUnit::createGlobalVariableDI<br>
     }<br>
     // Add linkage name.<br>
     StringRef LinkageName = GV.getLinkageName();<br>
-    if (!LinkageName.empty() && isGlobalVariable)<br>
+    if (!LinkageName.empty() && isGlobalVariable) {<br>
       addString(VariableDIE, dwarf::DW_AT_MIPS_linkage_name,<br>
                 getRealLinkageName(LinkageName));<br>
+      // To make old GDB happy, for static member variables, we add<br>
+      // AT_MIPS_linkage_name to the definition DIE as well.<br></blockquote><div><br></div><div style="">Can you explain this more? What's going on? What's the problem?</div></div></div></div></blockquote>I don't quite know how gdb works, but apparently we are getting errors when running gdb (GNU 6.3.50) with a simple testing case:</div><div><div>class MyClass {</div><div>public:</div><div>static MyClass* A;</div><div>MyClass() {</div><div>}</div><div>};</div><div>MyClass* MyClass::A = 0;</div><div><br></div><div>clang++ test.cpp -O0 -g -c -o test3.o</div><div>with Apple's gdb, run "gdb test3.o"</div><div>Error: gdb does not handle things like classes defined inside functions correctly; debug info for 'test3.o' skipped</div><div><br></div><div>This testing case used to work when we use DW_TAG_variable inside a class for static members.</div><div>Adding this extra AT_MIPS_linkage_name to the definition DIE will make old GDB happy.</div><div>It should not break other debugger.</div><div><br></div><div>CC' Jim.</div><div><br></div><div>Thanks,</div><div>Manman</div><div><br></div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div style=""><br></div><div style="">-eric</div>
</div></div></div>
</blockquote></div><br></body></html>