From b5f58ba3318e02aeaa60864fe9ae112f41b6d497 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 9 Jan 2014 19:16:40 +0100 Subject: [PATCH] * sanitizer_common/sanitizer_symbolizer_libbacktrace.h (LibbacktraceSymbolizer::Demangle): New declaration. * sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc (POSIXSymbolizer::Demangle): Use libbacktrace_symbolizer_'s Demangle method if possible. * sanitizer_common/sanitizer_symbolizer_libbacktrace.cc: Include "demangle.h" if SANITIZE_CP_DEMANGLE is defined. (struct CplusV3DemangleData): New type. (CplusV3DemangleCallback, CplusV3Demangle): New functions. (SymbolizeCodePCInfoCallback, SymbolizeCodeCallback, SymbolizeDataCallback): Use CplusV3Demangle. * sanitizer_common/Makefile.am (AM_CXXFLAGS): Add -DSANITIZE_CP_DEMANGLE and -I $(top_srcdir)/../include. * libbacktrace/backtrace-rename.h (cplus_demangle_builtin_types, cplus_demangle_fill_ctor, cplus_demangle_fill_dtor, cplus_demangle_fill_extended_operator, cplus_demangle_fill_name, cplus_demangle_init_info, cplus_demangle_mangled_name, cplus_demangle_operators, cplus_demangle_print, cplus_demangle_print_callback, cplus_demangle_type, cplus_demangle_v3, cplus_demangle_v3_callback, is_gnu_v3_mangled_ctor, is_gnu_v3_mangled_dtor, java_demangle_v3, java_demangle_v3_callback): Define. (__asan_internal_memcmp, __asan_internal_strncmp): New prototypes. (memcmp, strncmp): Redefine. * libbacktrace/Makefile.am (libsanitizer_libbacktrace_la_SOURCES): Add ../../libiberty/cp-demangle.c. * libbacktrace/bridge.cc (__asan_internal_memcmp, __asan_internal_strncmp): New functions. * sanitizer_common/Makefile.in: Regenerated. * libbacktrace/Makefile.in: Regenerated. * configure: Regenerated. * configure.ac: Regenerated. * config.h.in: Regenerated. From-SVN: r206477 --- libsanitizer/ChangeLog | 34 ++++++++ libsanitizer/config.h.in | 3 + libsanitizer/configure | 10 ++- libsanitizer/configure.ac | 2 +- libsanitizer/libbacktrace/Makefile.am | 1 + libsanitizer/libbacktrace/Makefile.in | 11 ++- libsanitizer/libbacktrace/backtrace-rename.h | 24 ++++++ libsanitizer/libbacktrace/bridge.cc | 12 +++ libsanitizer/sanitizer_common/Makefile.am | 4 +- libsanitizer/sanitizer_common/Makefile.in | 4 +- .../sanitizer_symbolizer_libbacktrace.cc | 79 ++++++++++++++++++- .../sanitizer_symbolizer_libbacktrace.h | 2 + .../sanitizer_symbolizer_posix_libcdep.cc | 5 ++ 13 files changed, 180 insertions(+), 11 deletions(-) diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index 66a81e4f1b2..30a26bcd4ef 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,5 +1,39 @@ 2014-01-09 Jakub Jelinek + * sanitizer_common/sanitizer_symbolizer_libbacktrace.h + (LibbacktraceSymbolizer::Demangle): New declaration. + * sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc + (POSIXSymbolizer::Demangle): Use libbacktrace_symbolizer_'s Demangle + method if possible. + * sanitizer_common/sanitizer_symbolizer_libbacktrace.cc: Include + "demangle.h" if SANITIZE_CP_DEMANGLE is defined. + (struct CplusV3DemangleData): New type. + (CplusV3DemangleCallback, CplusV3Demangle): New functions. + (SymbolizeCodePCInfoCallback, SymbolizeCodeCallback, + SymbolizeDataCallback): Use CplusV3Demangle. + * sanitizer_common/Makefile.am (AM_CXXFLAGS): Add + -DSANITIZE_CP_DEMANGLE and -I $(top_srcdir)/../include. + * libbacktrace/backtrace-rename.h (cplus_demangle_builtin_types, + cplus_demangle_fill_ctor, cplus_demangle_fill_dtor, + cplus_demangle_fill_extended_operator, cplus_demangle_fill_name, + cplus_demangle_init_info, cplus_demangle_mangled_name, + cplus_demangle_operators, cplus_demangle_print, + cplus_demangle_print_callback, cplus_demangle_type, cplus_demangle_v3, + cplus_demangle_v3_callback, is_gnu_v3_mangled_ctor, + is_gnu_v3_mangled_dtor, java_demangle_v3, java_demangle_v3_callback): + Define. + (__asan_internal_memcmp, __asan_internal_strncmp): New prototypes. + (memcmp, strncmp): Redefine. + * libbacktrace/Makefile.am (libsanitizer_libbacktrace_la_SOURCES): Add + ../../libiberty/cp-demangle.c. + * libbacktrace/bridge.cc (__asan_internal_memcmp, + __asan_internal_strncmp): New functions. + * sanitizer_common/Makefile.in: Regenerated. + * libbacktrace/Makefile.in: Regenerated. + * configure: Regenerated. + * configure.ac: Regenerated. + * config.h.in: Regenerated. + * sanitizer_common/Makefile.am (AM_CPPFLAGS): Add -isystem $(top_srcdir)/include/system. * sanitizer_common/Makefile.in: Regenerated. diff --git a/libsanitizer/config.h.in b/libsanitizer/config.h.in index bb4bb8a3f8b..e4b2786324e 100644 --- a/libsanitizer/config.h.in +++ b/libsanitizer/config.h.in @@ -3,6 +3,9 @@ /* ELF size: 32 or 64 */ #undef BACKTRACE_ELF_SIZE +/* Define to 1 if you have the header file. */ +#undef HAVE_ALLOCA_H + /* Define to 1 if you have the __atomic functions */ #undef HAVE_ATOMIC_FUNCTIONS diff --git a/libsanitizer/configure b/libsanitizer/configure index bb20f1242a9..c20735921ef 100755 --- a/libsanitizer/configure +++ b/libsanitizer/configure @@ -16134,12 +16134,14 @@ ac_config_commands="$ac_config_commands gstdint.h" -for ac_header in sys/mman.h +for ac_header in sys/mman.h alloca.h do : - ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_mman_h" = x""yes; then : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_SYS_MMAN_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac index ab4b216a351..c4641d47286 100644 --- a/libsanitizer/configure.ac +++ b/libsanitizer/configure.ac @@ -208,7 +208,7 @@ AC_SUBST(BACKTRACE_SUPPORTED) GCC_HEADER_STDINT(gstdint.h) -AC_CHECK_HEADERS(sys/mman.h) +AC_CHECK_HEADERS(sys/mman.h alloca.h) if test "$ac_cv_header_sys_mman_h" = "no"; then have_mmap=no else diff --git a/libsanitizer/libbacktrace/Makefile.am b/libsanitizer/libbacktrace/Makefile.am index bde141cadd6..39c91aa62b8 100644 --- a/libsanitizer/libbacktrace/Makefile.am +++ b/libsanitizer/libbacktrace/Makefile.am @@ -51,6 +51,7 @@ libsanitizer_libbacktrace_la_SOURCES = \ ../../libbacktrace/internal.h \ ../../libbacktrace/posix.c \ ../../libbacktrace/state.c \ + ../../libiberty/cp-demangle.c \ bridge.cc FORMAT_FILES = \ diff --git a/libsanitizer/libbacktrace/Makefile.in b/libsanitizer/libbacktrace/Makefile.in index efbf6188d38..3dca45b6e83 100644 --- a/libsanitizer/libbacktrace/Makefile.in +++ b/libsanitizer/libbacktrace/Makefile.in @@ -90,7 +90,7 @@ CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = am_libsanitizer_libbacktrace_la_OBJECTS = atomic.lo dwarf.lo \ - fileline.lo posix.lo state.lo bridge.lo + fileline.lo posix.lo state.lo cp-demangle.lo bridge.lo libsanitizer_libbacktrace_la_OBJECTS = \ $(am_libsanitizer_libbacktrace_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) @@ -280,6 +280,7 @@ libsanitizer_libbacktrace_la_SOURCES = \ ../../libbacktrace/internal.h \ ../../libbacktrace/posix.c \ ../../libbacktrace/state.c \ + ../../libiberty/cp-demangle.c \ bridge.cc FORMAT_FILES = \ @@ -362,6 +363,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atomic.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bridge.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cp-demangle.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileline.Plo@am__quote@ @@ -428,6 +430,13 @@ state.lo: ../../libbacktrace/state.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o state.lo `test -f '../../libbacktrace/state.c' || echo '$(srcdir)/'`../../libbacktrace/state.c +cp-demangle.lo: ../../libiberty/cp-demangle.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cp-demangle.lo -MD -MP -MF $(DEPDIR)/cp-demangle.Tpo -c -o cp-demangle.lo `test -f '../../libiberty/cp-demangle.c' || echo '$(srcdir)/'`../../libiberty/cp-demangle.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/cp-demangle.Tpo $(DEPDIR)/cp-demangle.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../libiberty/cp-demangle.c' object='cp-demangle.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cp-demangle.lo `test -f '../../libiberty/cp-demangle.c' || echo '$(srcdir)/'`../../libiberty/cp-demangle.c + elf.lo: ../../libbacktrace/elf.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT elf.lo -MD -MP -MF $(DEPDIR)/elf.Tpo -c -o elf.lo `test -f '../../libbacktrace/elf.c' || echo '$(srcdir)/'`../../libbacktrace/elf.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/elf.Tpo $(DEPDIR)/elf.Plo diff --git a/libsanitizer/libbacktrace/backtrace-rename.h b/libsanitizer/libbacktrace/backtrace-rename.h index 08402c8f8c6..af8f36bd2d3 100644 --- a/libsanitizer/libbacktrace/backtrace-rename.h +++ b/libsanitizer/libbacktrace/backtrace-rename.h @@ -14,25 +14,49 @@ #define backtrace_vector_grow __asan_backtrace_vector_grow #define backtrace_vector_release __asan_backtrace_vector_release +#define cplus_demangle_builtin_types __asan_cplus_demangle_builtin_types +#define cplus_demangle_fill_ctor __asan_cplus_demangle_fill_ctor +#define cplus_demangle_fill_dtor __asan_cplus_demangle_fill_dtor +#define cplus_demangle_fill_extended_operator __asan_cplus_demangle_fill_extended_operator +#define cplus_demangle_fill_name __asan_cplus_demangle_fill_name +#define cplus_demangle_init_info __asan_cplus_demangle_init_info +#define cplus_demangle_mangled_name __asan_cplus_demangle_mangled_name +#define cplus_demangle_operators __asan_cplus_demangle_operators +#define cplus_demangle_print __asan_cplus_demangle_print +#define cplus_demangle_print_callback __asan_cplus_demangle_print_callback +#define cplus_demangle_type __asan_cplus_demangle_type +#define cplus_demangle_v3 __asan_cplus_demangle_v3 +#define cplus_demangle_v3_callback __asan_cplus_demangle_v3_callback +#define is_gnu_v3_mangled_ctor __asan_is_gnu_v3_mangled_ctor +#define is_gnu_v3_mangled_dtor __asan_is_gnu_v3_mangled_dtor +#define java_demangle_v3 __asan_java_demangle_v3 +#define java_demangle_v3_callback __asan_java_demangle_v3_callback + #ifndef __cplusplus #include extern void *__asan_internal_memcpy (void *, const void *, size_t); extern void *__asan_internal_memset (void *, int, size_t); +extern int __asan_internal_memcmp (const void *, const void *, size_t); extern int __asan_internal_strcmp (const char *, const char *); +extern int __asan_internal_strncmp (const char *, const char *, size_t); extern size_t __asan_internal_strlen (const char *); extern size_t __asan_internal_strnlen (const char *, size_t); #undef memcpy #undef memset +#undef memcmp #undef strcmp +#undef strncmp #undef strlen #undef strnlen #define memcpy(x,y,z) __asan_internal_memcpy (x, y, z) #define memset(x,y,z) __asan_internal_memset (x, y, z) +#define memcmp(x,y,z) __asan_internal_memcmp (x, y, z) #define strcmp(x,y) __asan_internal_strcmp (x, y) +#define strncmp(x,y,z) __asan_internal_strncmp (x, y, z) #define strlen(x) __asan_internal_strlen (x) #ifdef HAVE_DECL_STRNLEN #define strnlen(x,y) __asan_internal_strnlen (x, y) diff --git a/libsanitizer/libbacktrace/bridge.cc b/libsanitizer/libbacktrace/bridge.cc index 3f95898aa09..d553c6617d0 100644 --- a/libsanitizer/libbacktrace/bridge.cc +++ b/libsanitizer/libbacktrace/bridge.cc @@ -51,12 +51,24 @@ __asan_internal_memset (void *dest, int c, size_t n) return __sanitizer::internal_memset (dest, c, n); } +int +__asan_internal_memcmp (const void *s1, const void *s2, size_t n) +{ + return __sanitizer::internal_memcmp (s1, s2, n); +} + int __asan_internal_strcmp (const char *s1, const char *s2) { return __sanitizer::internal_strcmp (s1, s2); } +int +__asan_internal_strncmp (const char *s1, const char *s2, size_t n) +{ + return __sanitizer::internal_strncmp (s1, s2, n); +} + size_t __asan_internal_strlen (const char *str) { diff --git a/libsanitizer/sanitizer_common/Makefile.am b/libsanitizer/sanitizer_common/Makefile.am index 11af196196c..8e9038dc8cf 100644 --- a/libsanitizer/sanitizer_common/Makefile.am +++ b/libsanitizer/sanitizer_common/Makefile.am @@ -7,8 +7,10 @@ DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) if LIBBACKTRACE_SUPPORTED -AM_CXXFLAGS += -DSANITIZER_LIBBACKTRACE -I $(top_srcdir)/../libbacktrace \ +AM_CXXFLAGS += -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ + -I $(top_srcdir)/../libbacktrace \ -I $(top_builddir)/libbacktrace \ + -I $(top_srcdir)/../include \ -include $(top_srcdir)/libbacktrace/backtrace-rename.h endif ACLOCAL_AMFLAGS = -I m4 diff --git a/libsanitizer/sanitizer_common/Makefile.in b/libsanitizer/sanitizer_common/Makefile.in index e5dc5be3812..e9fd115e976 100644 --- a/libsanitizer/sanitizer_common/Makefile.in +++ b/libsanitizer/sanitizer_common/Makefile.in @@ -35,8 +35,10 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = -DSANITIZER_LIBBACKTRACE -I $(top_srcdir)/../libbacktrace \ +@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../libbacktrace \ @LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_builddir)/libbacktrace \ +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../include \ @LIBBACKTRACE_SUPPORTED_TRUE@ -include $(top_srcdir)/libbacktrace/backtrace-rename.h subdir = sanitizer_common diff --git a/libsanitizer/sanitizer_common/sanitizer_symbolizer_libbacktrace.cc b/libsanitizer/sanitizer_common/sanitizer_symbolizer_libbacktrace.cc index 5654d1de7d4..3023002af47 100644 --- a/libsanitizer/sanitizer_common/sanitizer_symbolizer_libbacktrace.cc +++ b/libsanitizer/sanitizer_common/sanitizer_symbolizer_libbacktrace.cc @@ -20,6 +20,10 @@ # include "backtrace-supported.h" # if SANITIZER_POSIX && BACKTRACE_SUPPORTED && !BACKTRACE_USES_MALLOC # include "backtrace.h" +# if SANITIZER_CP_DEMANGLE +# undef ARRAY_SIZE +# include "demangle.h" +# endif # else # define SANITIZER_LIBBACKTRACE 0 # endif @@ -31,6 +35,60 @@ namespace __sanitizer { namespace { +#if SANITIZER_CP_DEMANGLE +struct CplusV3DemangleData { + char *buf; + uptr size, allocated; +}; + +extern "C" { +static void CplusV3DemangleCallback(const char *s, size_t l, void *vdata) { + CplusV3DemangleData *data = (CplusV3DemangleData *)vdata; + uptr needed = data->size + l + 1; + if (needed > data->allocated) { + data->allocated *= 2; + if (needed > data->allocated) + data->allocated = needed; + char *buf = (char *)InternalAlloc(data->allocated); + if (data->buf) { + internal_memcpy(buf, data->buf, data->size); + InternalFree(data->buf); + } + data->buf = buf; + } + internal_memcpy(data->buf + data->size, s, l); + data->buf[data->size + l] = '\0'; + data->size += l; +} +} // extern "C" + +char *CplusV3Demangle(const char *name, bool always_alloc) { + CplusV3DemangleData data; + data.buf = 0; + data.size = 0; + data.allocated = 0; + if (cplus_demangle_v3_callback(name, DMGL_PARAMS | DMGL_ANSI, + CplusV3DemangleCallback, &data)) { + if (data.size + 64 > data.allocated) + return data.buf; + char *buf = internal_strdup(data.buf); + InternalFree(data.buf); + return buf; + } + if (data.buf) + InternalFree(data.buf); + if (always_alloc) + return internal_strdup(name); + return 0; +} +#else +const char *CplusV3Demangle(const char *name, bool always_alloc) { + if (always_alloc) + return internal_strdup(name); + return 0; +} +#endif + struct SymbolizeCodeData { AddressInfo *frames; uptr n_frames; @@ -49,7 +107,7 @@ static int SymbolizeCodePCInfoCallback(void *vdata, uintptr_t addr, info->Clear(); info->FillAddressAndModuleInfo(addr, cdata->module_name, cdata->module_offset); - info->function = internal_strdup(function); + info->function = CplusV3Demangle(function, true); if (filename) info->file = internal_strdup(filename); info->line = lineno; @@ -67,7 +125,7 @@ static void SymbolizeCodeCallback(void *vdata, uintptr_t addr, info->Clear(); info->FillAddressAndModuleInfo(addr, cdata->module_name, cdata->module_offset); - info->function = internal_strdup(symname); + info->function = CplusV3Demangle(symname, true); cdata->n_frames = 1; } } @@ -76,7 +134,7 @@ static void SymbolizeDataCallback(void *vdata, uintptr_t, const char *symname, uintptr_t symval, uintptr_t symsize) { DataInfo *info = (DataInfo *)vdata; if (symname && symval) { - info->name = internal_strdup(symname); + info->name = CplusV3Demangle(symname, true); info->start = symval; info->size = symsize; } @@ -121,6 +179,17 @@ bool LibbacktraceSymbolizer::SymbolizeData(DataInfo *info) { return true; } +const char *LibbacktraceSymbolizer::Demangle(const char *name) { +#if SANITIZER_CP_DEMANGLE + const char *demangled = CplusV3Demangle(name, false); + if (demangled) + return demangled; + return name; +#else + return 0; +#endif +} + #else // SANITIZER_LIBBACKTRACE LibbacktraceSymbolizer *LibbacktraceSymbolizer::get(LowLevelAllocator *alloc) { @@ -139,6 +208,10 @@ bool LibbacktraceSymbolizer::SymbolizeData(DataInfo *info) { return false; } +const char *LibbacktraceSymbolizer::Demangle(const char *name) { + return 0; +} + #endif // SANITIZER_LIBBACKTRACE } // namespace __sanitizer diff --git a/libsanitizer/sanitizer_common/sanitizer_symbolizer_libbacktrace.h b/libsanitizer/sanitizer_common/sanitizer_symbolizer_libbacktrace.h index f09cea51268..05f0558c3d8 100644 --- a/libsanitizer/sanitizer_common/sanitizer_symbolizer_libbacktrace.h +++ b/libsanitizer/sanitizer_common/sanitizer_symbolizer_libbacktrace.h @@ -29,6 +29,8 @@ class LibbacktraceSymbolizer { bool SymbolizeData(DataInfo *info); + const char *Demangle(const char *name); + private: explicit LibbacktraceSymbolizer(void *state) : state_(state) {} diff --git a/libsanitizer/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc index 9f34b646217..7aead970382 100644 --- a/libsanitizer/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc +++ b/libsanitizer/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc @@ -513,6 +513,11 @@ class POSIXSymbolizer : public Symbolizer { SymbolizerScope sym_scope(this); if (internal_symbolizer_ != 0) return internal_symbolizer_->Demangle(name); + if (libbacktrace_symbolizer_ != 0) { + const char *demangled = libbacktrace_symbolizer_->Demangle(name); + if (demangled) + return demangled; + } return DemangleCXXABI(name); }