You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Fotis Panagiotopoulos <f....@gmail.com> on 2022/08/25 13:38:04 UTC

NuttX Code Coverage

Hello,

I am trying to use gcov with NuttX simulator, to have code coverage reports
generated.

I have enabled CONFIG_ARCH_COVERAGE and the executable is properly build
and run.
The .gcno files are properly generated.

However, the needed .gcda files are not generated.
Usually these are generated when the executable exits gracefully.

But there is no way to terminate the simulator gracefully.

How do you use code coverage with NuttX?

Re: NuttX Code Coverage

Posted by Xiang Xiao <xi...@gmail.com>.
On Thu, Aug 25, 2022 at 10:52 PM Fotis Panagiotopoulos <f....@gmail.com>
wrote:

> Hmm, indeed a call to __gcov_dump() is missing.
> After calling this, I get the .gcda files generated. And the reports seem
> correct.
>
> Shall I add this call to host_abort()?
>

Yes, it's a good improvement.


> Apart from manual control through NSH, it would be nice to have the files
> generated as the simulator exits.
>
> It is the "standard" expected behavior, and maybe the only solution to
> systems without NSH.
>
>
gcov command is designed for devices which can't do much in the power off
process.


>
> On Thu, Aug 25, 2022 at 5:15 PM Xiang Xiao <xi...@gmail.com>
> wrote:
>
> > On Thu, Aug 25, 2022 at 10:05 PM Fotis Panagiotopoulos <
> > f.j.panag@gmail.com>
> > wrote:
> >
> > > Ah, yes. I didn't have CONFIG_BOARDCTL_POWEROFF enabled, so I didn't
> see
> > > this command.
> > >
> > > Nevertheless, it is still not working.
> > > Indeed the simulator exits, but the .gcda files are not generated.
> > >
> > >
> > Try this tools:
> >
> >
> https://github.com/apache/incubator-nuttx-apps/blob/master/system/gcov/gcov.c
> >
> >
> > > On Thu, Aug 25, 2022 at 4:52 PM Gregory Nutt <sp...@gmail.com>
> > wrote:
> > >
> > > > > But there is no way to terminate the simulator gracefully.
> > > >
> > > > Doesn't this work
> > > >
> > > >      nsh> poweroff
> > > >
> > > > On the simulator, that should lead to exit() being called which is a
> > > > "normal" termination.
> > > >
> > > >
> > > >
> > >
> >
>

On Thu, Aug 25, 2022 at 10:52 PM Fotis Panagiotopoulos <f....@gmail.com>
wrote:

> Hmm, indeed a call to __gcov_dump() is missing.
> After calling this, I get the .gcda files generated. And the reports seem
> correct.
>
> Shall I add this call to host_abort()?
> Apart from manual control through NSH, it would be nice to have the files
> generated as the simulator exits.
>
> It is the "standard" expected behavior, and maybe the only solution to
> systems without NSH.
>
>
> On Thu, Aug 25, 2022 at 5:15 PM Xiang Xiao <xi...@gmail.com>
> wrote:
>
> > On Thu, Aug 25, 2022 at 10:05 PM Fotis Panagiotopoulos <
> > f.j.panag@gmail.com>
> > wrote:
> >
> > > Ah, yes. I didn't have CONFIG_BOARDCTL_POWEROFF enabled, so I didn't
> see
> > > this command.
> > >
> > > Nevertheless, it is still not working.
> > > Indeed the simulator exits, but the .gcda files are not generated.
> > >
> > >
> > Try this tools:
> >
> >
> https://github.com/apache/incubator-nuttx-apps/blob/master/system/gcov/gcov.c
> >
> >
> > > On Thu, Aug 25, 2022 at 4:52 PM Gregory Nutt <sp...@gmail.com>
> > wrote:
> > >
> > > > > But there is no way to terminate the simulator gracefully.
> > > >
> > > > Doesn't this work
> > > >
> > > >      nsh> poweroff
> > > >
> > > > On the simulator, that should lead to exit() being called which is a
> > > > "normal" termination.
> > > >
> > > >
> > > >
> > >
> >
>

Re: NuttX Code Coverage

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
Hmm, indeed a call to __gcov_dump() is missing.
After calling this, I get the .gcda files generated. And the reports seem
correct.

Shall I add this call to host_abort()?
Apart from manual control through NSH, it would be nice to have the files
generated as the simulator exits.

It is the "standard" expected behavior, and maybe the only solution to
systems without NSH.


On Thu, Aug 25, 2022 at 5:15 PM Xiang Xiao <xi...@gmail.com>
wrote:

> On Thu, Aug 25, 2022 at 10:05 PM Fotis Panagiotopoulos <
> f.j.panag@gmail.com>
> wrote:
>
> > Ah, yes. I didn't have CONFIG_BOARDCTL_POWEROFF enabled, so I didn't see
> > this command.
> >
> > Nevertheless, it is still not working.
> > Indeed the simulator exits, but the .gcda files are not generated.
> >
> >
> Try this tools:
>
> https://github.com/apache/incubator-nuttx-apps/blob/master/system/gcov/gcov.c
>
>
> > On Thu, Aug 25, 2022 at 4:52 PM Gregory Nutt <sp...@gmail.com>
> wrote:
> >
> > > > But there is no way to terminate the simulator gracefully.
> > >
> > > Doesn't this work
> > >
> > >      nsh> poweroff
> > >
> > > On the simulator, that should lead to exit() being called which is a
> > > "normal" termination.
> > >
> > >
> > >
> >
>

Re: NuttX Code Coverage

Posted by Xiang Xiao <xi...@gmail.com>.
On Thu, Aug 25, 2022 at 10:05 PM Fotis Panagiotopoulos <f....@gmail.com>
wrote:

> Ah, yes. I didn't have CONFIG_BOARDCTL_POWEROFF enabled, so I didn't see
> this command.
>
> Nevertheless, it is still not working.
> Indeed the simulator exits, but the .gcda files are not generated.
>
>
Try this tools:
https://github.com/apache/incubator-nuttx-apps/blob/master/system/gcov/gcov.c


> On Thu, Aug 25, 2022 at 4:52 PM Gregory Nutt <sp...@gmail.com> wrote:
>
> > > But there is no way to terminate the simulator gracefully.
> >
> > Doesn't this work
> >
> >      nsh> poweroff
> >
> > On the simulator, that should lead to exit() being called which is a
> > "normal" termination.
> >
> >
> >
>

Re: NuttX Code Coverage

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
Ah, yes. I didn't have CONFIG_BOARDCTL_POWEROFF enabled, so I didn't see
this command.

Nevertheless, it is still not working.
Indeed the simulator exits, but the .gcda files are not generated.

On Thu, Aug 25, 2022 at 4:52 PM Gregory Nutt <sp...@gmail.com> wrote:

> > But there is no way to terminate the simulator gracefully.
>
> Doesn't this work
>
>      nsh> poweroff
>
> On the simulator, that should lead to exit() being called which is a
> "normal" termination.
>
>
>

Re: NuttX Code Coverage

Posted by Gregory Nutt <sp...@gmail.com>.
> But there is no way to terminate the simulator gracefully.

Doesn't this work

     nsh> poweroff

On the simulator, that should lead to exit() being called which is a 
"normal" termination.