[rtems-tools commit] covoar/CoverageReaderQEMU: Fix infinite loop
Joel Sherrill
joel at rtems.org
Tue Mar 30 18:20:47 UTC 2021
Module: rtems-tools
Branch: master
Commit: 2845f6c0dad734d27d57bd4f565fb4126f806be7
Changeset: http://git.rtems.org/rtems-tools/commit/?id=2845f6c0dad734d27d57bd4f565fb4126f806be7
Author: Alex White <alex.white at oarcorp.com>
Date: Wed Feb 24 15:58:08 2021 -0600
covoar/CoverageReaderQEMU: Fix infinite loop
There was a potential that the branch info loop never terminated.
This has been fixed by adding a more reliable termination condition
and logging an error if it cannot find the branch target.
---
tester/covoar/CoverageReaderQEMU.cc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tester/covoar/CoverageReaderQEMU.cc b/tester/covoar/CoverageReaderQEMU.cc
index 7c344e4..d3c6abe 100644
--- a/tester/covoar/CoverageReaderQEMU.cc
+++ b/tester/covoar/CoverageReaderQEMU.cc
@@ -118,8 +118,15 @@ namespace Coverage {
// Determine if additional branch information is available.
if ( (entry->op & branchInfo) != 0 ) {
uint32_t a = entry->pc + entry->size - 1;
- while (!aCoverageMap->isStartOfInstruction(a))
+ while (a > entry->pc && !aCoverageMap->isStartOfInstruction(a))
a--;
+ if (a == entry->pc && !aCoverageMap->isStartOfInstruction(a)) {
+ // Something went wrong parsing the objdump.
+ std::ostringstream what;
+ what << "Reached beginning of range in " << file
+ << " at " << entry->pc << " with no start of instruction.";
+ throw rld::error( what, "CoverageReaderQEMU::processFile" );
+ }
if (entry->op & taken) {
aCoverageMap->setWasTaken( a );
} else if (entry->op & notTaken) {
More information about the vc
mailing list