[PATCH] covoar: Fix errors building on FreeBSD and clang

Alex White alex.white at oarcorp.com
Fri Jul 2 19:56:25 UTC 2021


On Wed, Jun 30, 2021 at 11:40 PM <chrisj at rtems.org> wrote:
>
> From: Chris Johns <chrisj at rtems.org>
>
> - The member variable `path_` cannot be a reference and initialised to
>   a const char* type input. To do so would require there is a temporary with
>   an unspecified life time.
> ---
>  tester/covoar/AddressToLineMapper.h | 2 +-
>  tester/covoar/Target_aarch64.h      | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tester/covoar/AddressToLineMapper.h b/tester/covoar/AddressToLineMapper.h
> index 88bf475..c78aef7 100644
> --- a/tester/covoar/AddressToLineMapper.h
> +++ b/tester/covoar/AddressToLineMapper.h
> @@ -84,7 +84,7 @@ namespace Coverage {
>       *  An iterator pointing to the location in the set that contains the
>       *  source file path of the address.
>       */
> -    const std::string& path_;
> +    const std::string path_;

Ryan alerted me about this issue a couple weeks back. This patch would fix the problem, but it would lead to a second copy of every file path string being stored in memory. This would also take away the usefulness of the set of file path strings maintained by the AddressLineRange class.

Instead, I propose we change the empty SourceLine constructor to take a `const std::string&`. This would allow the addition of something like this to the top of AddressToLineMapper::getSource():
const std::string unknown = "unknown";
const SourceLine default_sourceline = SourceLine(unknown);

That should eliminate the issue and preserve the memory conservation efforts of the original design.

Thanks,

Alex

>
>      /*!
>       *  The source line number of the address.
> diff --git a/tester/covoar/Target_aarch64.h b/tester/covoar/Target_aarch64.h
> index 08bd1fb..1502df4 100644
> --- a/tester/covoar/Target_aarch64.h
> +++ b/tester/covoar/Target_aarch64.h
> @@ -44,7 +44,7 @@ namespace Target {
>      bool isNopLine(
>        const char* const line,
>        int&              size
> -    );
> +    ) override;
>
>      /*!
>       *  This method determines if the specified line from an
> --
> 2.24.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210702/ccd3b380/attachment-0001.html>


More information about the devel mailing list