[llvm-commits] [compiler-rt] r163297 - in /compiler-rt/trunk/lib/tsan/rtl: tsan_flags.cc tsan_flags.h tsan_rtl.cc tsan_symbolize.cc
Alexey Samsonov
samsonov at google.com
Thu Sep 6 01:48:44 PDT 2012
Author: samsonov
Date: Thu Sep 6 03:48:43 2012
New Revision: 163297
URL: http://llvm.org/viewvc/llvm-project?rev=163297&view=rev
Log:
[TSan] add support for running external symbolizer other than addr2line (for testing purposes)
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc?rev=163297&r1=163296&r2=163297&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc Thu Sep 6 03:48:43 2012
@@ -53,7 +53,7 @@
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 @@
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
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h?rev=163297&r1=163296&r2=163297&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h Thu Sep 6 03:48:43 2012
@@ -62,8 +62,8 @@
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();
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=163297&r1=163296&r2=163297&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Thu Sep 6 03:48:43 2012
@@ -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 @@
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());
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc?rev=163297&r1=163296&r2=163297&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc Thu Sep 6 03:48:43 2012
@@ -31,8 +31,15 @@
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 @@
}
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++)
More information about the llvm-commits
mailing list