From a12a227df2a7a93a7f037d3b33183eadc7254591 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Fri, 17 Sep 2010 14:44:08 -0400 Subject: trace-graph: Fix plots to show start bars in zoomed views. Currently, if a zoomed view has events before the start of the view, those events are not examined to determine if the bar of a graph should be shown at the start. This patch adds code to the cpu and task plots to look for events that happened before the view to determine if a bar should be shown or not. Signed-off-by: Steven Rostedt --- trace-plot-cpu.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'trace-plot-cpu.c') diff --git a/trace-plot-cpu.c b/trace-plot-cpu.c index 09b1690..d6800ef 100644 --- a/trace-plot-cpu.c +++ b/trace-plot-cpu.c @@ -27,6 +27,7 @@ struct cpu_plot_info { int cpu; unsigned long long last_time; int last_pid; + struct record *last_record; }; static gint hash_pid(gint val) @@ -192,6 +193,7 @@ static void cpu_plot_start(struct graph_info *ginfo, struct graph_plot *plot, cpu = cpu_info->cpu; cpu_info->last_time = 0ULL; cpu_info->last_pid = -1; + cpu_info->last_record = NULL; } static int cpu_plot_event(struct graph_info *ginfo, @@ -200,6 +202,7 @@ static int cpu_plot_event(struct graph_info *ginfo, struct plot_info *info) { struct cpu_plot_info *cpu_info = plot->private; + struct tracecmd_input *handle = ginfo->handle; int sched_pid; int orig_pid; int is_sched_switch; @@ -212,6 +215,11 @@ static int cpu_plot_event(struct graph_info *ginfo, cpu = cpu_info->cpu; if (!record) { + if (cpu_info->last_record) { + free_record(cpu_info->last_record); + cpu_info->last_record = NULL; + } + /* Finish a box if the last record was not idle */ if (cpu_info->last_pid > 0) { info->box = TRUE; @@ -222,6 +230,30 @@ static int cpu_plot_event(struct graph_info *ginfo, return 0; } + /* + * If last record is NULL, then it may exist off the + * viewable range. Search to see if one exists. + */ + if (!cpu_info->last_record) { + struct record *trecord; + + trecord = tracecmd_read_prev(handle, record); + if (trecord) { + filter = filter_record(ginfo, trecord, + &orig_pid, &sched_pid, + &is_sched_switch); + cpu_info->last_pid = is_sched_switch ? sched_pid : orig_pid; + } + cpu_info->last_record = trecord; + /* We moved the cursor, put it back */ + trecord = tracecmd_read_data(handle, record->cpu); + free_record(trecord); + } + + free_record(cpu_info->last_record); + cpu_info->last_record = record; + tracecmd_record_ref(record); + cpu = cpu_info->cpu; filter = filter_record(ginfo, record, &orig_pid, &sched_pid, &is_sched_switch); -- cgit v1.2.2