Skip to content

Commit ea20b93

Browse files
Merge pull request #6975 from usama54321/sanitizers-dladdr-symbolizer-module-path-108858834
[Sanitizers][Darwin] In DlAddrSymbolizer, return only the module file…
2 parents 763418d + 21fccb4 commit ea20b93

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)