2012-11-12 16:53:47 +01:00
|
|
|
//===-- sanitizer_symbolizer.h ----------------------------------*- C++ -*-===//
|
|
|
|
//
|
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
|
2012-11-12 16:53:47 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2013-12-05 10:18:38 +01:00
|
|
|
// Symbolizer is used by sanitizers to map instruction address to a location in
|
|
|
|
// source code at run-time. Symbolizer either uses __sanitizer_symbolize_*
|
|
|
|
// defined in the program, or (if they are missing) tries to find and
|
|
|
|
// launch "llvm-symbolizer" commandline tool in a separate process and
|
|
|
|
// communicate with it.
|
2012-11-12 16:53:47 +01:00
|
|
|
//
|
2013-12-05 10:18:38 +01:00
|
|
|
// Generally we should try to avoid calling system library functions during
|
|
|
|
// symbolization (and use their replacements from sanitizer_libc.h instead).
|
2012-11-12 16:53:47 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SANITIZER_SYMBOLIZER_H
|
|
|
|
#define SANITIZER_SYMBOLIZER_H
|
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
#include "sanitizer_common.h"
|
|
|
|
#include "sanitizer_mutex.h"
|
2019-08-14 10:47:11 +02:00
|
|
|
#include "sanitizer_vector.h"
|
2012-11-12 16:53:47 +01:00
|
|
|
|
|
|
|
namespace __sanitizer {
|
|
|
|
|
|
|
|
struct AddressInfo {
|
2015-10-21 09:32:45 +02:00
|
|
|
// Owns all the string members. Storage for them is
|
|
|
|
// (de)allocated using sanitizer internal allocator.
|
2012-11-12 16:53:47 +01:00
|
|
|
uptr address;
|
2014-05-22 09:09:21 +02:00
|
|
|
|
2012-11-12 16:53:47 +01:00
|
|
|
char *module;
|
|
|
|
uptr module_offset;
|
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
|
|
|
ModuleArch module_arch;
|
2014-05-22 09:09:21 +02:00
|
|
|
|
|
|
|
static const uptr kUnknown = ~(uptr)0;
|
2012-11-12 16:53:47 +01:00
|
|
|
char *function;
|
2014-05-22 09:09:21 +02:00
|
|
|
uptr function_offset;
|
|
|
|
|
2012-11-12 16:53:47 +01:00
|
|
|
char *file;
|
|
|
|
int line;
|
|
|
|
int column;
|
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
AddressInfo();
|
2014-05-22 09:09:21 +02:00
|
|
|
// Deletes all strings and resets all fields.
|
2015-10-21 09:32:45 +02:00
|
|
|
void Clear();
|
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
|
|
|
void FillModuleInfo(const char *mod_name, uptr mod_offset, ModuleArch arch);
|
2015-10-21 09:32:45 +02:00
|
|
|
};
|
2012-11-12 16:53:47 +01:00
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
// Linked list of symbolized frames (each frame is described by AddressInfo).
|
|
|
|
struct SymbolizedStack {
|
|
|
|
SymbolizedStack *next;
|
|
|
|
AddressInfo info;
|
|
|
|
static SymbolizedStack *New(uptr addr);
|
|
|
|
// Deletes current, and all subsequent frames in the linked list.
|
|
|
|
// The object cannot be accessed after the call to this function.
|
|
|
|
void ClearAll();
|
|
|
|
|
|
|
|
private:
|
|
|
|
SymbolizedStack();
|
2012-11-12 16:53:47 +01:00
|
|
|
};
|
|
|
|
|
2014-11-13 21:41:38 +01:00
|
|
|
// For now, DataInfo is used to describe global variable.
|
2013-01-23 12:41:33 +01:00
|
|
|
struct DataInfo {
|
2015-10-21 09:32:45 +02:00
|
|
|
// Owns all the string members. Storage for them is
|
|
|
|
// (de)allocated using sanitizer internal allocator.
|
2013-01-23 12:41:33 +01:00
|
|
|
char *module;
|
|
|
|
uptr module_offset;
|
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
|
|
|
ModuleArch module_arch;
|
|
|
|
|
2016-11-08 23:04:09 +01:00
|
|
|
char *file;
|
|
|
|
uptr line;
|
2013-01-23 12:41:33 +01:00
|
|
|
char *name;
|
|
|
|
uptr start;
|
|
|
|
uptr size;
|
2014-11-13 21:41:38 +01:00
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
DataInfo();
|
|
|
|
void Clear();
|
2013-01-23 12:41:33 +01:00
|
|
|
};
|
|
|
|
|
2019-08-14 10:47:11 +02:00
|
|
|
struct LocalInfo {
|
|
|
|
char *function_name = nullptr;
|
|
|
|
char *name = nullptr;
|
|
|
|
char *decl_file = nullptr;
|
|
|
|
unsigned decl_line = 0;
|
|
|
|
|
|
|
|
bool has_frame_offset = false;
|
|
|
|
bool has_size = false;
|
|
|
|
bool has_tag_offset = false;
|
|
|
|
|
|
|
|
sptr frame_offset;
|
|
|
|
uptr size;
|
|
|
|
uptr tag_offset;
|
|
|
|
|
|
|
|
void Clear();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FrameInfo {
|
|
|
|
char *module;
|
|
|
|
uptr module_offset;
|
|
|
|
ModuleArch module_arch;
|
|
|
|
|
|
|
|
InternalMmapVector<LocalInfo> locals;
|
|
|
|
void Clear();
|
|
|
|
};
|
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
class SymbolizerTool;
|
|
|
|
|
|
|
|
class Symbolizer final {
|
2012-11-12 16:53:47 +01:00
|
|
|
public:
|
2014-09-23 19:59:53 +02:00
|
|
|
/// Initialize and return platform-specific implementation of symbolizer
|
|
|
|
/// (if it wasn't already initialized).
|
2013-12-05 10:18:38 +01:00
|
|
|
static Symbolizer *GetOrInit();
|
2016-11-08 23:04:09 +01:00
|
|
|
static void LateInitialize();
|
2015-10-21 09:32:45 +02:00
|
|
|
// Returns a list of symbolized frames for a given address (containing
|
|
|
|
// all inlined functions, if necessary).
|
|
|
|
SymbolizedStack *SymbolizePC(uptr address);
|
|
|
|
bool SymbolizeData(uptr address, DataInfo *info);
|
2019-08-14 10:47:11 +02:00
|
|
|
bool SymbolizeFrame(uptr address, FrameInfo *info);
|
2015-10-21 09:32:45 +02:00
|
|
|
|
|
|
|
// The module names Symbolizer returns are stable and unique for every given
|
|
|
|
// module. It is safe to store and compare them as pointers.
|
|
|
|
bool GetModuleNameAndOffsetForPC(uptr pc, const char **module_name,
|
|
|
|
uptr *module_address);
|
|
|
|
const char *GetModuleNameForPc(uptr pc) {
|
|
|
|
const char *module_name = nullptr;
|
|
|
|
uptr unused;
|
|
|
|
if (GetModuleNameAndOffsetForPC(pc, &module_name, &unused))
|
|
|
|
return module_name;
|
|
|
|
return nullptr;
|
2013-12-05 10:18:38 +01:00
|
|
|
}
|
2015-10-21 09:32:45 +02:00
|
|
|
|
2013-11-04 22:33:31 +01:00
|
|
|
// Release internal caches (if any).
|
2015-10-21 09:32:45 +02:00
|
|
|
void Flush();
|
2013-11-04 22:33:31 +01:00
|
|
|
// Attempts to demangle the provided C++ mangled name.
|
2015-10-21 09:32:45 +02:00
|
|
|
const char *Demangle(const char *name);
|
2012-11-12 16:53:47 +01:00
|
|
|
|
2013-12-05 10:18:38 +01:00
|
|
|
// Allow user to install hooks that would be called before/after Symbolizer
|
|
|
|
// does the actual file/line info fetching. Specific sanitizers may need this
|
|
|
|
// to distinguish system library calls made in user code from calls made
|
|
|
|
// during in-process symbolization.
|
|
|
|
typedef void (*StartSymbolizationHook)();
|
|
|
|
typedef void (*EndSymbolizationHook)();
|
|
|
|
// May be called at most once.
|
|
|
|
void AddHooks(StartSymbolizationHook start_hook,
|
|
|
|
EndSymbolizationHook end_hook);
|
|
|
|
|
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
|
|
|
void RefreshModules();
|
2016-11-08 23:04:09 +01:00
|
|
|
const LoadedModule *FindModuleForAddress(uptr address);
|
|
|
|
|
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
|
|
|
void InvalidateModuleList();
|
|
|
|
|
2013-12-05 10:18:38 +01:00
|
|
|
private:
|
2015-10-21 09:32:45 +02:00
|
|
|
// GetModuleNameAndOffsetForPC has to return a string to the caller.
|
|
|
|
// Since the corresponding module might get unloaded later, we should create
|
|
|
|
// our owned copies of the strings that we can safely return.
|
|
|
|
// ModuleNameOwner does not provide any synchronization, thus calls to
|
|
|
|
// its method should be protected by |mu_|.
|
|
|
|
class ModuleNameOwner {
|
|
|
|
public:
|
|
|
|
explicit ModuleNameOwner(BlockingMutex *synchronized_by)
|
2018-10-31 12:14:23 +01:00
|
|
|
: last_match_(nullptr), mu_(synchronized_by) {
|
|
|
|
storage_.reserve(kInitialCapacity);
|
|
|
|
}
|
2015-10-21 09:32:45 +02:00
|
|
|
const char *GetOwnedCopy(const char *str);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const uptr kInitialCapacity = 1000;
|
|
|
|
InternalMmapVector<const char*> storage_;
|
|
|
|
const char *last_match_;
|
|
|
|
|
|
|
|
BlockingMutex *mu_;
|
|
|
|
} module_names_;
|
|
|
|
|
2013-12-05 10:18:38 +01:00
|
|
|
/// Platform-specific function for creating a Symbolizer object.
|
2014-09-23 19:59:53 +02:00
|
|
|
static Symbolizer *PlatformInit();
|
2015-10-21 09:32:45 +02:00
|
|
|
|
|
|
|
bool FindModuleNameAndOffsetForAddress(uptr address, const char **module_name,
|
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
|
|
|
uptr *module_offset,
|
|
|
|
ModuleArch *module_arch);
|
2016-11-08 23:04:09 +01:00
|
|
|
ListOfModules modules_;
|
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
|
|
|
ListOfModules fallback_modules_;
|
2015-10-21 09:32:45 +02:00
|
|
|
// If stale, need to reload the modules before looking up addresses.
|
|
|
|
bool modules_fresh_;
|
|
|
|
|
|
|
|
// Platform-specific default demangler, must not return nullptr.
|
|
|
|
const char *PlatformDemangle(const char *name);
|
2013-12-05 10:18:38 +01:00
|
|
|
|
|
|
|
static Symbolizer *symbolizer_;
|
|
|
|
static StaticSpinMutex init_mu_;
|
|
|
|
|
2015-10-21 09:32:45 +02:00
|
|
|
// Mutex locked from public methods of |Symbolizer|, so that the internals
|
|
|
|
// (including individual symbolizer tools and platform-specific methods) are
|
|
|
|
// always synchronized.
|
|
|
|
BlockingMutex mu_;
|
|
|
|
|
|
|
|
IntrusiveList<SymbolizerTool> tools_;
|
|
|
|
|
|
|
|
explicit Symbolizer(IntrusiveList<SymbolizerTool> tools);
|
2013-12-05 10:18:38 +01:00
|
|
|
|
|
|
|
static LowLevelAllocator symbolizer_allocator_;
|
|
|
|
|
|
|
|
StartSymbolizationHook start_hook_;
|
|
|
|
EndSymbolizationHook end_hook_;
|
|
|
|
class SymbolizerScope {
|
|
|
|
public:
|
|
|
|
explicit SymbolizerScope(const Symbolizer *sym);
|
|
|
|
~SymbolizerScope();
|
|
|
|
private:
|
|
|
|
const Symbolizer *sym_;
|
|
|
|
};
|
2020-06-01 21:15:18 +02:00
|
|
|
|
|
|
|
// Calls `LateInitialize()` on all items in `tools_`.
|
|
|
|
void LateInitializeTools();
|
2013-12-05 10:18:38 +01:00
|
|
|
};
|
2012-11-12 16:53:47 +01:00
|
|
|
|
2016-11-08 23:04:09 +01:00
|
|
|
#ifdef SANITIZER_WINDOWS
|
|
|
|
void InitializeDbgHelpIfNeeded();
|
|
|
|
#endif
|
|
|
|
|
2012-11-12 16:53:47 +01:00
|
|
|
} // namespace __sanitizer
|
|
|
|
|
|
|
|
#endif // SANITIZER_SYMBOLIZER_H
|