aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--trace-graph.c33
-rw-r--r--trace-graph.h26
-rw-r--r--trace-plot-cpu.c32
-rw-r--r--trace-plot.c14
4 files changed, 75 insertions, 30 deletions
diff --git a/trace-graph.c b/trace-graph.c
index c16f313..7eaf506 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -1721,7 +1721,6 @@ static void draw_info(struct graph_info *ginfo,
1721 1721
1722void trace_graph_select_by_time(struct graph_info *ginfo, guint64 time) 1722void trace_graph_select_by_time(struct graph_info *ginfo, guint64 time)
1723{ 1723{
1724 struct record *record = NULL;
1725 GtkAdjustment *vadj; 1724 GtkAdjustment *vadj;
1726 gint view_start; 1725 gint view_start;
1727 gint view_width; 1726 gint view_width;
@@ -1729,7 +1728,8 @@ void trace_graph_select_by_time(struct graph_info *ginfo, guint64 time)
1729 gint mid; 1728 gint mid;
1730 gint start; 1729 gint start;
1731 gint end; 1730 gint end;
1732 gint cpu; 1731 int ret;
1732 gint i;
1733 guint64 old_start_time = ginfo->view_start_time; 1733 guint64 old_start_time = ginfo->view_start_time;
1734 1734
1735 view_width = gtk_adjustment_get_page_size(ginfo->hadj); 1735 view_width = gtk_adjustment_get_page_size(ginfo->hadj);
@@ -1780,20 +1780,13 @@ void trace_graph_select_by_time(struct graph_info *ginfo, guint64 time)
1780 * If a record exists at this exact time value, we should 1780 * If a record exists at this exact time value, we should
1781 * make sure that it is in view. 1781 * make sure that it is in view.
1782 */ 1782 */
1783 for (cpu = 0; cpu < ginfo->cpus; cpu++) { 1783 for (i = 0; i < ginfo->plots; i++) {
1784 tracecmd_set_cpu_to_timestamp(ginfo->handle, cpu, time); 1784 ret = trace_graph_plot_match_time(ginfo, ginfo->plot_array[i],
1785 record = tracecmd_read_data(ginfo->handle, cpu); 1785 time);
1786 while (record && record->ts < time) { 1786 if (ret)
1787 free_record(record);
1788 record = tracecmd_read_data(ginfo->handle, cpu);
1789 }
1790 if (record && record->ts == time)
1791 break; 1787 break;
1792 free_record(record);
1793 record = NULL;
1794 } 1788 }
1795 free_record(record); 1789 if (i == ginfo->plots)
1796 if (cpu == ginfo->cpus)
1797 return; 1790 return;
1798 1791
1799 /* Make sure PLOT is visible */ 1792 /* Make sure PLOT is visible */
@@ -1801,15 +1794,15 @@ void trace_graph_select_by_time(struct graph_info *ginfo, guint64 time)
1801 view_start = gtk_adjustment_get_value(vadj); 1794 view_start = gtk_adjustment_get_value(vadj);
1802 view_width = gtk_adjustment_get_page_size(vadj); 1795 view_width = gtk_adjustment_get_page_size(vadj);
1803 1796
1804 if (PLOT_TOP(cpu) > view_start && 1797 if (PLOT_TOP(i) > view_start &&
1805 PLOT_BOTTOM(cpu) < view_start + view_width) 1798 PLOT_BOTTOM(i) < view_start + view_width)
1806 return; 1799 return;
1807 1800
1808 if (PLOT_TOP(cpu) < view_start) 1801 if (PLOT_TOP(i) < view_start)
1809 gtk_adjustment_set_value(vadj, PLOT_TOP(cpu) - 5); 1802 gtk_adjustment_set_value(vadj, PLOT_TOP(i) - 5);
1810 1803
1811 if (PLOT_BOTTOM(cpu) > view_start + view_width) 1804 if (PLOT_BOTTOM(i) > view_start + view_width)
1812 gtk_adjustment_set_value(vadj, (PLOT_BOTTOM(cpu) - view_width) + 10); 1805 gtk_adjustment_set_value(vadj, (PLOT_BOTTOM(i) - view_width) + 10);
1813} 1806}
1814 1807
1815static void graph_free_systems(struct graph_info *ginfo) 1808static void graph_free_systems(struct graph_info *ginfo)
diff --git a/trace-graph.h b/trace-graph.h
index 634707d..6035045 100644
--- a/trace-graph.h
+++ b/trace-graph.h
@@ -12,14 +12,24 @@ typedef void (graph_filter_cb)(struct graph_info *ginfo,
12 struct filter_task *task_filter, 12 struct filter_task *task_filter,
13 struct filter_task *hide_tasks); 13 struct filter_task *hide_tasks);
14 14
15struct graph_plot;
16
17/*
18 * match_time:
19 * Return true if a selected time should expose plot.
20 * Should only return true if an event has the exact time that
21 * is passed in.
22 */
15struct plot_callbacks { 23struct plot_callbacks {
16 void *private; 24 int (*match_time)(struct graph_info *, struct graph_plot *,
25 unsigned long long time);
17}; 26};
18 27
19struct graph_plot { 28struct graph_plot {
20 struct graph_plot *next; 29 struct graph_plot *next;
21 char *label; 30 char *label;
22 struct plot_callbacks *cb; 31 const struct plot_callbacks *cb;
32 void *private;
23}; 33};
24 34
25struct graph_callbacks { 35struct graph_callbacks {
@@ -154,7 +164,13 @@ int trace_graph_load_handle(struct graph_info *ginfo,
154void trace_graph_plot_free(struct graph_info *ginfo); 164void trace_graph_plot_free(struct graph_info *ginfo);
155void trace_graph_plot_init(struct graph_info *ginfo); 165void trace_graph_plot_init(struct graph_info *ginfo);
156void trace_graph_plot_append(struct graph_info *ginfo, 166void trace_graph_plot_append(struct graph_info *ginfo,
157 const char *label, struct plot_callbacks *cb); 167 const char *label, const struct plot_callbacks *cb,
168 void *data);
169
170int trace_graph_plot_match_time(struct graph_info *ginfo,
171 struct graph_plot *plot,
172 unsigned long long time);
173
158 174
159/* cpu plot */ 175/* cpu plot */
160void graph_plot_init_cpus(struct graph_info *ginfo, int cpus); 176void graph_plot_init_cpus(struct graph_info *ginfo, int cpus);
diff --git a/trace-plot-cpu.c b/trace-plot-cpu.c
index 31b88f1..d855c2c 100644
--- a/trace-plot-cpu.c
+++ b/trace-plot-cpu.c
@@ -1,14 +1,38 @@
1#include "trace-graph.h" 1#include "trace-graph.h"
2 2
3static struct plot_callbacks cpu_plot_cb; 3static int cpu_plot_match_time(struct graph_info *ginfo, struct graph_plot *plot,
4 unsigned long long time)
5{
6 struct record *record;
7 long cpu;
8 int ret = 0;
9
10 cpu = (long)plot->private;
11
12 tracecmd_set_cpu_to_timestamp(ginfo->handle, cpu, time);
13 record = tracecmd_read_data(ginfo->handle, cpu);
14 while (record && record->ts < time) {
15 free_record(record);
16 record = tracecmd_read_data(ginfo->handle, cpu);
17 }
18 if (record && record->ts == time)
19 ret = 1;
20 free_record(record);
21
22 return ret;
23}
24
25static const struct plot_callbacks cpu_plot_cb = {
26 .match_time = cpu_plot_match_time
27};
4 28
5void graph_plot_init_cpus(struct graph_info *ginfo, int cpus) 29void graph_plot_init_cpus(struct graph_info *ginfo, int cpus)
6{ 30{
7 char label[100]; 31 char label[100];
8 int cpu; 32 long cpu;
9 33
10 for (cpu = 0; cpu < cpus; cpu++) { 34 for (cpu = 0; cpu < cpus; cpu++) {
11 snprintf(label, 100, "CPU %d", cpu); 35 snprintf(label, 100, "CPU %ld", cpu);
12 trace_graph_plot_append(ginfo, label, &cpu_plot_cb); 36 trace_graph_plot_append(ginfo, label, &cpu_plot_cb, (void *)cpu);
13 } 37 }
14} 38}
diff --git a/trace-plot.c b/trace-plot.c
index 35d3352..152ff05 100644
--- a/trace-plot.c
+++ b/trace-plot.c
@@ -27,7 +27,8 @@ void trace_graph_plot_init(struct graph_info *ginfo)
27} 27}
28 28
29void trace_graph_plot_append(struct graph_info *ginfo, 29void trace_graph_plot_append(struct graph_info *ginfo,
30 const char *label, struct plot_callbacks *cb) 30 const char *label, const struct plot_callbacks *cb,
31 void *data)
31{ 32{
32 struct graph_plot *plot; 33 struct graph_plot *plot;
33 char *name; 34 char *name;
@@ -41,6 +42,7 @@ void trace_graph_plot_append(struct graph_info *ginfo,
41 42
42 plot->label = name; 43 plot->label = name;
43 plot->cb = cb; 44 plot->cb = cb;
45 plot->private = data;
44 46
45 plot->next = ginfo->plot_list; 47 plot->next = ginfo->plot_list;
46 ginfo->plot_list = plot; 48 ginfo->plot_list = plot;
@@ -61,3 +63,13 @@ void trace_graph_plot_append(struct graph_info *ginfo,
61 63
62 ginfo->plots++; 64 ginfo->plots++;
63} 65}
66
67int trace_graph_plot_match_time(struct graph_info *ginfo,
68 struct graph_plot *plot,
69 unsigned long long time)
70{
71 if (!plot->cb->match_time)
72 return 0;
73
74 return plot->cb->match_time(ginfo, plot, time);
75}