Please provide instructions about how to use gcov to process gcov data
returned from target when using
__gcov_info_to_gcda (*info, filename, dump, allocate, arg);
and
__gcov_filename_to_gcfn (f, dump, arg);
I have tried following the stand alone tutorial.
https://gcc.gnu.org/onlinedocs/gcc/Freestanding-Environments.html#Tutorial
That tutorial does not give example about what happened when gcov data is
sent back from a target.
I am getting data returned from target but the gcov-tool keeps give error
state below
*host*: windows
*compiler*: C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\13.2
Rel1\bin
*target*: Renesas S7G2
*command*: C:\opt\extend\source\Home\SK-S7G2-master\build>C:\"Program Files
(x86)\Arm GNU Toolchain arm-none-eabi\13.2
Rel1\bin\arm-none-eabi-gcov-tool.exe" merge-stream
CMakeFiles\SK-S7G2_Simple.elf.dir\src\output_gcc.txt
*error: *CMakeFiles\SK-S7G2_Simple.elf.dir\src\output_gcc.txt:incorrect
gcov version 841614340 vs 1110651434
I have provided the output from the target
and the code used to generate the output.
Please give some guidance from real embedded target.
Example from host are not explaining the type of error.
--
A life well lived is its own reward
nfcg*23BhC:\opt\extend\source\Home\SK-S7G2-master\build\CMakeFiles/SK-S7G2_Simple.elf.dir/src/hal_entry.cpp.gcda
adcgh*23BhN[�hS.>bh�V�7�¤�h�åùhz¼*�£�>²»�N��cïw��´óõñZ�¾�e·�ø0
#include "app.h"
#include <gcov.h>
#include <stdio.h>
#include <stdlib.h>
//#define XPACK 1
#define GCC
#define gcov_read_unsigned __gcov_read_unsigned_port
extern void __gcov_info_to_gcda(const struct gcov_info *__info,
void (*__filename_fn)(const char*, void*),
void (*__dump_fn) (const void *, unsigned n, void *arg),
void * (*__allocate_fn) (unsigned length, void *arg),
void* __arg);
/* Convert the FILENAME to a gcfn data stream. The DUMP_FN callback is
subsequently called with chunks (the begin and length of the chunk are
passed as the first two callback parameters) of the gcfn data stream.
The ARG parameter is a user-provided argument passed as the last
argument to the DUMP_FN callback function. This function is intended
to be used by the filename callback of __gcov_info_to_gcda(). The gcfn
data stream is used by the merge-stream subcommand of the gcov-tool to
get the filename associated with a gcda data stream. */
extern void __gcov_filename_to_gcfn (const char *__filename,
void (*__dump_fn) (const void *d, unsigned n, void *arg)
,void *__arg);
/* The start and end symbols are provided by the linker script. We use the
array notation to avoid issues with a potential small-data area. */
extern const struct gcov_info *const __gcov_info_start[];
extern const struct gcov_info *const __gcov_info_end[];
void dump_gcov_info (void);
unsigned char __gcov_read_unsigned_port()
{
return 1110585898;
}
/* This function shall produce a reliable in order byte stream to transfer the
gcov information from the target to the host system. */
static void dump (const void *d, unsigned n, void *arg)
{
(void)arg;
const unsigned char *c = (unsigned char *)d;
//for (unsigned i = 0; i < n; ++i)
//fwrite (encode (c[i], buf), sizeof (buf), 1, stderr);
//fwrite (c, sizeof (c), n, stdout);
//for (unsigned i = 0; i < n; ++i)
// printf ("%02x", c[i]);
printf("%s",c);
}
/* The filename is serialized to a gcfn data stream by the
__gcov_filename_to_gcfn() function. The gcfn data is used by the
"merge-stream" subcommand of the "gcov-tool" to figure out the filename
associated with the gcov information. */
#ifdef GCC
static void filename (const char *f, void *arg)
{
__gcov_filename_to_gcfn (f, dump, arg);
}
#elif XPACK == 1
static void filename (const char *f, void *arg)
{
printf("%s",f);
}
#endif
/* The __gcov_info_to_gcda() function may have to allocate memory under
certain conditions. Simply try it out if it is needed for your application
or not. */
static void * allocate (unsigned length, void *arg)
{
(void)arg;
return malloc (length);
}
/* Dump the gcov information of all translation units. */
#ifdef GCC
void dump_gcov_info (void)
#elif XPACK == 1
__gcov_dump(void)
#endif
{
const struct gcov_info *const *info = __gcov_info_start;
const struct gcov_info *const *end = __gcov_info_end;
/* Obfuscate variable to prevent compiler optimizations. */
__asm__ ("" : "+r" (info));
while (info != end)
{
void *arg = NULL;
__gcov_info_to_gcda (*info, filename, dump, allocate, arg);
fputc ('\n', stdout);
++info;
}
}
/* The main() function just runs the application and then dumps the gcov
information to stderr. */
// int
// main (void)
// {
// application ();
// dump_gcov_info ();
// return 0;
// }