aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2009-12-21 20:54:32 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-21 20:54:32 -0500
commit7fe507f6cab8c983ce91682d8ed98725a7e6b8fc (patch)
tree4ae81fc9565a2dd43530e7d38783e348bce9f7ee
parent5718d550edd8d4d7e4c1987f90d6dc99c99d92b2 (diff)
trace-graph: Add CPU label to CPU lines
The CPU lines did not show what CPUs they represent. This enables them. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-graph.c85
-rw-r--r--trace-graph.h2
2 files changed, 84 insertions, 3 deletions
diff --git a/trace-graph.c b/trace-graph.c
index 0d68e37..b92cf5b 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -46,6 +46,8 @@
46static gint ftrace_sched_switch_id = -1; 46static gint ftrace_sched_switch_id = -1;
47static gint event_sched_switch_id = -1; 47static gint event_sched_switch_id = -1;
48 48
49static gint largest_cpu_label = 0;
50
49static void convert_nano(unsigned long long time, unsigned long *sec, 51static void convert_nano(unsigned long long time, unsigned long *sec,
50 unsigned long *usec) 52 unsigned long *usec)
51{ 53{
@@ -61,7 +63,7 @@ static void print_time(unsigned long long time)
61 printf("%lu.%06lu", sec, usec); 63 printf("%lu.%06lu", sec, usec);
62} 64}
63 65
64static void update_with_backend(struct graph_info *ginfo, 66static void __update_with_backend(struct graph_info *ginfo,
65 gint x, gint y, 67 gint x, gint y,
66 gint width, gint height) 68 gint width, gint height)
67{ 69{
@@ -72,6 +74,81 @@ static void update_with_backend(struct graph_info *ginfo,
72 width, height); 74 width, height);
73} 75}
74 76
77static void clear_old_cpu_label(struct graph_info *ginfo, gint cpu)
78{
79 __update_with_backend(ginfo,
80 ginfo->cpu_x, CPU_TOP(cpu),
81 largest_cpu_label+1, 20);
82}
83
84static void clear_old_cpu_labels(struct graph_info *ginfo)
85{
86 gint cpu;
87
88 for (cpu = 0; cpu < ginfo->cpus; cpu++)
89 clear_old_cpu_label(ginfo, cpu);
90}
91
92static void __draw_cpu_label(struct graph_info *ginfo, gint cpu)
93{
94 PangoLayout *layout;
95 gchar buf[BUFSIZ];
96 gint width, height;
97
98 snprintf(buf, BUFSIZ, "CPU %d", cpu);
99
100 layout = gtk_widget_create_pango_layout(ginfo->draw, buf);
101 pango_layout_get_pixel_size(layout, &width, &height);
102 width += 4;
103
104 if (width > largest_cpu_label)
105 largest_cpu_label = width;
106 gdk_draw_rectangle(ginfo->draw->window,
107 ginfo->draw->style->white_gc,
108 TRUE,
109 ginfo->cpu_x, CPU_TOP(cpu)+4,
110 width, height);
111 gdk_draw_layout(ginfo->draw->window,
112 ginfo->draw->style->black_gc,
113 ginfo->cpu_x + 2, CPU_TOP(cpu) + 4,
114 layout);
115 g_object_unref(layout);
116}
117
118static void draw_cpu_label(struct graph_info *ginfo, gint cpu)
119{
120 clear_old_cpu_label(ginfo, cpu);
121 __draw_cpu_label(ginfo, cpu);
122}
123
124
125static void draw_cpu_labels(struct graph_info *ginfo)
126{
127 gint cpu;
128
129 clear_old_cpu_labels(ginfo);
130 ginfo->cpu_x = gtk_adjustment_get_value(ginfo->vadj) + 5;
131
132 for (cpu = 0; cpu < ginfo->cpus; cpu++)
133 __draw_cpu_label(ginfo, cpu);
134}
135
136static void update_with_backend(struct graph_info *ginfo,
137 gint x, gint y,
138 gint width, gint height)
139{
140 gint cpu;
141
142 __update_with_backend(ginfo, x, y, width, height);
143 for (cpu = 0; cpu < ginfo->cpus; cpu++ ) {
144 if (y <= CPU_BOTTOM(cpu) &&
145 y + height > CPU_TOP(cpu) &&
146 x + width > ginfo->cpu_x &&
147 x <= ginfo->cpu_x + largest_cpu_label)
148 draw_cpu_label(ginfo, cpu);
149 }
150}
151
75static gboolean 152static gboolean
76expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) 153expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
77{ 154{
@@ -545,6 +622,7 @@ value_changed(GtkWidget *widget, gpointer data)
545 struct graph_info *ginfo = data; 622 struct graph_info *ginfo = data;
546 GtkAdjustment *adj = GTK_ADJUSTMENT(widget); 623 GtkAdjustment *adj = GTK_ADJUSTMENT(widget);
547 624
625 draw_cpu_labels(ginfo);
548 printf("value = %f\n", 626 printf("value = %f\n",
549 gtk_adjustment_get_value(adj)); 627 gtk_adjustment_get_value(adj));
550 628
@@ -964,6 +1042,8 @@ static void draw_info(struct graph_info *ginfo,
964 draw_cpu(ginfo, cpu, new_width, read_comms); 1042 draw_cpu(ginfo, cpu, new_width, read_comms);
965 1043
966 read_comms = 0; 1044 read_comms = 0;
1045
1046 draw_cpu_labels(ginfo);
967} 1047}
968 1048
969static gboolean 1049static gboolean
@@ -974,7 +1054,6 @@ configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
974 1054
975 gtk_widget_set_size_request(widget, ginfo->draw_width, ginfo->draw_height); 1055 gtk_widget_set_size_request(widget, ginfo->draw_width, ginfo->draw_height);
976 1056
977
978 old_pix = ginfo->curr_pixmap; 1057 old_pix = ginfo->curr_pixmap;
979 1058
980 /* initialize full width if needed */ 1059 /* initialize full width if needed */
@@ -1018,7 +1097,7 @@ configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
1018 ginfo->vadj_value = gtk_adjustment_get_value(ginfo->vadj); 1097 ginfo->vadj_value = gtk_adjustment_get_value(ginfo->vadj);
1019 printf("get val %f\n", ginfo->vadj_value); 1098 printf("get val %f\n", ginfo->vadj_value);
1020 ginfo->vadj_value = 0.0; 1099 ginfo->vadj_value = 0.0;
1021 1100
1022 return TRUE; 1101 return TRUE;
1023} 1102}
1024 1103
diff --git a/trace-graph.h b/trace-graph.h
index caa2531..d3bea95 100644
--- a/trace-graph.h
+++ b/trace-graph.h
@@ -36,6 +36,8 @@ struct graph_info {
36 gint cpu_data_w; 36 gint cpu_data_w;
37 gint cpu_data_h; 37 gint cpu_data_h;
38 38
39 gint cpu_x; /* x coord where CPU numbers are drawn */
40
39 /* not needed in future */ 41 /* not needed in future */
40 42
41 gchar *test; 43 gchar *test;