[llvm] 8d3ff60 - Fix symbolizer markup backtrace build/test.
Daniel Thornburgh via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 17 13:53:14 PDT 2023
Author: Daniel Thornburgh
Date: 2023-08-17T13:53:02-07:00
New Revision: 8d3ff601a307fa9d18f237903b298bb12b8b64cf
URL: https://github.com/llvm/llvm-project/commit/8d3ff601a307fa9d18f237903b298bb12b8b64cf
DIFF: https://github.com/llvm/llvm-project/commit/8d3ff601a307fa9d18f237903b298bb12b8b64cf.diff
LOG: Fix symbolizer markup backtrace build/test.
This corrects a Darwin build failure due to a missing stub and an
environment-specific Linux test failure due to an overly restrictive
test regex. This also backs out of the previous fix attempt; %p is
intended to be printed and parsed with the semantics of #.
Added:
Modified:
llvm/lib/Support/Unix/Signals.inc
llvm/unittests/Support/SignalsTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index 8d27c9cfeccda1..792b0fd66b45d9 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -539,7 +539,7 @@ public:
uintptr_t StartAddress = Info->dlpi_addr + Phdr->p_vaddr;
uintptr_t ModuleRelativeAddress = Phdr->p_vaddr;
std::array<char, 4> ModeStr = modeStrFromFlags(Phdr->p_flags);
- OS << format("{{{mmap:%016x:%x:load:%d:%s:%016x}}}\n", StartAddress,
+ OS << format("{{{mmap:%#016x:%#x:load:%d:%s:%#016x}}}\n", StartAddress,
Phdr->p_memsz, ModuleCount, &ModeStr[0],
ModuleRelativeAddress);
}
@@ -656,6 +656,10 @@ static bool findModulesAndOffsets(void **StackTrace, int Depth,
return true;
}
+static bool printMarkupContext(llvm::raw_ostream &OS,
+ const char *MainExecutableName) {
+ return false;
+}
#else
/// Backtraces are not enabled or we don't yet know how to find all loaded DSOs
/// on this platform.
diff --git a/llvm/unittests/Support/SignalsTest.cpp b/llvm/unittests/Support/SignalsTest.cpp
index 4eec376b3ceb53..090d836e7b688d 100644
--- a/llvm/unittests/Support/SignalsTest.cpp
+++ b/llvm/unittests/Support/SignalsTest.cpp
@@ -25,6 +25,10 @@ using testing::Not;
#define TAG_BEGIN "\\{\\{\\{"
#define TAG_END "\\}\\}\\}"
+// %p in the Symbolizer Markup Format spec
+#define P_REGEX "(0+|0x[0-9a-fA-F]+)"
+// %i in the Symbolizer Markup Format spec
+#define I_REGEX "(0x[0-9a-fA-F]+|0[0-7]+|[0-9]+)"
#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES && HAVE_LINK_H && \
(defined(__linux__) || defined(__FreeBSD__) || \
@@ -43,14 +47,10 @@ TEST(SignalsTest, PrintsSymbolizerMarkup) {
"module:0:[^:]*SupportTests:elf:[0-9a-f]+" TAG_END
".*"));
// Text segment for main binary
- EXPECT_THAT(
- Res,
- MatchesRegex(".*" TAG_BEGIN
- "mmap:[0-9a-f]+:[0-9a-f]+:load:0:rx:[0-9a-f]+" TAG_END
- ".*"));
+ EXPECT_THAT(Res, MatchesRegex(".*" TAG_BEGIN "mmap:" P_REGEX ":" I_REGEX
+ ":load:0:rx:" P_REGEX TAG_END ".*"));
// Backtrace line
- EXPECT_THAT(Res, MatchesRegex(".*" TAG_BEGIN "bt:0:[0-9a-f]+"
- ".*"));
+ EXPECT_THAT(Res, MatchesRegex(".*" TAG_BEGIN "bt:0:" P_REGEX ".*"));
}
TEST(SignalsTest, SymbolizerMarkupDisabled) {
More information about the llvm-commits
mailing list