[compiler-rt] 3effc19 - [sanitizers] improve debug output for failed suppression parse (#72066)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 18 17:11:00 PST 2023
Author: Thomas Schenker
Date: 2023-12-18T17:10:55-08:00
New Revision: 3effc191e32cd690695e3ba9972b6c332d2beb00
URL: https://github.com/llvm/llvm-project/commit/3effc191e32cd690695e3ba9972b6c332d2beb00
DIFF: https://github.com/llvm/llvm-project/commit/3effc191e32cd690695e3ba9972b6c332d2beb00.diff
LOG: [sanitizers] improve debug output for failed suppression parse (#72066)
If a sanitizer suppression file can not be parsed, add the supported
suppression types to the error message.
See https://github.com/llvm/llvm-project/issues/72060.
---------
Co-authored-by: Vitaly Buka <vitalybuka at gmail.com>
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
compiler-rt/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
index f3818526baab1b..9c8c4bf9d1a484 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
@@ -138,7 +138,10 @@ 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]);
Die();
}
Suppression s;
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 50a6ce92f9bedc..45ed16b173afe4 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