forked from OSchip/llvm-project
[NFC][lsan] Change LeakSuppressionContext interface
Reviewed By: morehouse Differential Revision: https://reviews.llvm.org/D115318
This commit is contained in:
parent
19c5cf4167
commit
a9a1499080
|
@ -74,14 +74,14 @@ class LeakSuppressionContext {
|
||||||
|
|
||||||
Suppression *GetSuppressionForAddr(uptr addr);
|
Suppression *GetSuppressionForAddr(uptr addr);
|
||||||
void LazyInit();
|
void LazyInit();
|
||||||
|
bool SuppressByRule(const StackTrace &stack, uptr hit_count, uptr total_size);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LeakSuppressionContext(const char *supprression_types[],
|
LeakSuppressionContext(const char *supprression_types[],
|
||||||
int suppression_types_num)
|
int suppression_types_num)
|
||||||
: context(supprression_types, suppression_types_num) {}
|
: context(supprression_types, suppression_types_num) {}
|
||||||
|
|
||||||
Suppression *GetSuppressionForStack(u32 stack_trace_id,
|
bool Suppress(u32 stack_trace_id, uptr hit_count, uptr total_size);
|
||||||
const StackTrace &stack);
|
|
||||||
|
|
||||||
const InternalMmapVector<u32> &GetSortedSuppressedStacks() {
|
const InternalMmapVector<u32> &GetSortedSuppressedStacks() {
|
||||||
if (!suppressed_stacks_sorted) {
|
if (!suppressed_stacks_sorted) {
|
||||||
|
@ -148,19 +148,29 @@ Suppression *LeakSuppressionContext::GetSuppressionForAddr(uptr addr) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Suppression *LeakSuppressionContext::GetSuppressionForStack(
|
bool LeakSuppressionContext::SuppressByRule(const StackTrace &stack,
|
||||||
u32 stack_trace_id, const StackTrace &stack) {
|
uptr hit_count, uptr total_size) {
|
||||||
LazyInit();
|
|
||||||
for (uptr i = 0; i < stack.size; i++) {
|
for (uptr i = 0; i < stack.size; i++) {
|
||||||
Suppression *s = GetSuppressionForAddr(
|
Suppression *s = GetSuppressionForAddr(
|
||||||
StackTrace::GetPreviousInstructionPc(stack.trace[i]));
|
StackTrace::GetPreviousInstructionPc(stack.trace[i]));
|
||||||
if (s) {
|
if (s) {
|
||||||
suppressed_stacks_sorted = false;
|
s->weight += total_size;
|
||||||
suppressed_stacks.push_back(stack_trace_id);
|
atomic_fetch_add(&s->hit_count, hit_count, memory_order_relaxed);
|
||||||
return s;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LeakSuppressionContext::Suppress(u32 stack_trace_id, uptr hit_count,
|
||||||
|
uptr total_size) {
|
||||||
|
LazyInit();
|
||||||
|
StackTrace stack = StackDepotGet(stack_trace_id);
|
||||||
|
if (!SuppressByRule(stack, hit_count, total_size))
|
||||||
|
return false;
|
||||||
|
suppressed_stacks_sorted = false;
|
||||||
|
suppressed_stacks.push_back(stack_trace_id);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LeakSuppressionContext *GetSuppressionContext() {
|
static LeakSuppressionContext *GetSuppressionContext() {
|
||||||
|
@ -909,12 +919,8 @@ uptr LeakReport::ApplySuppressions() {
|
||||||
LeakSuppressionContext *suppressions = GetSuppressionContext();
|
LeakSuppressionContext *suppressions = GetSuppressionContext();
|
||||||
uptr new_suppressions = false;
|
uptr new_suppressions = false;
|
||||||
for (uptr i = 0; i < leaks_.size(); i++) {
|
for (uptr i = 0; i < leaks_.size(); i++) {
|
||||||
Suppression *s = suppressions->GetSuppressionForStack(
|
if (suppressions->Suppress(leaks_[i].stack_trace_id, leaks_[i].hit_count,
|
||||||
leaks_[i].stack_trace_id, StackDepotGet(leaks_[i].stack_trace_id));
|
leaks_[i].total_size)) {
|
||||||
if (s) {
|
|
||||||
s->weight += leaks_[i].total_size;
|
|
||||||
atomic_fetch_add(&s->hit_count, leaks_[i].hit_count,
|
|
||||||
memory_order_relaxed);
|
|
||||||
leaks_[i].is_suppressed = true;
|
leaks_[i].is_suppressed = true;
|
||||||
++new_suppressions;
|
++new_suppressions;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue