Skip to content

Commit f6ea869

Browse files
committed
[Sanitizers][Darwin] In DlAddrSymbolizer, return only the module file name instead of the comlpete module path during symbolication.
rdar://108858834 Differential Revision: https://reviews.llvm.org/D152029
1 parent 9a795f0 commit f6ea869

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ bool DlAddrSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) {
4141
stack->info.function_offset = addr - sym_addr;
4242
}
4343

44+
if (info.dli_fname) {
45+
if (auto *last_occurence = internal_strrchr(info.dli_fname, '/')) {
46+
stack->info.module = internal_strdup(last_occurence + 1);
47+
}
48+
}
49+
4450
const char *demangled = DemangleSwiftAndCXX(info.dli_sname);
4551
if (!demangled) return false;
4652
stack->info.function = internal_strdup(demangled);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clangxx %s -O0 -o %t
2+
// RUN: %env_tool_opts=external_symbolizer_path= %run %t 2>&1 | FileCheck %s
3+
#include <sanitizer/common_interface_defs.h>
4+
#include <stdio.h>
5+
6+
int main() {
7+
//CHECK: #0{{.*}}
8+
//CHECK: #1{{.*}}(symbolizer-file-name-dladdr.cpp.tmp
9+
__sanitizer_print_stack_trace();
10+
return 0;
11+
}

0 commit comments

Comments
 (0)