[PATCH] covoar: Fix off-by-one in Coverage::finalizeSymbol()
Gedare Bloom
gedare at rtems.org
Wed Mar 31 16:22:15 UTC 2021
On Wed, Mar 31, 2021 at 10:05 AM Alex White <alex.white at oarcorp.com> wrote:
>
> The `rangeIndex` variable is 1 higher than the index at which the first
> instruction address was found. This fixes the lookup after the loop to
> account for that fact.
> ---
> tester/covoar/ObjdumpProcessor.cc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc
> index 62a06c5..1cfa877 100644
> --- a/tester/covoar/ObjdumpProcessor.cc
> +++ b/tester/covoar/ObjdumpProcessor.cc
> @@ -60,7 +60,7 @@ namespace Coverage {
> lowAddress = coverageMap.getLowAddressOfRange(rangeIndex);
> }
>
> - uint32_t sizeWithoutNops = coverageMap.getSizeOfRange(rangeIndex);
> + uint32_t sizeWithoutNops = coverageMap.getSizeOfRange(rangeIndex - 1);
I guess this is because of the for loop. Maybe, you should prefer to
exit the for loop with the proper index?
Fixing an off-by-1 bug by subtracting one from the point of
consumption is a good way to ensure the bug occurs again if anyone
reuses the rangeIndex variable later.
> uint32_t size = sizeWithoutNops;
> uint32_t highAddress = lowAddress + size - 1;
> uint32_t computedHighAddress = highAddress;
> --
> 2.27.0
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
More information about the devel
mailing list