From 61c4835ed40d6a168ada3f62c7cc11420b5e3f39 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Tue, 28 Oct 2008 12:49:49 -0400 Subject: add some detail to st_dump output --- src/sched_trace.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/sched_trace.c b/src/sched_trace.c index 9f532f3..330ed27 100644 --- a/src/sched_trace.c +++ b/src/sched_trace.c @@ -62,6 +62,7 @@ static const char* event_names[] = { #define ST_INVALID (ST_RESUME + 1) + const char* event2name(unsigned int id) { if (id >= ST_INVALID) @@ -71,16 +72,64 @@ const char* event2name(unsigned int id) void print_header(struct st_trace_header* hdr) { - printf("%-14s on CPU %u for %5u/%5u", + printf("%-14s %5u/%-5u on CPU%3u ", event2name(hdr->type), - hdr->cpu, hdr->pid, hdr->job); + hdr->pid, hdr->job, + hdr->cpu); +} + +typedef void (*print_t)(struct st_event_record* rec); + +static void print_nothing(struct st_event_record* _) +{ +} + +static void print_name(struct st_event_record* rec) +{ + /* terminate in all cases */ + rec->data.name.cmd[ST_NAME_LEN - 1] = 0; + printf("%s", rec->data.name.cmd); +} + +static void print_param(struct st_event_record* rec) +{ + printf("T=(cost:%6.2fms, period:%6.2fms, phase:%6.2fms), part=%d", + rec->data.param.wcet / 1000000.0, + rec->data.param.period / 1000000.0, + rec->data.param.phase / 1000000.0,\ + rec->data.param.partition); } +static print_t print_detail[] = { + print_nothing, + print_name, + print_param, + print_nothing, + print_nothing, + print_nothing, + print_nothing, + print_nothing, + print_nothing, + print_nothing, + print_nothing +}; + +void print_event(struct st_event_record *rec) +{ + unsigned int id = rec->hdr.type; + + if (id >= ST_INVALID) + id = ST_INVALID; + print_header(&rec->hdr); + print_detail[id](rec); + printf("\n"); + return event_names[id]; +} + + void print_all(struct st_event_record *rec, unsigned int count) { unsigned int i; - for (i = 0; i < count; i++) { - print_header(&rec[i].hdr); - printf("\n"); - } + for (i = 0; i < count; i++) + print_event(&rec[i]); } -- cgit v1.2.2