From 67f1be840f98c83255df2fa635970ce841abfeaa Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Sun, 28 Mar 2021 11:59:58 +0200 Subject: [PATCH] prune-trace: correctly handle 0 trace entries If the analyzed program does not read any memory, or the reading memory accesses are filtered out in the import step (import-trace -m), the trace table may hold no entries for the program. This commit makes sure the SamplingPruner and FESamplingPruner deal properly with this situation. Change-Id: I6bb5da23f345fa97cf8ab0b688cce5d00945249a --- tools/prune-trace/FESamplingPruner.cc | 5 +++++ tools/prune-trace/SamplingPruner.cc | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/tools/prune-trace/FESamplingPruner.cc b/tools/prune-trace/FESamplingPruner.cc index e8f0710f..91a374d3 100644 --- a/tools/prune-trace/FESamplingPruner.cc +++ b/tools/prune-trace/FESamplingPruner.cc @@ -146,6 +146,11 @@ bool FESamplingPruner::sampling_prune(const fail::Database::Variant& variant) samplerows = std::min(pilotcount, m_samplesize); } + if (pilotcount == 0) { + LOG << "no entries found, nothing to sample from!" << endl; + return true; + } + LOG << "loaded " << pilotcount << " entries, sampling " << samplerows << " entries with fault expansion ..." << endl; diff --git a/tools/prune-trace/SamplingPruner.cc b/tools/prune-trace/SamplingPruner.cc index 3665fac3..41219dba 100644 --- a/tools/prune-trace/SamplingPruner.cc +++ b/tools/prune-trace/SamplingPruner.cc @@ -173,6 +173,11 @@ bool SamplingPruner::sampling_prune(const fail::Database::Variant& variant) mysql_free_result(res); } + if (pilotcount == 0) { + LOG << "no entries found, nothing to sample from!" << endl; + return true; + } + LOG << "loaded " << pilotcount << " entries, sampling " << m_samplesize << " fault-space coordinates ..." << endl;