[lldb-dev] Using a undeclared free function in lldb Mangled.cpp causes build failure

Zack Perry zack.perry at sbcglobal.net
Thu Aug 15 11:36:53 PDT 2013

Hi Stefanus,

Thanks for your response?

> 0. why in a C++ code, the C free function is used?

Because it's calling into a C API (cxxabi). demangled_name comes from a
call to abi::__cxa_demangle(), which presumably calls malloc to allocate
its return value.

OK. Got that.

> 1. Why when using it, the #include <cstdlib> is nowhere in the source?

Mangled.cpp:25 is:
#include <stdlib.h>

No. This is incorrect. With lldb 3.3 official release tar ball, the #include that you mentioned is not there.

zackp at nb1:~/Downloads/clang3.3/lldb-3.3.src/source/Core$ grep stdlib.h Mangled.cpp
zackp at nb1:~/Downloads/clang3.3/lldb-3.3.src/source/Core$

I patched it as follows:

   11  #if defined(__APPLE__)
   13  #endif
   16  #include "lldb/Core/cxa_demangle.h"
   17  #else
   18  // FreeBSD9-STABLE requires this to know about size_t in cxxabi.h
   19  #include <cstddef>
   20  #include <cxxabi.h>
   21  #endif
   23  #include <cstdlib>
   24  #include "llvm/ADT/DenseMap.h"

My personal style is that if I code in C++, I use as much as possible C++ coding convention.


-- Zack[...]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20130815/16fc310c/attachment.html>

More information about the lldb-dev mailing list