Skip to content

Commit ada7f4c

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 175d9c0 commit ada7f4c

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
@@ -198,7 +198,9 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
198198
RenderModuleLocation(buffer, info->module, info->module_offset,
199199
info->module_arch, strip_path_prefix);
200200

201+
#if !SANITIZER_APPLE
201202
MaybeBuildIdToBuffer(*info, /*PrefixSpace=*/true, buffer);
203+
#endif
202204
} else {
203205
buffer->append("(<unknown module>)");
204206
}
@@ -211,7 +213,9 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
211213
// Always strip the module name for %M.
212214
RenderModuleLocation(buffer, StripModuleName(info->module),
213215
info->module_offset, info->module_arch, "");
216+
#if !SANITIZER_APPLE
214217
MaybeBuildIdToBuffer(*info, /*PrefixSpace=*/true, buffer);
218+
#endif
215219
} else {
216220
buffer->append("(%p)", (void *)address);
217221
}

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
@@ -123,11 +123,19 @@ TEST(SanitizerStacktracePrinter, RenderFrame) {
123123
RenderFrame(&str, "%M", frame_no, info.address, &info, false);
124124
EXPECT_NE(nullptr, internal_strstr(str.data(), "(module+0x"));
125125
EXPECT_NE(nullptr, internal_strstr(str.data(), "200"));
126+
#if SANITIZER_APPLE
127+
EXPECT_EQ(nullptr, internal_strstr(str.data(), "BuildId: 5566"));
128+
#else
126129
EXPECT_NE(nullptr, internal_strstr(str.data(), "BuildId: 5566"));
130+
#endif
127131
str.clear();
128132

129133
RenderFrame(&str, "%L", frame_no, info.address, &info, false);
134+
#if SANITIZER_APPLE
135+
EXPECT_STREQ("(/path/to/module+0x200)", str.data());
136+
#else
130137
EXPECT_STREQ("(/path/to/module+0x200) (BuildId: 5566)", str.data());
138+
#endif
131139
str.clear();
132140

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

0 commit comments

Comments
 (0)