Skip to content

Commit 3effc19

Browse files
schenkervitalybuka
andauthored
[sanitizers] improve debug output for failed suppression parse (llvm#72066)
If a sanitizer suppression file can not be parsed, add the supported suppression types to the error message. See llvm#72060. --------- Co-authored-by: Vitaly Buka <[email protected]>
1 parent e3627e2 commit 3effc19

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ void SuppressionContext::Parse(const char *str) {
138138
}
139139
}
140140
if (type == suppression_types_num_) {
141-
Printf("%s: failed to parse suppressions\n", SanitizerToolName);
141+
Printf("%s: failed to parse suppressions.\n", SanitizerToolName);
142+
Printf("Supported suppression types are:\n");
143+
for (type = 0; type < suppression_types_num_; type++)
144+
Printf("- %s\n", suppression_types_[type]);
142145
Die();
143146
}
144147
Suppression s;

compiler-rt/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,15 @@ TEST_F(SuppressionContextTest, HasSuppressionType) {
130130
}
131131

132132
TEST_F(SuppressionContextTest, RegressionTestForBufferOverflowInSuppressions) {
133-
EXPECT_DEATH(ctx_.Parse("race"), "failed to parse suppressions");
134-
EXPECT_DEATH(ctx_.Parse("foo"), "failed to parse suppressions");
133+
const char *expected_output =
134+
"failed to parse suppressions.\n"
135+
"Supported suppression types are:\n"
136+
"- race\n"
137+
"- thread\n"
138+
"- mutex\n"
139+
"- signal\n";
140+
EXPECT_DEATH(ctx_.Parse("race"), expected_output);
141+
EXPECT_DEATH(ctx_.Parse("foo"), expected_output);
135142
}
136143

137-
138144
} // namespace __sanitizer

0 commit comments

Comments
 (0)