Files
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
cmake
docs
include
lib
BlocksRuntime
asan
builtins
cfi
dfsan
esan
fuzzer
hwasan
interception
lsan
msan
profile
safestack
sanitizer_common
scudo
stats
tsan
benchmarks
dd
go
rtl
tsan.syms.extra
tsan_clock.cc
tsan_clock.h
tsan_debugging.cc
tsan_defs.h
tsan_dense_alloc.h
tsan_external.cc
tsan_fd.cc
tsan_fd.h
tsan_flags.cc
tsan_flags.h
tsan_flags.inc
tsan_ignoreset.cc
tsan_ignoreset.h
tsan_interceptors.cc
tsan_interceptors.h
tsan_interceptors_mac.cc
tsan_interface.cc
tsan_interface.h
tsan_interface_ann.cc
tsan_interface_ann.h
tsan_interface_atomic.cc
tsan_interface_inl.h
tsan_interface_java.cc
tsan_interface_java.h
tsan_libdispatch_mac.cc
tsan_malloc_mac.cc
tsan_md5.cc
tsan_mman.cc
tsan_mman.h
tsan_mutex.cc
tsan_mutex.h
tsan_mutexset.cc
tsan_mutexset.h
tsan_new_delete.cc
tsan_platform.h
tsan_platform_linux.cc
tsan_platform_mac.cc
tsan_platform_posix.cc
tsan_platform_windows.cc
tsan_ppc_regs.h
tsan_preinit.cc
tsan_report.cc
tsan_report.h
tsan_rtl.cc
tsan_rtl.h
tsan_rtl_aarch64.S
tsan_rtl_amd64.S
tsan_rtl_mips64.S
tsan_rtl_mutex.cc
tsan_rtl_ppc64.S
tsan_rtl_proc.cc
tsan_rtl_report.cc
tsan_rtl_thread.cc
tsan_stack_trace.cc
tsan_stack_trace.h
tsan_stat.cc
tsan_stat.h
tsan_suppressions.cc
tsan_suppressions.h
tsan_symbolize.cc
tsan_symbolize.h
tsan_sync.cc
tsan_sync.h
tsan_trace.h
tsan_update_shadow_word_inl.h
tests
.clang-format
CMakeLists.txt
analyze_libtsan.sh
check_analyze.sh
check_cmake.sh
ubsan
ubsan_minimal
xray
CMakeLists.txt
test
unittests
www
.arcconfig
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
README.txt
eng
libcxx
libcxxabi
libunwind
lld
lldb
llvm
nuget
openmp
polly
Directory.Build.props
Directory.Build.targets
NuGet.config
azure-pipelines.yml
build.cmd
build.sh
dir.common.props
global.json
llvm.proj
mxe-Win64.cmake.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/external/llvm-project/compiler-rt/lib/tsan/rtl/tsan_symbolize.cc

83 lines
2.5 KiB
C++
Raw Normal View History

//===-- tsan_symbolize.cc -------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of ThreadSanitizer (TSan), a race detector.
//
//===----------------------------------------------------------------------===//
#include "tsan_symbolize.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_symbolizer.h"
#include "tsan_flags.h"
#include "tsan_report.h"
#include "tsan_rtl.h"
namespace __tsan {
void EnterSymbolizer() {
ThreadState *thr = cur_thread();
CHECK(!thr->in_symbolizer);
thr->in_symbolizer = true;
thr->ignore_interceptors++;
}
void ExitSymbolizer() {
ThreadState *thr = cur_thread();
CHECK(thr->in_symbolizer);
thr->in_symbolizer = false;
thr->ignore_interceptors--;
}
// May be overriden by JIT/JAVA/etc,
// whatever produces PCs marked with kExternalPCBit.
SANITIZER_WEAK_DEFAULT_IMPL
bool __tsan_symbolize_external(uptr pc, char *func_buf, uptr func_siz,
char *file_buf, uptr file_siz, int *line,
int *col) {
return false;
}
SymbolizedStack *SymbolizeCode(uptr addr) {
// Check if PC comes from non-native land.
if (addr & kExternalPCBit) {
// Declare static to not consume too much stack space.
// We symbolize reports in a single thread, so this is fine.
static char func_buf[1024];
static char file_buf[1024];
int line, col;
SymbolizedStack *frame = SymbolizedStack::New(addr);
if (__tsan_symbolize_external(addr, func_buf, sizeof(func_buf), file_buf,
sizeof(file_buf), &line, &col)) {
frame->info.function = internal_strdup(func_buf);
frame->info.file = internal_strdup(file_buf);
frame->info.line = line;
frame->info.column = col;
}
return frame;
}
return Symbolizer::GetOrInit()->SymbolizePC(addr);
}
ReportLocation *SymbolizeData(uptr addr) {
DataInfo info;
if (!Symbolizer::GetOrInit()->SymbolizeData(addr, &info))
return 0;
ReportLocation *ent = ReportLocation::New(ReportLocationGlobal);
internal_memcpy(&ent->global, &info, sizeof(info));
return ent;
}
void SymbolizeFlush() {
Symbolizer::GetOrInit()->Flush();
}
} // namespace __tsan