From ecf6f04712ac9d917bae11064ca10d86d4ab05cf Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 8 Mar 2012 14:27:14 -0500 Subject: rt-graph: real-time task labels --- rt-plot-task.c | 19 +++++++++---------- trace-graph.c | 48 +++++++++++++++++++++++++++++++++--------------- trace-graph.h | 3 --- trace-plot.c | 4 +--- 4 files changed, 43 insertions(+), 31 deletions(-) diff --git a/rt-plot-task.c b/rt-plot-task.c index b6d794d..557bfff 100644 --- a/rt-plot-task.c +++ b/rt-plot-task.c @@ -298,11 +298,9 @@ static int try_release(struct graph_info *ginfo, struct rt_task_info *rtt_info, update_job(rtt_info, job); info->release = TRUE; info->rtime = release; - info->rlabel = rtt_info->label; info->deadline = TRUE; info->dtime = deadline; - info->dlabel = rtt_info->label; if (job <= 3) rtt_info->first_rels[job - 1] = release; @@ -328,7 +326,6 @@ static int try_completion(struct graph_info *ginfo, update_job(rtt_info, job); info->completion = TRUE; info->ctime = ts; - info->clabel = rtt_info->label; dprintf(3, "Completion for %d:%d on %d at %llu\n", pid, job, record->cpu, ts); ret = 1; @@ -627,35 +624,37 @@ static int rt_task_plot_display_info(struct graph_info *ginfo, &job, &release, &deadline, &record); restore_offsets(ginfo, offsets); - /* Show real-time data about time */ pid = rtt_info->pid; comm = pevent_data_comm_from_pid(ginfo->pevent, pid); - trace_seq_printf(s, "%s - %d:%d\n", comm, pid, job); + trace_seq_printf(s, "%s-%d:%d\n", comm, pid, job); if (record) { rts = get_rts(ginfo, record); eid = pevent_data_type(ginfo->pevent, record); if (in_res(ginfo, deadline, time)) { - trace_seq_printf(s, "litmus_deadline for %d:%d at %llu\n", + trace_seq_printf(s, "\nlitmus_deadline\n" + "deadline(job(%d,%d)): %llu\n", pid, job, deadline); } if (in_res(ginfo, release, time)) { - trace_seq_printf(s, "litmus_release for %d:%d at %llu\n", + trace_seq_printf(s, "\nlitmus_release\n" + "release(job(%d,%d)): %llu\n", pid, job, release); } if (in_res(ginfo, rts, time)) { event = pevent_data_event_from_type(ginfo->pevent, eid); if (event) { + trace_seq_putc(s, '\n'); trace_seq_puts(s, event->name); trace_seq_putc(s, '\n'); pevent_event_info(s, event, record); - trace_seq_putc(s, '\n'); } else - trace_seq_printf(s, "UNKNOWN EVENT %d\n", eid); + trace_seq_printf(s, "\nUNKNOWN EVENT %d\n", eid); } - convert_nano(get_rts(ginfo, record), &sec, &usec); + trace_seq_putc(s, '\n'); + convert_nano(time, &sec, &usec); trace_seq_printf(s, "%lu.%06lu CPU: %03d", sec, usec, record->cpu); free_record(record); diff --git a/trace-graph.c b/trace-graph.c index 10e1d65..f63c202 100644 --- a/trace-graph.c +++ b/trace-graph.c @@ -1638,16 +1638,36 @@ static gint draw_plot_line(struct graph_info *ginfo, int i, return x; } +static void draw_plot_label(struct graph_info *ginfo, char *label, + gint x, gint y, gint max_width) +{ + PangoLayout *layout; + gint text_width, text_height; + static PangoFontDescription *font = NULL; + + if (!font) { + font = pango_font_description_from_string("Sans 6"); + } + + layout = gtk_widget_create_pango_layout(ginfo->draw, label); + pango_layout_set_font_description(layout, font); + pango_layout_get_pixel_size(layout, &text_width, &text_height); + + if (text_width <= max_width) { + gdk_draw_layout(ginfo->curr_pixmap, + ginfo->draw->style->black_gc, + x, y, layout); + } + g_object_unref(layout); +} + static void draw_plot_box(struct graph_info *ginfo, int i, unsigned long long start, unsigned long long end, gboolean fill, gboolean thin, char *label, GdkGC *gc) { - gint x1; - gint x2; - gint y; - gint size; + gint x1, x2, y, size; x1 = convert_time_to_x(ginfo, start); x2 = convert_time_to_x(ginfo, end); @@ -1659,10 +1679,12 @@ static void draw_plot_box(struct graph_info *ginfo, int i, fill, x1, y, x2 - x1, size); + if (label) + draw_plot_label(ginfo, label, x1 + 1, y + 1, x2 - x1 - 2); } static void draw_plot_release(struct graph_info *ginfo, int i, - unsigned long long time, char *label, GdkGC *gc) + unsigned long long time, GdkGC *gc) { int tbase = PLOT_TOP(i) + PLOT_TRI_SIZE; @@ -1681,7 +1703,7 @@ static void draw_plot_release(struct graph_info *ginfo, int i, } static void draw_plot_deadline(struct graph_info *ginfo, int i, - unsigned long long time, char *label, GdkGC *gc) + unsigned long long time, GdkGC *gc) { int tbase = PLOT_BOX_BOTTOM(i); int x = convert_time_to_x(ginfo, time); @@ -1699,8 +1721,7 @@ static void draw_plot_deadline(struct graph_info *ginfo, int i, } static void draw_plot_completion(struct graph_info *ginfo, int i, - unsigned long long time, char *label, - GdkGC *gc) + unsigned long long time, GdkGC *gc) { int tbase = PLOT_BOX_BOTTOM(i) + PLOT_BTRI_SIZE; int x = convert_time_to_x(ginfo, time); @@ -1748,7 +1769,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, } draw_plot_box(ginfo, plot->pos, info.bstart, info.bend, - info.bfill, info.bthin, info.blabel, plot->gc); + info.bfill, info.bthin, info.blabel, plot->gc); } if (info.release) { @@ -1756,8 +1777,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, plot->last_color = 0; set_color(ginfo->draw, plot->gc, plot->last_color); } - draw_plot_release(ginfo, plot->pos, - info.rtime, info.rlabel, plot->gc); + draw_plot_release(ginfo, plot->pos, info.rtime, plot->gc); } if (info.deadline) { @@ -1765,8 +1785,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, plot->last_color = 0; set_color(ginfo->draw, plot->gc, plot->last_color); } - draw_plot_deadline(ginfo, plot->pos, - info.dtime, info.dlabel, plot->gc); + draw_plot_deadline(ginfo, plot->pos, info.dtime, plot->gc); } if (info.completion) { @@ -1774,8 +1793,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, plot->last_color = 0; set_color(ginfo->draw, plot->gc, plot->last_color); } - draw_plot_completion(ginfo, plot->pos, - info.ctime, info.dlabel, plot->gc); + draw_plot_completion(ginfo, plot->pos, info.ctime, plot->gc); } diff --git a/trace-graph.h b/trace-graph.h index 788c77d..5d7c247 100644 --- a/trace-graph.h +++ b/trace-graph.h @@ -61,15 +61,12 @@ struct plot_info { gboolean release; unsigned long long rtime; - char *rlabel; gboolean deadline; unsigned long long dtime; - char *dlabel; gboolean completion; unsigned long long ctime; - char *clabel; }; /* diff --git a/trace-plot.c b/trace-plot.c index 2621034..e459969 100644 --- a/trace-plot.c +++ b/trace-plot.c @@ -345,12 +345,10 @@ int trace_graph_plot_event(struct graph_info *ginfo, info->bfill = TRUE; info->blabel = NULL; + info->bthin = FALSE; info->release = FALSE; - info->rlabel = NULL; info->deadline = FALSE; - info->dlabel = NULL; info->completion = FALSE; - info->clabel = NULL; if (!plot->cb->plot_event) return 0; -- cgit v1.2.2