Set the trace duration in the PRV header

This commit is contained in:
Rodrigo Arias 2021-11-02 14:05:32 +01:00
parent 5dc195a037
commit e05f78bb0f
3 changed files with 21 additions and 1 deletions

9
emu.c
View File

@ -707,6 +707,14 @@ open_pcfs(struct ovni_emu *emu, char *tracedir)
}
}
/* Fix the trace duration at the end */
static void
fix_prv_headers(struct ovni_emu *emu)
{
prv_fix_header(emu->prv_thread, emu->delta_time, emu->total_nthreads);
prv_fix_header(emu->prv_cpu, emu->delta_time, emu->total_ncpus);
}
static void
close_prvs(struct ovni_emu *emu)
{
@ -1084,6 +1092,7 @@ emu_post(struct ovni_emu *emu)
static void
emu_destroy(struct ovni_emu *emu)
{
fix_prv_headers(emu);
close_prvs(emu);
close_pcfs(emu);
destroy_metadata(emu);

10
prv.c
View File

@ -81,5 +81,13 @@ prv_ev_autocpu(struct ovni_emu *emu, int type, int val)
void
prv_header(FILE *f, int nrows)
{
fprintf(f, "#Paraver (19/01/38 at 03:14):00000000000000000000_ns:0:1:1(%d:1)\n", nrows);
fprintf(f, "#Paraver (19/01/38 at 03:14):%020ld_ns:0:1:1(%d:1)\n", 0LU, nrows);
}
void
prv_fix_header(FILE *f, uint64_t duration, int nrows)
{
/* Go to the first byte */
fseek(f, 0, SEEK_SET);
fprintf(f, "#Paraver (19/01/38 at 03:14):%020ld_ns:0:1:1(%d:1)\n", duration, nrows);
}

3
prv.h
View File

@ -43,4 +43,7 @@ prv_ev_autocpu_raw(struct ovni_emu *emu, int64_t time, int type, int val);
void
prv_header(FILE *f, int nrows);
void
prv_fix_header(FILE *f, uint64_t duration, int nrows);
#endif /* OVNI_PRV_H */