From 26538d6edad965d45a02e3d999d5853fb3fa51c6 Mon Sep 17 00:00:00 2001 From: Alex White Date: Wed, 31 Mar 2021 11:01:06 -0500 Subject: covoar: Fix off-by-one in Coverage::finalizeSymbol() The `rangeIndex` variable is 1 higher than the index at which the first instruction address was found. This fixes the loop to set `rangeIndex` correctly. --- tester/covoar/ObjdumpProcessor.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc index 62a06c5..c2ed3d5 100644 --- a/tester/covoar/ObjdumpProcessor.cc +++ b/tester/covoar/ObjdumpProcessor.cc @@ -52,13 +52,12 @@ namespace Coverage { throw rld::error( what, "Coverage::finalizeSymbol" ); } - int rangeIndex; + int rangeIndex = -1; uint32_t lowAddress = UINT32_MAX; - for (rangeIndex = 0; - firstInstructionAddress != lowAddress; - rangeIndex++) { + do { + rangeIndex++; lowAddress = coverageMap.getLowAddressOfRange(rangeIndex); - } + } while (firstInstructionAddress != lowAddress); uint32_t sizeWithoutNops = coverageMap.getSizeOfRange(rangeIndex); uint32_t size = sizeWithoutNops; -- cgit v1.2.3