<br><br><div class="gmail_quote">On Fri, May 20, 2011 at 6:21 AM, Howard Hinnant <span dir="ltr"><<a href="mailto:hhinnant@apple.com">hhinnant@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
There is a new project at:<br>
<br>
<a href="http://libcxxabi.llvm.org/" target="_blank">http://libcxxabi.llvm.org/</a><br>
<br>
This is libc++abi, and is meant to be the low-level, Itanium ABI (<a href="http://www.codesourcery.com/public/cxx-abi/" target="_blank">http://www.codesourcery.com/public/cxx-abi/</a>) implementation for libc++. There isn't much in there right now (additions welcome!). So far all that is in there is a demangler (__cxa_demangle).<br>
<br>
The demangler has been split into three lower-level API's:<br>
<br>
__demangle_tree<br>
__demangle(const char* mangled_name, char* buf, size_t bs)<br>
<br>
__demangle_tree<br>
__demangle(const char* mangled_name);<br>
<br>
char*<br>
__demangle(__demangle_tree dmg_tree, char* buf, size_t* n, int* status);<br>
<br>
The first two functions take a mangled name as input and output a __demangle_tree. This is the "parsing part" of demangling. The reason for two functions here is so that you can optionally pass in a buffer, which if large enough, will be used instead of allocating memory for the __demangle_tree.<br>
<br>
The third function takes the __demangle_tree, and outputs an unmangled name.<br>
<br>
Using this low-level API, __cxa_demangle becomes a trivial wrapper above this API:<br>
<br>
char*<br>
__cxa_demangle(const char* mangled_name, char* buf, size_t* n, int* status)<br>
{<br>
if (mangled_name == NULL || (buf != NULL && n == NULL))<br>
{<br>
if (status)<br>
*status = __libcxxabi::invalid_args;<br>
return NULL;<br>
}<br>
const size_t bs = 64 * 1024;<br>
char static_buf[bs];<br>
<br>
buf = __libcxxabi::__demangle(__libcxxabi::__demangle(mangled_name,<br>
static_buf, bs),<br>
buf, n, status);<br>
return buf;<br>
}<br>
<br>
It is expected that some tools (compilers, debuggers) will want to make use of an API on __demangle_tree that has yet to be developed. E.g. how many function arguments and what are they? How many template arguments and what are they? etc.<br>
</blockquote><div><br>Hi Howard,<br><br>I have to let the cat out of the bag a bit early, but there is going to be BSD licensed code doing this exact thing released very soon. (Sorry everyone I'm the bottleneck)<br>
<br>
You're of course free to work on what you want, but a few notes<br><br>1) It's used in production already<br>2) It's been tested with LLVM, PathScale and possibly other compilers<br>3) It's portable across FreeBSD, Linux, Solaris, OSX.. etc<br>
4) Has good inline documentation<br>5) Smallest/fastest C++ runtime in the industry based on my tests<br><br>./C<br><br>ps. Someone kick me if it's not in the wild by later today<br></div></div>