This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: coverage tests


>>>>> "Thomas" == Koeller, T <Thomas.Koeller@baslerweb.com> writes:

    Thomas> I wonder if it it possible to use gcov for programs
    Thomas> running on an embedded target?

Theoretically yes, but eCos does not currently have the required
support.

I have not investigated gcov in detail so some of the below may be
wrong, but it should give some idea of what would be involved.

When you compile code with -fprofile-arcs -ftest-coverage, the
compiler inserts extra code that does the appropriate counting. It
will also install initialization calls to __bb_init_func() for every
module. On native targets this function is provided by libgcc.a, see
gcc/libgcc2.c for the full details. Essentially it installs an
atexit() handler __bb_exit_func() which is responsible for dumping all
the accumulated profiling information to a file using stdio calls.

For embedded targets the profiling implementation has to be rather
different. Typically a deeply embedded application will never exit so
atexit() handlers never get called. Also, even if stdio library calls
are available they may not be able to write to a file that can be
readily accessed by gcov running on the host. Hence the relevant
libgcc code is disabled, -Dinhibit_libc. However the code generated by
the compiler will still do the counting and make calls to
__bb_init_func().

So an implementation of gcov profiling for eCos would involve an
eCos-specific version of __bb_init_func(), some way of dumping the
accumulated information to the host e.g. by establishing a socket
connection to a suitable program, and some way of triggering a dump
(e.g. a function that can be called by the application).

There may well be other problems, for example the accumulated counts
may be incorrect if a thread context switch occurs. In fact I do not
know how well gcov copes with multi-threaded programs generally. Also
the synthetic target would be a special case: it uses the system's
libgcc.a which contains a __bb_init_func() intended for use with
glibc.

Bart

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]