[compiler-rt] f6ea869 - [Sanitizers][Darwin] In DlAddrSymbolizer, return only the module file name instead of the comlpete module path during symbolication.
usama hameed via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 16:31:52 PDT 2023
Author: usama hameed
Date: 2023-06-05T16:31:33-07:00
New Revision: f6ea869f7c043c70722b8db6be94d9ad4cc9eb92
URL: https://github.com/llvm/llvm-project/commit/f6ea869f7c043c70722b8db6be94d9ad4cc9eb92
DIFF: https://github.com/llvm/llvm-project/commit/f6ea869f7c043c70722b8db6be94d9ad4cc9eb92.diff
LOG: [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
Added:
compiler-rt/test/sanitizer_common/TestCases/Darwin/symbolizer-file-name-dladdr.cpp
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
index a9c958b2d1001..f17c54ba37b01 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
@@ -41,6 +41,12 @@ bool DlAddrSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) {
stack->info.function_offset = addr - sym_addr;
}
+ if (info.dli_fname) {
+ if (auto *last_occurence = internal_strrchr(info.dli_fname, '/')) {
+ stack->info.module = internal_strdup(last_occurence + 1);
+ }
+ }
+
const char *demangled = DemangleSwiftAndCXX(info.dli_sname);
if (!demangled) return false;
stack->info.function = internal_strdup(demangled);
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Darwin/symbolizer-file-name-dladdr.cpp b/compiler-rt/test/sanitizer_common/TestCases/Darwin/symbolizer-file-name-dladdr.cpp
new file mode 100644
index 0000000000000..802bd666361f4
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Darwin/symbolizer-file-name-dladdr.cpp
@@ -0,0 +1,11 @@
+// RUN: %clangxx %s -O0 -o %t
+// RUN: %env_tool_opts=external_symbolizer_path= %run %t 2>&1 | FileCheck %s
+#include <sanitizer/common_interface_defs.h>
+#include <stdio.h>
+
+int main() {
+ //CHECK: #0{{.*}}
+ //CHECK: #1{{.*}}(symbolizer-file-name-dladdr.cpp.tmp
+ __sanitizer_print_stack_trace();
+ return 0;
+}
More information about the llvm-commits
mailing list