forked from OSchip/llvm-project
[TSan] add support for running external symbolizer other than addr2line (for testing purposes)
llvm-svn: 163297
This commit is contained in:
parent
3ebf2fa654
commit
fdff4a8e0b
|
@ -53,7 +53,7 @@ void InitializeFlags(Flags *f, const char *env) {
|
|||
f->flush_memory_ms = 0;
|
||||
f->stop_on_start = false;
|
||||
f->running_on_valgrind = false;
|
||||
f->use_internal_symbolizer = false;
|
||||
f->external_symbolizer_path = "";
|
||||
|
||||
// Let a frontend override.
|
||||
OverrideFlags(f);
|
||||
|
@ -75,7 +75,7 @@ void InitializeFlags(Flags *f, const char *env) {
|
|||
ParseFlag(env, &f->profile_memory, "profile_memory");
|
||||
ParseFlag(env, &f->flush_memory_ms, "flush_memory_ms");
|
||||
ParseFlag(env, &f->stop_on_start, "stop_on_start");
|
||||
ParseFlag(env, &f->use_internal_symbolizer, "use_internal_symbolizer");
|
||||
ParseFlag(env, &f->external_symbolizer_path, "external_symbolizer_path");
|
||||
}
|
||||
|
||||
} // namespace __tsan
|
||||
|
|
|
@ -62,8 +62,8 @@ struct Flags {
|
|||
bool stop_on_start;
|
||||
// Controls whether RunningOnValgrind() returns true or false.
|
||||
bool running_on_valgrind;
|
||||
// If set, uses in-process symbolizer from common sanitizer runtime.
|
||||
bool use_internal_symbolizer;
|
||||
// Path to external symbolizer.
|
||||
const char *external_symbolizer_path;
|
||||
};
|
||||
|
||||
Flags *flags();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "sanitizer_common/sanitizer_libc.h"
|
||||
#include "sanitizer_common/sanitizer_stackdepot.h"
|
||||
#include "sanitizer_common/sanitizer_placement_new.h"
|
||||
#include "sanitizer_common/sanitizer_symbolizer.h"
|
||||
#include "tsan_defs.h"
|
||||
#include "tsan_platform.h"
|
||||
#include "tsan_rtl.h"
|
||||
|
@ -182,6 +183,11 @@ void Initialize(ThreadState *thr) {
|
|||
InitializeMemoryProfile();
|
||||
InitializeMemoryFlush();
|
||||
|
||||
const char *external_symbolizer = flags()->external_symbolizer_path;
|
||||
if (external_symbolizer != 0 && external_symbolizer[0] != '\0') {
|
||||
InitializeExternalSymbolizer(external_symbolizer);
|
||||
}
|
||||
|
||||
if (ctx->flags.verbosity)
|
||||
TsanPrintf("***** Running under ThreadSanitizer v2 (pid %d) *****\n",
|
||||
GetPid());
|
||||
|
|
|
@ -31,8 +31,15 @@ ReportStack *NewReportStackEntry(uptr addr) {
|
|||
|
||||
static ReportStack *NewReportStackEntry(const AddressInfo &info) {
|
||||
ReportStack *ent = NewReportStackEntry(info.address);
|
||||
if (info.module)
|
||||
ent->module = internal_strdup(info.module);
|
||||
if (info.module) {
|
||||
// Strip module path to make output shorter.
|
||||
const char *short_module_name = internal_strrchr(info.module, '/');
|
||||
if (short_module_name)
|
||||
short_module_name += 1;
|
||||
else
|
||||
short_module_name = info.module;
|
||||
ent->module = internal_strdup(short_module_name);
|
||||
}
|
||||
ent->offset = info.module_offset;
|
||||
if (info.function) {
|
||||
ent->func = internal_strdup(info.function);
|
||||
|
@ -45,7 +52,7 @@ static ReportStack *NewReportStackEntry(const AddressInfo &info) {
|
|||
}
|
||||
|
||||
ReportStack *SymbolizeCode(uptr addr) {
|
||||
if (flags()->use_internal_symbolizer) {
|
||||
if (0 != internal_strcmp(flags()->external_symbolizer_path, "")) {
|
||||
static const uptr kMaxAddrFrames = 16;
|
||||
InternalScopedBuffer<AddressInfo> addr_frames(kMaxAddrFrames);
|
||||
for (uptr i = 0; i < kMaxAddrFrames; i++)
|
||||
|
|
Loading…
Reference in New Issue