[llvm] r176143 - Debug Info: for static member variables, add AT_MIPS_linkage_name to the

Manman Ren mren at apple.com
Tue Feb 26 16:19:39 PST 2013


On Feb 26, 2013, at 4:09 PM, Eric Christopher <echristo at gmail.com> wrote:

> 
> Debug Info: for static member variables, add AT_MIPS_linkage_name to the
> definition DIE, to make old GDB happy.
> 
> 
> Again, is this for compatibility or for correctness?
To me this is to fix a regression. Not sure whether that belongs to compatibility or correctness.
>  
> We have a regression for old GDB when Clang uses DW_TAG_member to declare
> static members inside a class, instead of DW_TAG_variable. This patch will fix
> this regression.
> 
> 
> So, did you check the other uses of AT_MIPS_linkage_name?
Do you mean uses of AT_MIPS_linkage_name by the debuggers?
>  
> 
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=176143&r1=176142&r2=176143&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Tue Feb 26 18:02:32 2013
> @@ -1348,9 +1348,15 @@ void CompileUnit::createGlobalVariableDI
>      }
>      // Add linkage name.
>      StringRef LinkageName = GV.getLinkageName();
> -    if (!LinkageName.empty() && isGlobalVariable)
> +    if (!LinkageName.empty() && isGlobalVariable) {
>        addString(VariableDIE, dwarf::DW_AT_MIPS_linkage_name,
>                  getRealLinkageName(LinkageName));
> +      // To make old GDB happy, for static member variables, we add
> +      // AT_MIPS_linkage_name to the definition DIE as well.
> 
> Can you explain this more? What's going on? What's the problem?
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:
class MyClass {
public:
static MyClass* A;
MyClass() {
}
};
MyClass* MyClass::A = 0;

clang++ test.cpp -O0 -g -c -o test3.o
with Apple's gdb, run "gdb test3.o"
Error: gdb does not handle things like classes defined inside functions correctly; debug info for 'test3.o' skipped

This testing case used to work when we use DW_TAG_variable inside a class for static members.
Adding this extra AT_MIPS_linkage_name to the definition DIE will make old GDB happy.
It should not break other debugger.

CC' Jim.

Thanks,
Manman

> 
> -eric

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130226/403f9caa/attachment.html>


More information about the llvm-commits mailing list