From 06d56ad1a6eebf565538b443c7a31444872442ee Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 8 Mar 2012 16:41:45 -0500 Subject: rt-graph: time type abstracted out --- rt-plot-task.c | 1 + trace-graph.c | 12 ++++++------ trace-graph.h | 8 ++++++++ trace-plot-cpu.c | 1 + trace-plot-task.c | 2 ++ trace-plot.c | 7 ++++++- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/rt-plot-task.c b/rt-plot-task.c index 1e2cd5d..852f323 100644 --- a/rt-plot-task.c +++ b/rt-plot-task.c @@ -771,6 +771,7 @@ void rt_plot_task(struct graph_info *ginfo, int pid, int pos) "%s-%d\n(%llu.%1llu, %llu.%1llu)", comm, pid, wm, wn, pm, pn); plot = trace_graph_plot_insert(ginfo, pos, plot_label, PLOT_TYPE_RT_TASK, + TIME_TYPE_RT, &rt_task_cb, rtt_info); free(plot_label); diff --git a/trace-graph.c b/trace-graph.c index de29e45..34c8268 100644 --- a/trace-graph.c +++ b/trace-graph.c @@ -1839,7 +1839,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, plot->p1, plot->p2, ginfo->draw_width, width_16, font); } -static void draw_nonrt_plots(struct graph_info *ginfo) +static void draw_ft_plots(struct graph_info *ginfo) { gint cpu, pid; struct record *record; @@ -1860,7 +1860,7 @@ static void draw_nonrt_plots(struct graph_info *ginfo) hash = trace_graph_plot_find_cpu(ginfo, cpu); if (hash) { for (list = hash->plots; list; list = list->next) { - if (list->plot->type == PLOT_TYPE_RT_TASK) + if (list->plot->time != TIME_TYPE_FT) continue; draw_plot(ginfo, list->plot, record); } @@ -1869,13 +1869,13 @@ static void draw_nonrt_plots(struct graph_info *ginfo) hash = trace_graph_plot_find_task(ginfo, pid); if (hash) { for (list = hash->plots; list; list = list->next) { - if (list->plot->type == PLOT_TYPE_RT_TASK) + if (list->plot->time != TIME_TYPE_FT) continue; draw_plot(ginfo, list->plot, record); } } for (list = ginfo->all_recs; list; list = list->next) { - if (list->plot->type == PLOT_TYPE_RT_TASK) + if (list->plot->time != TIME_TYPE_FT) continue; draw_plot(ginfo, list->plot, record); } @@ -1900,7 +1900,7 @@ static void draw_rt_plots(struct graph_info *ginfo) break; } for (list = ginfo->all_recs; list; list = list->next) { - if (list->plot->type != PLOT_TYPE_RT_TASK) + if (list->plot->time != TIME_TYPE_RT) continue; draw_plot(ginfo, list->plot, record); } @@ -1965,7 +1965,7 @@ static void draw_plots(struct graph_info *ginfo, gint new_width) goto out; } - draw_nonrt_plots(ginfo); + draw_ft_plots(ginfo); draw_rt_plots(ginfo); out: diff --git a/trace-graph.h b/trace-graph.h index 5d7c247..cfa5db7 100644 --- a/trace-graph.h +++ b/trace-graph.h @@ -44,6 +44,11 @@ enum graph_plot_type { PLOT_TYPE_RT_TASK, }; +enum plot_time_type { + TIME_TYPE_FT, + TIME_TYPE_RT +}; + struct graph_plot; struct plot_info { @@ -133,6 +138,7 @@ struct plot_callbacks { struct graph_plot { enum graph_plot_type type; + enum plot_time_type time; int pos; char *label; const struct plot_callbacks *cb; @@ -337,12 +343,14 @@ void trace_graph_plot_init(struct graph_info *ginfo); struct graph_plot *trace_graph_plot_append(struct graph_info *ginfo, const char *label, enum graph_plot_type type, + enum plot_time_type time, const struct plot_callbacks *cb, void *data); struct graph_plot *trace_graph_plot_insert(struct graph_info *ginfo, int pos, const char *label, enum graph_plot_type type, + enum plot_time_type time, const struct plot_callbacks *cb, void *data); void trace_graph_plot_remove(struct graph_info *ginfo, struct graph_plot *plot); diff --git a/trace-plot-cpu.c b/trace-plot-cpu.c index 28baaa5..9b927e1 100644 --- a/trace-plot-cpu.c +++ b/trace-plot-cpu.c @@ -469,6 +469,7 @@ static void add_cpu_plot(struct graph_info *ginfo, gint cpu) snprintf(label, 100, "CPU %d", cpu); plot = trace_graph_plot_append(ginfo, label, PLOT_TYPE_CPU, + TIME_TYPE_FT, &cpu_plot_cb, cpu_info); trace_graph_plot_add_cpu(ginfo, plot, cpu); } diff --git a/trace-plot-task.c b/trace-plot-task.c index d4b608b..803d89b 100644 --- a/trace-plot-task.c +++ b/trace-plot-task.c @@ -836,6 +836,7 @@ void graph_plot_init_tasks(struct graph_info *ginfo) snprintf(label, 100, "TASK %d", pid); trace_graph_plot_insert(ginfo, 1, label, PLOT_TYPE_TASK, + TIME_TYPE_FT, &task_plot_cb, task_info); } @@ -858,6 +859,7 @@ void graph_plot_task(struct graph_info *ginfo, int pid, int pos) label = malloc_or_die(len); snprintf(label, len, "%s-%d", comm, pid); plot = trace_graph_plot_insert(ginfo, pos, label, PLOT_TYPE_TASK, + TIME_TYPE_RT, &task_plot_cb, task_info); free(label); diff --git a/trace-plot.c b/trace-plot.c index e459969..5629e47 100644 --- a/trace-plot.c +++ b/trace-plot.c @@ -76,6 +76,7 @@ allocate_plot(struct graph_info *ginfo, struct graph_plot * trace_graph_plot_append(struct graph_info *ginfo, const char *label, enum graph_plot_type type, + enum plot_time_type time, const struct plot_callbacks *cb, void *data) { struct graph_plot *plot; @@ -84,6 +85,7 @@ trace_graph_plot_append(struct graph_info *ginfo, plot->type = type; plot->pos = ginfo->plots; + plot->time = time; if (!ginfo->plots) { ginfo->plot_array = malloc_or_die(sizeof(ginfo->plot_array[0])); @@ -107,13 +109,15 @@ trace_graph_plot_append(struct graph_info *ginfo, struct graph_plot * trace_graph_plot_insert(struct graph_info *ginfo, int pos, const char *label, enum graph_plot_type type, + enum plot_time_type time, const struct plot_callbacks *cb, void *data) { struct graph_plot *plot; int i; if (pos >= ginfo->plots) - return trace_graph_plot_append(ginfo, label, type, cb, data); + return trace_graph_plot_append(ginfo, label, type, + time, cb, data); if (pos < 0) pos = 0; @@ -121,6 +125,7 @@ trace_graph_plot_insert(struct graph_info *ginfo, plot = allocate_plot(ginfo, label, cb, data); plot->pos = pos; plot->type = type; + plot->time = time; ginfo->plot_array = realloc(ginfo->plot_array, sizeof(ginfo->plot_array[0]) * (ginfo->plots + 1)); -- cgit v1.2.2