[lldb-dev] LLDB Expression Parser Name Mangling
gclayton at apple.com
Mon Jun 30 13:19:20 PDT 2014
> On Jun 30, 2014, at 1:14 PM, Greg Clayton <gclayton at apple.com> wrote:
>> On Jun 30, 2014, at 12:33 PM, Zachary Turner <zturner at google.com> wrote:
>> Questions from a random observer: Why are these two manglings of std::string hardcoded into the code?
> Because the compiler will emit one or both and the current libstdc++ only has one mangling in the symbol table. If we don't pull this trick we can end up not finding functions that are required in JITed code when the lookups for these symbols happen in the MCJIT.
>> Or better yet, why is std::string even special cased to begin with?
> Because this one of the few things that there are special aliased mangled names for in the mangling. Not sure why the compiler isn't always forced to use the shorter built in mangling, but it currently isn't. This might only be an issue on MacOSX, I am not sure on how often these issues would present themselves on other systems.
The relevant section is:
<substitution> ::= St # ::std::
<substitution> ::= Sa # ::std::allocator
<substitution> ::= Sb # ::std::basic_string
<substitution> ::= Ss # ::std::basic_string < char,
<substitution> ::= Si # ::std::basic_istream<char, std::char_traits<char> >
<substitution> ::= So # ::std::basic_ostream<char, std::char_traits<char> >
<substitution> ::= Sd # ::std::basic_iostream<char, std::char_traits<char> >
The abbreviation St is always an initial qualifier, i.e. appearing as the first element of a compound name. It does not require N...E delimiters unless either followed by more than one additional composite name component, or preceded by CV-qualifiers or a ref-qualifier for a member function. This adds the case:
<name> ::= St <unqualified-name> # ::std::
So if a compiler doesn't apply compression, or does, when the current system was built with/without you can get name lookup failures.
>> Is the debug visualization support not sufficient to be able to deal with stl strings in a useful manner?
> Debug visualization is just fine, it is just when the MCJIT says "I must get an address for this mangled named" and if we aren't able to find it, the expression evaluation fails.
More information about the lldb-dev