2019-08-14 10:47:11 +02:00
|
|
|
//===-- sanitizer_symbolizer_libbacktrace.cpp -----------------------------===//
|
2013-12-05 10:18:38 +01:00
|
|
|
//
|
2019-08-14 10:47:11 +02:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-12-05 10:18:38 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is shared between AddressSanitizer and ThreadSanitizer
|
|
|
|
// run-time libraries.
|
|
|
|
// Libbacktrace implementation of symbolizer parts.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "sanitizer_platform.h"
|
|
|
|
|
|
|
|
#include "sanitizer_internal_defs.h"
|
|
|
|
#include "sanitizer_symbolizer.h"
|
|
|
|
#include "sanitizer_symbolizer_libbacktrace.h"
|
|
|
|
|
|
|
|
#if SANITIZER_LIBBACKTRACE
|
|
|
|
# include "backtrace-supported.h"
|
|
|
|
# if SANITIZER_POSIX && BACKTRACE_SUPPORTED && !BACKTRACE_USES_MALLOC
|
|
|
|
# include "backtrace.h"
|
* 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
2014-01-09 19:16:40 +01:00
|
|
|
# if SANITIZER_CP_DEMANGLE
|
|
|
|
# undef ARRAY_SIZE
|
|
|
|
# include "demangle.h"
|
|
|
|
# endif
|
2013-12-05 10:18:38 +01:00
|
|
|
# else
|
|
|
|
# define SANITIZER_LIBBACKTRACE 0
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace __sanitizer {
|
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
static char *DemangleAlloc(const char *name, bool always_alloc);
|
|
|
|
|
2013-12-05 10:18:38 +01:00
|
|
|
#if SANITIZER_LIBBACKTRACE
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
# if SANITIZER_CP_DEMANGLE
|
* 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
2014-01-09 19:16:40 +01:00
|
|
|
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"
|
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
char *CplusV3Demangle(const char *name) {
|
* 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
2014-01-09 19:16:40 +01:00
|
|
|
CplusV3DemangleData data;
|
|
|
|
data.buf = 0;
|
|
|
|
data.size = 0;
|
|
|
|
data.allocated = 0;
|
|
|
|
if (cplus_demangle_v3_callback(name, DMGL_PARAMS | DMGL_ANSI,
|
2014-05-22 09:09:21 +02:00
|
|
|
CplusV3DemangleCallback, &data)) {
|
* 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
2014-01-09 19:16:40 +01:00
|
|
|
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);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-22 09:09:21 +02:00
|
|
|
# endif // SANITIZER_CP_DEMANGLE
|
* 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
2014-01-09 19:16:40 +01:00
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
struct SymbolizeCodeCallbackArg {
|
|
|
|
SymbolizedStack *first;
|
|
|
|
SymbolizedStack *last;
|
|
|
|
uptr frames_symbolized;
|
|
|
|
|
|
|
|
AddressInfo *get_new_frame(uintptr_t addr) {
|
|
|
|
CHECK(last);
|
|
|
|
if (frames_symbolized > 0) {
|
|
|
|
SymbolizedStack *cur = SymbolizedStack::New(addr);
|
|
|
|
AddressInfo *info = &cur->info;
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
info->FillModuleInfo(first->info.module, first->info.module_offset,
|
|
|
|
first->info.module_arch);
|
2015-10-21 09:32:45 +02:00
|
|
|
last->next = cur;
|
|
|
|
last = cur;
|
|
|
|
}
|
|
|
|
CHECK_EQ(addr, first->info.address);
|
|
|
|
CHECK_EQ(addr, last->info.address);
|
|
|
|
return &last->info;
|
|
|
|
}
|
2013-12-05 10:18:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
static int SymbolizeCodePCInfoCallback(void *vdata, uintptr_t addr,
|
|
|
|
const char *filename, int lineno,
|
|
|
|
const char *function) {
|
2015-10-21 09:32:45 +02:00
|
|
|
SymbolizeCodeCallbackArg *cdata = (SymbolizeCodeCallbackArg *)vdata;
|
2013-12-05 10:18:38 +01:00
|
|
|
if (function) {
|
2015-10-21 09:32:45 +02:00
|
|
|
AddressInfo *info = cdata->get_new_frame(addr);
|
|
|
|
info->function = DemangleAlloc(function, /*always_alloc*/ true);
|
2013-12-05 10:18:38 +01:00
|
|
|
if (filename)
|
|
|
|
info->file = internal_strdup(filename);
|
|
|
|
info->line = lineno;
|
2015-10-21 09:32:45 +02:00
|
|
|
cdata->frames_symbolized++;
|
2013-12-05 10:18:38 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SymbolizeCodeCallback(void *vdata, uintptr_t addr,
|
|
|
|
const char *symname, uintptr_t, uintptr_t) {
|
2015-10-21 09:32:45 +02:00
|
|
|
SymbolizeCodeCallbackArg *cdata = (SymbolizeCodeCallbackArg *)vdata;
|
2013-12-05 10:18:38 +01:00
|
|
|
if (symname) {
|
2015-10-21 09:32:45 +02:00
|
|
|
AddressInfo *info = cdata->get_new_frame(addr);
|
|
|
|
info->function = DemangleAlloc(symname, /*always_alloc*/ true);
|
|
|
|
cdata->frames_symbolized++;
|
2013-12-05 10:18:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SymbolizeDataCallback(void *vdata, uintptr_t, const char *symname,
|
|
|
|
uintptr_t symval, uintptr_t symsize) {
|
|
|
|
DataInfo *info = (DataInfo *)vdata;
|
|
|
|
if (symname && symval) {
|
2015-10-21 09:32:45 +02:00
|
|
|
info->name = DemangleAlloc(symname, /*always_alloc*/ true);
|
2013-12-05 10:18:38 +01:00
|
|
|
info->start = symval;
|
|
|
|
info->size = symsize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ErrorCallback(void *, const char *, int) {}
|
|
|
|
} // extern "C"
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
LibbacktraceSymbolizer *LibbacktraceSymbolizer::get(LowLevelAllocator *alloc) {
|
|
|
|
// State created in backtrace_create_state is leaked.
|
|
|
|
void *state = (void *)(backtrace_create_state("/proc/self/exe", 0,
|
|
|
|
ErrorCallback, NULL));
|
|
|
|
if (!state)
|
|
|
|
return 0;
|
|
|
|
return new(*alloc) LibbacktraceSymbolizer(state);
|
|
|
|
}
|
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
bool LibbacktraceSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) {
|
|
|
|
SymbolizeCodeCallbackArg data;
|
|
|
|
data.first = stack;
|
|
|
|
data.last = stack;
|
|
|
|
data.frames_symbolized = 0;
|
2013-12-05 10:18:38 +01:00
|
|
|
backtrace_pcinfo((backtrace_state *)state_, addr, SymbolizeCodePCInfoCallback,
|
|
|
|
ErrorCallback, &data);
|
2015-10-21 09:32:45 +02:00
|
|
|
if (data.frames_symbolized > 0)
|
|
|
|
return true;
|
2013-12-05 10:18:38 +01:00
|
|
|
backtrace_syminfo((backtrace_state *)state_, addr, SymbolizeCodeCallback,
|
|
|
|
ErrorCallback, &data);
|
2015-10-21 09:32:45 +02:00
|
|
|
return (data.frames_symbolized > 0);
|
2013-12-05 10:18:38 +01:00
|
|
|
}
|
|
|
|
|
2014-12-16 12:35:34 +01:00
|
|
|
bool LibbacktraceSymbolizer::SymbolizeData(uptr addr, DataInfo *info) {
|
|
|
|
backtrace_syminfo((backtrace_state *)state_, addr, SymbolizeDataCallback,
|
|
|
|
ErrorCallback, info);
|
2013-12-05 10:18:38 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else // SANITIZER_LIBBACKTRACE
|
|
|
|
|
|
|
|
LibbacktraceSymbolizer *LibbacktraceSymbolizer::get(LowLevelAllocator *alloc) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
bool LibbacktraceSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) {
|
2013-12-05 10:18:38 +01:00
|
|
|
(void)state_;
|
2015-10-21 09:32:45 +02:00
|
|
|
return false;
|
2013-12-05 10:18:38 +01:00
|
|
|
}
|
|
|
|
|
2014-12-16 12:35:34 +01:00
|
|
|
bool LibbacktraceSymbolizer::SymbolizeData(uptr addr, DataInfo *info) {
|
2013-12-05 10:18:38 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
#endif // SANITIZER_LIBBACKTRACE
|
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
static char *DemangleAlloc(const char *name, bool always_alloc) {
|
2014-05-22 09:09:21 +02:00
|
|
|
#if SANITIZER_LIBBACKTRACE && SANITIZER_CP_DEMANGLE
|
|
|
|
if (char *demangled = CplusV3Demangle(name))
|
|
|
|
return demangled;
|
|
|
|
#endif
|
|
|
|
if (always_alloc)
|
|
|
|
return internal_strdup(name);
|
* 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
2014-01-09 19:16:40 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
const char *LibbacktraceSymbolizer::Demangle(const char *name) {
|
|
|
|
return DemangleAlloc(name, /*always_alloc*/ false);
|
|
|
|
}
|
|
|
|
|
2013-12-05 10:18:38 +01:00
|
|
|
} // namespace __sanitizer
|