summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/asan_stack.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/asan/asan_stack.cc')
-rw-r--r--compiler-rt/lib/asan/asan_stack.cc22
1 files changed, 17 insertions, 5 deletions
diff --git a/compiler-rt/lib/asan/asan_stack.cc b/compiler-rt/lib/asan/asan_stack.cc
index d6103c2c98f..703cc692bc1 100644
--- a/compiler-rt/lib/asan/asan_stack.cc
+++ b/compiler-rt/lib/asan/asan_stack.cc
@@ -26,6 +26,13 @@ ASAN_USE_EXTERNAL_SYMBOLIZER(const void *pc, char *out, int out_size);
namespace __asan {
+static const char *StripPathPrefix(const char *filepath) {
+ const char *path_prefix = flags()->strip_path_prefix;
+ if (filepath == internal_strstr(filepath, path_prefix))
+ return filepath + internal_strlen(path_prefix);
+ return filepath;
+}
+
// ----------------------- AsanStackTrace ----------------------------- {{{1
// PCs in stack traces are actually the return addresses, that is,
// addresses of the next instructions after the call. That's why we
@@ -46,7 +53,10 @@ void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
pc = patch_pc(pc);
char buff[4096];
ASAN_USE_EXTERNAL_SYMBOLIZER((void*)pc, buff, sizeof(buff));
- AsanPrintf(" #%zu 0x%zx %s\n", i, pc, buff);
+ // We can't know anything about the string returned by external
+ // symbolizer, but if it starts with filename, try to strip path prefix
+ // from it.
+ AsanPrintf(" #%zu 0x%zx %s\n", i, pc, StripPathPrefix(buff));
}
}
@@ -72,9 +82,11 @@ void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
AsanPrintf(" in %s", info.function);
}
if (info.file) {
- AsanPrintf(" %s:%d:%d", info.file, info.line, info.column);
+ AsanPrintf(" %s:%d:%d", StripPathPrefix(info.file), info.line,
+ info.column);
} else if (info.module) {
- AsanPrintf(" (%s+0x%zx)", info.module, info.module_offset);
+ AsanPrintf(" (%s+0x%zx)", StripPathPrefix(info.module),
+ info.module_offset);
}
AsanPrintf("\n");
info.Clear();
@@ -85,8 +97,8 @@ void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
char filename[4096];
if (proc_maps.GetObjectNameAndOffset(pc, &offset,
filename, sizeof(filename))) {
- AsanPrintf(" #%zu 0x%zx (%s+0x%zx)\n", frame_num, pc, filename,
- offset);
+ AsanPrintf(" #%zu 0x%zx (%s+0x%zx)\n",
+ frame_num, pc, StripPathPrefix(filename), offset);
} else {
AsanPrintf(" #%zu 0x%zx\n", frame_num, pc);
}
OpenPOWER on IntegriCloud