[compiler-rt] fdb1a89 - [Sanitizers] Remove BuildId from sanitizers stacktrace on Darwin

usama hameed via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 16:38:22 PDT 2023


Author: usama hameed
Date: 2023-06-06T16:37:39-07:00
New Revision: fdb1a891b64c27522a2386a8025f8ad5c7e02bfb

URL: https://github.com/llvm/llvm-project/commit/fdb1a891b64c27522a2386a8025f8ad5c7e02bfb
DIFF: https://github.com/llvm/llvm-project/commit/fdb1a891b64c27522a2386a8025f8ad5c7e02bfb.diff

LOG: [Sanitizers] Remove BuildId from sanitizers stacktrace on Darwin

On Darwin, we do not want to show the BuildId appended at the end of stack
frames in Sanitizers. The BuildId/UUID can be seen by using the
print_module_map=1 sanitizer option.

Differential Revision: https://reviews.llvm.org/D150298

rdar://108324403

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
    compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_printer_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
index 1096d21fb47f4..d3d1d26681ef8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
@@ -218,7 +218,9 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
         RenderModuleLocation(buffer, info->module, info->module_offset,
                              info->module_arch, strip_path_prefix);
 
+#ifndef SANITIZER_APPLE
         MaybeBuildIdToBuffer(*info, /*PrefixSpace=*/true, buffer);
+#endif
       } else {
         buffer->append("(<unknown module>)");
       }
@@ -231,7 +233,9 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
         // Always strip the module name for %M.
         RenderModuleLocation(buffer, StripModuleName(info->module),
                              info->module_offset, info->module_arch, "");
+#ifndef SANITIZER_APPLE
         MaybeBuildIdToBuffer(*info, /*PrefixSpace=*/true, buffer);
+#endif
       } else {
         buffer->append("(%p)", (void *)address);
       }

diff  --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_printer_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_printer_test.cpp
index 62b34cd78aba8..489ef4dbb5b7d 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_printer_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_printer_test.cpp
@@ -137,11 +137,19 @@ TEST(SanitizerStacktracePrinter, RenderFrame) {
   RenderFrame(&str, "%M", frame_no, info.address, &info, false);
   EXPECT_NE(nullptr, internal_strstr(str.data(), "(module+0x"));
   EXPECT_NE(nullptr, internal_strstr(str.data(), "200"));
+#if SANITIZER_APPLE
+  EXPECT_EQ(nullptr, internal_strstr(str.data(), "BuildId: 5566"));
+#else
   EXPECT_NE(nullptr, internal_strstr(str.data(), "BuildId: 5566"));
+#endif
   str.clear();
 
   RenderFrame(&str, "%L", frame_no, info.address, &info, false);
+#if SANITIZER_APPLE
+  EXPECT_STREQ("(/path/to/module+0x200)", str.data());
+#else
   EXPECT_STREQ("(/path/to/module+0x200) (BuildId: 5566)", str.data());
+#endif
   str.clear();
 
   RenderFrame(&str, "%b", frame_no, info.address, &info, false);


        


More information about the llvm-commits mailing list