aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-02-08 15:02:13 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-02-10 10:58:45 -0500
commitb391d4e5acbf1f243b316f6f024137fa614a0d2d (patch)
tree8b6f777c9e8d87e8dde6fe41463b97624cd7a818
parent7d359f826170f08cc97a683cb48e4051c7a79117 (diff)
trace-graph: Add find_record to plots for popup windows
The popup needs a record to use to determin if a task should be added to the filter or not. Add the method find_record to the plot callback structure. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-graph.c12
-rw-r--r--trace-graph.h10
-rw-r--r--trace-plot-cpu.c39
-rw-r--r--trace-plot.c11
4 files changed, 66 insertions, 6 deletions
diff --git a/trace-graph.c b/trace-graph.c
index 026d940..67cae96 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -456,13 +456,14 @@ do_pop_up(GtkWidget *widget, GdkEventButton *event, gpointer data)
456 static GtkWidget *menu_filter_hide_task; 456 static GtkWidget *menu_filter_hide_task;
457 static GtkWidget *menu_filter_clear_tasks; 457 static GtkWidget *menu_filter_clear_tasks;
458 struct record *record = NULL; 458 struct record *record = NULL;
459 struct graph_plot *plot;
459 const char *comm; 460 const char *comm;
460 guint64 time; 461 guint64 time;
461 gchar *text; 462 gchar *text;
462 gint pid; 463 gint pid;
463 gint len; 464 gint len;
464 gint x, y; 465 gint x, y;
465 gint cpu; 466 gint i;
466 467
467 x = event->x; 468 x = event->x;
468 y = event->y; 469 y = event->y;
@@ -523,10 +524,11 @@ do_pop_up(GtkWidget *widget, GdkEventButton *event, gpointer data)
523 524
524 time = convert_x_to_time(ginfo, x); 525 time = convert_x_to_time(ginfo, x);
525 526
526 for (cpu = 0; cpu < ginfo->cpus; cpu++) { 527 for (i = 0; i < ginfo->plots; i++) {
527 if (y >= (PLOT_TOP(cpu) - PLOT_GIVE) && 528 if (y >= (PLOT_TOP(i) - PLOT_GIVE) &&
528 y <= (PLOT_BOTTOM(cpu) + PLOT_GIVE)) { 529 y <= (PLOT_BOTTOM(i) + PLOT_GIVE)) {
529 record = find_record_on_cpu(ginfo, cpu, time); 530 plot = ginfo->plot_array[i];
531 record = trace_graph_plot_find_record(ginfo, plot, time);
530 break; 532 break;
531 } 533 }
532 } 534 }
diff --git a/trace-graph.h b/trace-graph.h
index 343a769..7427785 100644
--- a/trace-graph.h
+++ b/trace-graph.h
@@ -46,6 +46,9 @@ struct graph_plot;
46 * a event, the plot may ask to display that event. 46 * a event, the plot may ask to display that event.
47 * The time will be given to find the event, the time may be before 47 * The time will be given to find the event, the time may be before
48 * the given event. 48 * the given event.
49 *
50 * find_record:
51 * return a tracecmd record for a given time.
49 */ 52 */
50struct plot_callbacks { 53struct plot_callbacks {
51 int (*match_time)(struct graph_info *, struct graph_plot *, 54 int (*match_time)(struct graph_info *, struct graph_plot *,
@@ -62,6 +65,8 @@ struct plot_callbacks {
62 void (*end)(struct graph_info *, struct graph_plot *); 65 void (*end)(struct graph_info *, struct graph_plot *);
63 int (*display_last_event)(struct graph_info *ginfo, struct graph_plot *plot, 66 int (*display_last_event)(struct graph_info *ginfo, struct graph_plot *plot,
64 struct trace_seq *s, unsigned long long time); 67 struct trace_seq *s, unsigned long long time);
68 struct record *(*find_record)(struct graph_info *, struct graph_plot *,
69 unsigned long long time);
65}; 70};
66 71
67struct graph_plot { 72struct graph_plot {
@@ -239,6 +244,11 @@ int trace_graph_plot_event(struct graph_info *ginfo,
239void trace_graph_plot_end(struct graph_info *ginfo, 244void trace_graph_plot_end(struct graph_info *ginfo,
240 struct graph_plot *plot); 245 struct graph_plot *plot);
241 246
247struct record *
248trace_graph_plot_find_record(struct graph_info *ginfo,
249 struct graph_plot *plot,
250 unsigned long long time);
251
242/* cpu plot */ 252/* cpu plot */
243void graph_plot_init_cpus(struct graph_info *ginfo, int cpus); 253void graph_plot_init_cpus(struct graph_info *ginfo, int cpus);
244 254
diff --git a/trace-plot-cpu.c b/trace-plot-cpu.c
index b1adb91..5d37950 100644
--- a/trace-plot-cpu.c
+++ b/trace-plot-cpu.c
@@ -275,12 +275,49 @@ static int cpu_plot_event(struct graph_info *ginfo,
275 return ret; 275 return ret;
276} 276}
277 277
278static struct record *
279find_record_on_cpu(struct graph_info *ginfo, gint cpu, guint64 time)
280{
281 struct record *record = NULL;
282 guint64 offset = 0;
283
284 tracecmd_set_cpu_to_timestamp(ginfo->handle, cpu, time);
285 do {
286 if (record) {
287 offset = record->offset;
288 free_record(record);
289 }
290 record = tracecmd_read_data(ginfo->handle, cpu);
291 } while (record && record->ts <= (time - 1 / ginfo->resolution));
292
293 if (record) {
294 if (record->ts > (time + 1 / ginfo->resolution) && offset) {
295 free_record(record);
296 record = tracecmd_read_at(ginfo->handle, offset, NULL);
297 }
298 }
299
300 return record;
301}
302
303static struct record *
304cpu_plot_find_record(struct graph_info *ginfo, struct graph_plot *plot,
305 unsigned long long time)
306{
307 struct cpu_plot_info *cpu_info = plot->private;
308 int cpu;
309
310 cpu = cpu_info->cpu;
311
312 return find_record_on_cpu(ginfo, cpu, time);
313}
278 314
279static const struct plot_callbacks cpu_plot_cb = { 315static const struct plot_callbacks cpu_plot_cb = {
280 .match_time = cpu_plot_match_time, 316 .match_time = cpu_plot_match_time,
281 .plot_event = cpu_plot_event, 317 .plot_event = cpu_plot_event,
282 .start = cpu_plot_start, 318 .start = cpu_plot_start,
283 .display_last_event = cpu_plot_display_last_event 319 .display_last_event = cpu_plot_display_last_event,
320 .find_record = cpu_plot_find_record,
284}; 321};
285 322
286void graph_plot_init_cpus(struct graph_info *ginfo, int cpus) 323void graph_plot_init_cpus(struct graph_info *ginfo, int cpus)
diff --git a/trace-plot.c b/trace-plot.c
index 7a3e5dd..0cc8919 100644
--- a/trace-plot.c
+++ b/trace-plot.c
@@ -121,3 +121,14 @@ int trace_graph_plot_display_last_event(struct graph_info *ginfo,
121 121
122 return plot->cb->display_last_event(ginfo, plot, s, time); 122 return plot->cb->display_last_event(ginfo, plot, s, time);
123} 123}
124
125struct record *
126trace_graph_plot_find_record(struct graph_info *ginfo,
127 struct graph_plot *plot,
128 unsigned long long time)
129{
130 if (!plot->cb->find_record)
131 return 0;
132
133 return plot->cb->find_record(ginfo, plot, time);
134}