[Lldb-commits] [PATCH] D12809: Better scheme to lookup alternate mangled name when looking up function address.

Siva Chandra via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 14 11:52:52 PDT 2015


sivachandra added a comment.

I could very well be missing something obvious. However, let me explain what I am trying to solve here. Lets take the example of std::vector<string>::size method. The DWARF we get when compiled with GCC is as follows:

  < 3><0x000020a3>        DW_TAG_subprogram
                            DW_AT_external              yes(1)
                            DW_AT_name                  "size"
                            DW_AT_decl_file             0x00000003 /usr/include/c++/4.8/bits/stl_vector.h
                            DW_AT_decl_line             0x00000285
                            DW_AT_linkage_name          "_ZNKSt6vectorISsSaISsEE4sizeEv"
                            DW_AT_type                  <0x00001eb1>
                            DW_AT_accessibility         DW_ACCESS_public
                            DW_AT_declaration           yes(1)
                            DW_AT_object_pointer        <0x000020bc>
                            DW_AT_sibling               <0x000020c2>

If we demangle the linkage name from here, we get "std::vector<std::string, std::allocator<std::string> >::size() const". So, the m_function_fullname_index of SymbolFileDWARF will have entry for this function with this full name.

However, due to missing debug info elsewhere, the IR generated by clang (the LLDB compiler), generates a mangled name like this:
"_ZNKSt6vectorISbIcSt17char_traits<char>St15allocator<char>ESt82allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >E4sizeEv"

This demangles to
"std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::size() const"

Since neither the clang generated mangled name is present in the ELF symtab, and nor its corresponding demangled name is not present in any of the DWARF indices, the existing FindFunctions will not be helpful. Also, only functions with debug info (those which have an address specified in the DWARF) are indexed.

What I am doing in my change is to use the fact that all methods (and their types) are grokked while creating the AST for clang (the LLDB compiler). So, when a method is grokked, store a map from its scoped name to its DIE. Even if there were any discrepancies in the mangled name in the debug info versus that generated by the LLDB compiler, the fully scoped names should be the same. In which case, use the fully scoped name to get to the DIE and retrieve its "actual" mangled name.


http://reviews.llvm.org/D12809





More information about the lldb-commits mailing list