[lldb-dev] Anonymous Namespace - Bug 15302

Greg Clayton gclayton at apple.com
Mon Jul 28 17:08:27 PDT 2014


> On Jul 28, 2014, at 2:26 PM, Alex Pepper <apepper at blueshiftinc.com> wrote:
> 
> I investigated bug 15302, which is described as:
> 
> "LLDB does not print 'anonymous namespace' prefix for variable names (if inferior built with GCC on Linux)"
> 
> What I found was that the GCC dwarf data does not contain a mangled name for a variable defined in an anonymous namespace, unlike clang.  LLDB VariableObject depends on the mangled name to identify the anonymous namespace for a variable, so in the test case it does no print the (anonymous namespace) prefix.  I checked the dwarf data using dwarfdump and nm.  In the case of dwarfdump the variable is a child of the anonymous namespace but there is no mangled name, but when I use nm to dump the symbols it displays the mangled name.  I am not sure if this means nm is generating the name or getting the symbol from somewhere else.

nm only looks at the symbol table and the symbol table will contain only the mangled name for the variable.

> I am looking for suggestions on how to resolve this, should LLDB be inferring the namespace from the hierarchy somehow or should GCC be outputting the mangled symbol?

I believe GCC should emit a mangled name. The problem is you can have:

namespace {
    class Foo {
        static int g_foo;
    }
}

If GCC doesn't emit the full mangled named, then we don't want to have to have code that knows how to follow the decl context of g_foo back up and create names for everything with proper scoping and decorations.

Greg



More information about the lldb-dev mailing list