Skip to content

Commit

Permalink
[Sanitizers] Remove BuildId from sanitizers stacktrace on Darwin
Browse files Browse the repository at this point in the history
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
  • Loading branch information
usama54321 committed Jun 6, 2023
1 parent bb39889 commit fdb1a89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>)");
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fdb1a89

Please sign in to comment.