diff --git a/emu.c b/emu.c index 2345ab9..33bae68 100644 --- a/emu.c +++ b/emu.c @@ -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); diff --git a/prv.c b/prv.c index bdf6975..d7104f1 100644 --- a/prv.c +++ b/prv.c @@ -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); } diff --git a/prv.h b/prv.h index ec3ddb9..de244b5 100644 --- a/prv.h +++ b/prv.h @@ -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 */