[PATCH 9/9] Use BFD demangler

José Fonseca jose.r.fonseca at gmail.com
Sun May 19 15:26:39 PDT 2013


AFAIK BFD is GPL, so I rather not depend on it, in any form.

But I believe that cplus_demangle was part of libiberty which was LGPL,
which would be OK as external dependency, but it doesn't seem that distros
ship that library separately.

Possibly an even simpler (both from licensing and dependency POV) would be
libstdc++'s abi::__cxa_demangle. Have you tried that?

Jose

On Sun, May 19, 2013 at 3:39 PM, Alexander Monakov <amonakov at ispras.ru>wrote:

> ---
>  CMakeLists.txt             | 2 +-
>  common/trace_backtrace.cpp | 5 +++++
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index db03031..6836553 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -262,7 +262,7 @@ endif ()
>  if (CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
>      add_subdirectory (thirdparty/libbacktrace)
>      include_directories
> (${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libbacktrace)
> -    set (LIBBACKTRACE_LIBRARIES backtrace)
> +    set (LIBBACKTRACE_LIBRARIES backtrace bfd)
>  endif ()
>
>  # Always use bundled QJSon.
> diff --git a/common/trace_backtrace.cpp b/common/trace_backtrace.cpp
> index 83c9d46..9b13f6d 100644
> --- a/common/trace_backtrace.cpp
> +++ b/common/trace_backtrace.cpp
> @@ -274,6 +274,8 @@ std::vector<RawStackFrame> get_backtrace() {
>
>  #include <stdint.h>
>  #include <dlfcn.h>
> +#define HAVE_DECL_BASENAME 1
> +#include <demangle.h>
>  #include <map>
>  #include <vector>
>
> @@ -330,6 +332,9 @@ class libbacktraceProvider {
>          frame.linenumber = line;
>          if (func)
>              frame.function = func;
> +        int dem_style = DMGL_PARAMS|DMGL_ANSI|DMGL_VERBOSE|DMGL_AUTO;
> +        if (func && (func = cplus_demangle_v3(func, dem_style)))
> +            frame.function = func;
>          this_->current_frames->push_back(frame);
>          return 0;
>      }
> --
> 1.8.1.2
>
> _______________________________________________
> apitrace mailing list
> apitrace at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/apitrace
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/apitrace/attachments/20130519/8003a26e/attachment.html>


More information about the apitrace mailing list