[compiler-rt] [sanitizers] improve debug output for failed suppression parse (PR #72066)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 13:36:02 PST 2023
https://github.com/schenker updated https://github.com/llvm/llvm-project/pull/72066
>From ba9bb00e8edb7b87eede1c3005fdbf5124c78e21 Mon Sep 17 00:00:00 2001
From: Thomas Schenker <thomas.schenker at protonmail.com>
Date: Sun, 12 Nov 2023 21:05:01 +0100
Subject: [PATCH 1/2] [sanitizers] improve debug output for failed suppression
parse
If a suppression file can not be parsed, add the supported suppression
types to the error message.
---
compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
index f3818526baab1b7..a94178828bd80db 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
@@ -139,6 +139,10 @@ void SuppressionContext::Parse(const char *str) {
}
if (type == suppression_types_num_) {
Printf("%s: failed to parse suppressions\n", SanitizerToolName);
+ Printf("Supported suppression types are:\n");
+ for (type = 0; type < suppression_types_num_; type++) {
+ Printf("- %s\n", suppression_types_[type]);
+ }
Die();
}
Suppression s;
>From 93c3c4ab8baafed74085decddbe675c4b621b072 Mon Sep 17 00:00:00 2001
From: Thomas Schenker <thomas.schenker at protonmail.com>
Date: Tue, 14 Nov 2023 22:16:47 +0100
Subject: [PATCH 2/2] add tests
---
.../lib/sanitizer_common/sanitizer_suppressions.cpp | 2 +-
.../tests/sanitizer_suppressions_test.cpp | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
index a94178828bd80db..913960d3ebc8786 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
@@ -138,7 +138,7 @@ void SuppressionContext::Parse(const char *str) {
}
}
if (type == suppression_types_num_) {
- Printf("%s: failed to parse suppressions\n", SanitizerToolName);
+ Printf("%s: failed to parse suppressions.\n", SanitizerToolName);
Printf("Supported suppression types are:\n");
for (type = 0; type < suppression_types_num_; type++) {
Printf("- %s\n", suppression_types_[type]);
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp
index 50a6ce92f9bedc9..aeff9897a51622d 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp
@@ -130,9 +130,15 @@ TEST_F(SuppressionContextTest, HasSuppressionType) {
}
TEST_F(SuppressionContextTest, RegressionTestForBufferOverflowInSuppressions) {
- EXPECT_DEATH(ctx_.Parse("race"), "failed to parse suppressions");
- EXPECT_DEATH(ctx_.Parse("foo"), "failed to parse suppressions");
+ const char *expected_output =
+ "failed to parse suppressions.\n"
+ "Supported suppression types are:\n"
+ "- race\n"
+ "- thread\n"
+ "- mutex\n"
+ "- signal\n";
+ EXPECT_DEATH(ctx_.Parse("race"), expected_output);
+ EXPECT_DEATH(ctx_.Parse("foo"), expected_output);
}
-
} // namespace __sanitizer
More information about the llvm-commits
mailing list