[cfe-dev] LLDB Expression Name Mangling for std::string

Alex Pepper apepper at blueshiftinc.com
Thu Jul 3 15:58:48 PDT 2014


I have been getting up to speed on the LLDB project and have been 
working towards getting all unit tests to pass on Linux.  As part of 
this I have been working on a failure in the expression parsing when 
trying to evaluate std::string::c_str() function call.  The failure is 
due to a mismatch in the name mangling between what is mangled in the 
LLDB runtime vs the inferior process exported symbols.

I have been debugging LLDB trying to find where the name mangling is 
getting messed up during eval parsing of std::string::c_str() and have 
traced it into CXXNameMangler::mangleStandardSubstitution in 
ItaniumMangle.cpp which is part of clangs AST module.  In 
mangleStandardSubstitution it is testing the identifier to see if it is 
a ClassTemplateSpecializationDecl equivalent to 
std::basic_string<char,std::char_traits<char>,std::allocator<char>> so 
that it can substitute the short form mangled string "Ss".  This check 
fails on the second template argument test where it is checking if it is 
a char specialization of char_traits.

if (!isCharSpecialization(TemplateArgs[1].getAsType(), "char_traits"))
         return false;

I have dumped the declaration to verify it is the correct identifier:
class basic_string definition
|-TemplateArgument type 'char'
|-TemplateArgument type 'struct std::char_traits<char>'
|-TemplateArgument type 'class std::allocator<char>'

I also dumped the template arguments separately:
char identifier
struct std::char_traits<char> identifier
class std::allocator<char> identifier

I am not familiar enough yet with the Clang architecture to understand 
why this check is failing.  Any suggestions on how to track this down 
would be appreciated.

- Alex



More information about the cfe-dev mailing list