[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@gmail.com>
This commit is contained in:
Thomas Schenker
2023-12-19 02:10:55 +01:00
committed by GitHub
parent e3627e2690
commit 3effc191e3
2 changed files with 13 additions and 4 deletions

View File

@@ -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;

View File

@@ -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