[PATCH v2] covoar: Fix off-by-one in Coverage::finalizeSymbol()

Gedare Bloom gedare at rtems.org
Wed Mar 31 18:16:25 UTC 2021


ok

On Wed, Mar 31, 2021 at 11:22 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 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;
> --
> 2.27.0
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list