<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 30/06/2014 11:44 AM, Greg Clayton
wrote:<br>
</div>
<blockquote
cite="mid:8228A716-1E41-43C0-8329-82457809A4B2@apple.com"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">On Jun 30, 2014, at 10:52 AM, Alex Pepper <a class="moz-txt-link-rfc2396E" href="mailto:apepper@blueshiftinc.com"><apepper@blueshiftinc.com></a> wrote:
* I sent this earlier before I registered, sorry in advance if this shows up as a duplicate.
I have been familiarizing myself with the expression parsing code in LLDB with the intention of finding and fixing several expression parser related bugs.
The first issue that I have been investigating in detail is related to calling c_str() on a standard string. The expression fails because LLDB is not able to match up the mangled function name with any names in the symbol table. There is special handling for standard strings in IRForTarget::GetFunctionAddress to support two variants of the mangled name prefix of, _ZNKSbIc and _ZNKSs. The _ZNKSbIc represents basic_string<char> whereas _ZNKSs represents string which is a typedef of basic_string<char>. In this case the full name in the g++ compiled dwarf symbols is _ZNKSs5c_strEv, Clang also generates the same symbol. The call to m_decl_map->GetFunctionAddress is failing because the mangled name that is being generated by the JIT compiled expression is actually the fully specified name, _ZNKSbIcSt17char_traits<char>St15allocator<char>E5c_strEv, which is equivalent to basic_string<char,char_traits<char>,allocator<char>>.
I have been walking through the expression parsing code but have not been able to locate where this name is actually generated. I am guessing the name is generated during the ParseAST but I have not been able to track it down yet, any help would be appreciated.
</pre>
</blockquote>
<pre wrap="">
The compiler will generate this in the debug info. When we go looking for a symbol or function, the compiler will ask us where the function is, and we usually find this in the C++ standard library shared library. So you should do a:
(lldb) image dump symtab
This should dump all symbols from all shared libraries and look for std::basic_string somewhere in the mix and see what symbols. You _ZNKSbIcSt17char_traits<char>St15allocator<char>E5c_strEv detangles to:
std::basic_string<char, std::char_traits<char>, std::allocator<char> >::c_str() const
on our system. I would check the symbols in your libstdc++ shared library and see what symbols are there for basic_string and see why things aren't matching up.
Greg
</pre>
</blockquote>
<br>
In lldb I dumped the un-mangled symbol for: std::string::c_str()
const. The address is: libstdc++.so.6[
<meta charset="utf-8">
<b style="font-weight:normal;"
id="docs-internal-guid-ebac21e9-ee9d-6472-7412-e4c90f8f8528"><span
style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;">0x00000000000b9630</span></b>].
This address corresponds the the exported symbol _ZNKSs5c_strEv,
that I dumped from libstdc++.so.6 at the same file address/value.
Both the lldb I am debugging and the inferior a.out I am attached
from lldb show dependencies on the same version and location of
libstdc++.so.6.<br>
<br>
I am still not clear if the mangled name,
_ZNKSbIcSt17char_traits<char>St15allocator<char>E5c_strEv,
is being generated from MCJIT within LLDB and where that happens in
the source. As you described in your followup message, according to
the name mangling compression rules I would expect this to be
mangled as _ZNKSs5c_strEv. On my system (Ubuntu 14.04, gcc.4.82,
clang 3.5-1), the standalone compile of the test program mangles as
_ZNKSs5c_strEv in dwarf symbols, but in LLDB the name extracted from
the function passed to GetFunctionAddress() is mangled as
_ZNKSbIcSt17char_traits<char>St15allocator<char>E5c_strEv,
which is not compressed as I would have expected.<br>
<br>
- Alex<br>
<br>
<br>
</body>
</html>