Skip to content

Commit fdb1a89

Browse files
committed
[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
1 parent bb39889 commit fdb1a89

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
218218
RenderModuleLocation(buffer, info->module, info->module_offset,
219219
info->module_arch, strip_path_prefix);
220220

221+
#ifndef SANITIZER_APPLE
221222
MaybeBuildIdToBuffer(*info, /*PrefixSpace=*/true, buffer);
223+
#endif
222224
} else {
223225
buffer->append("(<unknown module>)");
224226
}
@@ -231,7 +233,9 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
231233
// Always strip the module name for %M.
232234
RenderModuleLocation(buffer, StripModuleName(info->module),
233235
info->module_offset, info->module_arch, "");
236+
#ifndef SANITIZER_APPLE
234237
MaybeBuildIdToBuffer(*info, /*PrefixSpace=*/true, buffer);
238+
#endif
235239
} else {
236240
buffer->append("(%p)", (void *)address);
237241
}

compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_printer_test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,19 @@ TEST(SanitizerStacktracePrinter, RenderFrame) {
137137
RenderFrame(&str, "%M", frame_no, info.address, &info, false);
138138
EXPECT_NE(nullptr, internal_strstr(str.data(), "(module+0x"));
139139
EXPECT_NE(nullptr, internal_strstr(str.data(), "200"));
140+
#if SANITIZER_APPLE
141+
EXPECT_EQ(nullptr, internal_strstr(str.data(), "BuildId: 5566"));
142+
#else
140143
EXPECT_NE(nullptr, internal_strstr(str.data(), "BuildId: 5566"));
144+
#endif
141145
str.clear();
142146

143147
RenderFrame(&str, "%L", frame_no, info.address, &info, false);
148+
#if SANITIZER_APPLE
149+
EXPECT_STREQ("(/path/to/module+0x200)", str.data());
150+
#else
144151
EXPECT_STREQ("(/path/to/module+0x200) (BuildId: 5566)", str.data());
152+
#endif
145153
str.clear();
146154

147155
RenderFrame(&str, "%b", frame_no, info.address, &info, false);

0 commit comments

Comments
 (0)