diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-12-31 16:27:53 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-31 16:27:53 -0500 |
commit | 0a0bfaa72b4ff1af4fa0fd75128a31dcd326dbb7 (patch) | |
tree | 0fc4a5c7e213741f2a1289797d2624648f49d937 | |
parent | fa243a0a1107ebbf5eea0a1871df203ec4050552 (diff) |
trace-graph: Add filtering of tasks
This enables the popup filter menus to actual filter the tasks
in the graph.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-graph.c | 101 |
1 files changed, 71 insertions, 30 deletions
diff --git a/trace-graph.c b/trace-graph.c index 814559e..54ea8ea 100644 --- a/trace-graph.c +++ b/trace-graph.c | |||
@@ -68,7 +68,7 @@ static gint event_sched_switch_id = -1; | |||
68 | static gint largest_cpu_label = 0; | 68 | static gint largest_cpu_label = 0; |
69 | 69 | ||
70 | static void redraw_pixmap_backend(struct graph_info *ginfo); | 70 | static void redraw_pixmap_backend(struct graph_info *ginfo); |
71 | static gint do_hash(gint val); | 71 | static guint do_hash(gint val); |
72 | 72 | ||
73 | static void convert_nano(unsigned long long time, unsigned long *sec, | 73 | static void convert_nano(unsigned long long time, unsigned long *sec, |
74 | unsigned long *usec) | 74 | unsigned long *usec) |
@@ -167,6 +167,21 @@ static void filter_task_clear(struct graph_info *ginfo) | |||
167 | 167 | ||
168 | ginfo->filter_task_count = 0; | 168 | ginfo->filter_task_count = 0; |
169 | ginfo->filter_available = 0; | 169 | ginfo->filter_available = 0; |
170 | ginfo->filter_enabled = 0; | ||
171 | } | ||
172 | |||
173 | gboolean filter_on_task(struct graph_info *ginfo, gint pid) | ||
174 | { | ||
175 | gboolean filter; | ||
176 | |||
177 | filter = FALSE; | ||
178 | |||
179 | if (ginfo->filter_enabled && | ||
180 | ginfo->filter_task_count && | ||
181 | !filter_task_find_pid(ginfo, pid)) | ||
182 | filter = TRUE; | ||
183 | |||
184 | return filter; | ||
170 | } | 185 | } |
171 | 186 | ||
172 | static void __update_with_backend(struct graph_info *ginfo, | 187 | static void __update_with_backend(struct graph_info *ginfo, |
@@ -235,6 +250,17 @@ static void clear_last_line(GtkWidget *widget, struct graph_info *ginfo) | |||
235 | update_with_backend(ginfo, x, 0, x+2, widget->allocation.height); | 250 | update_with_backend(ginfo, x, 0, x+2, widget->allocation.height); |
236 | } | 251 | } |
237 | 252 | ||
253 | static void redraw_graph(struct graph_info *ginfo) | ||
254 | { | ||
255 | gdouble height; | ||
256 | gdouble width; | ||
257 | |||
258 | redraw_pixmap_backend(ginfo); | ||
259 | width = ginfo->draw->allocation.width; | ||
260 | height = ginfo->draw->allocation.height; | ||
261 | update_with_backend(ginfo, 0, 0, width, height); | ||
262 | } | ||
263 | |||
238 | static struct record * | 264 | static struct record * |
239 | find_record_on_cpu(struct graph_info *ginfo, gint cpu, guint64 time) | 265 | find_record_on_cpu(struct graph_info *ginfo, gint cpu, guint64 time) |
240 | { | 266 | { |
@@ -268,6 +294,8 @@ filter_enable_clicked (gpointer data) | |||
268 | struct graph_info *ginfo = data; | 294 | struct graph_info *ginfo = data; |
269 | 295 | ||
270 | ginfo->filter_enabled ^= 1; | 296 | ginfo->filter_enabled ^= 1; |
297 | |||
298 | redraw_graph(ginfo); | ||
271 | } | 299 | } |
272 | 300 | ||
273 | static void | 301 | static void |
@@ -282,14 +310,21 @@ filter_add_task_clicked (gpointer data) | |||
282 | filter_task_remove_pid(ginfo, task->pid); | 310 | filter_task_remove_pid(ginfo, task->pid); |
283 | else | 311 | else |
284 | filter_task_add_pid(ginfo, ginfo->filter_task_selected); | 312 | filter_task_add_pid(ginfo, ginfo->filter_task_selected); |
313 | |||
314 | if (ginfo->filter_enabled) | ||
315 | redraw_graph(ginfo); | ||
285 | } | 316 | } |
286 | 317 | ||
287 | static void | 318 | static void |
288 | filter_clear_tasks_clicked (gpointer data) | 319 | filter_clear_tasks_clicked (gpointer data) |
289 | { | 320 | { |
290 | struct graph_info *ginfo = data; | 321 | struct graph_info *ginfo = data; |
322 | gint filter_enabled = ginfo->filter_enabled; | ||
291 | 323 | ||
292 | filter_task_clear(ginfo); | 324 | filter_task_clear(ginfo); |
325 | |||
326 | if (filter_enabled) | ||
327 | redraw_graph(ginfo); | ||
293 | } | 328 | } |
294 | 329 | ||
295 | static gboolean | 330 | static gboolean |
@@ -763,7 +798,6 @@ static void zoom_in_window(struct graph_info *ginfo, gint start, gint end) | |||
763 | gdouble new_width; | 798 | gdouble new_width; |
764 | gdouble select_width; | 799 | gdouble select_width; |
765 | gdouble curr_width; | 800 | gdouble curr_width; |
766 | gdouble height; | ||
767 | gdouble mid; | 801 | gdouble mid; |
768 | gdouble percent; | 802 | gdouble percent; |
769 | gint old_width = ginfo->draw_width; | 803 | gint old_width = ginfo->draw_width; |
@@ -860,11 +894,9 @@ static void zoom_in_window(struct graph_info *ginfo, gint start, gint end) | |||
860 | dprintf(1, "new width=%d\n", ginfo->draw_width); | 894 | dprintf(1, "new width=%d\n", ginfo->draw_width); |
861 | 895 | ||
862 | /* make sure the width is sent */ | 896 | /* make sure the width is sent */ |
863 | if (ginfo->draw_width == old_width) { | 897 | if (ginfo->draw_width == old_width) |
864 | redraw_pixmap_backend(ginfo); | 898 | redraw_graph(ginfo); |
865 | height = ginfo->draw->allocation.height; | 899 | else |
866 | update_with_backend(ginfo, 0, 0, ginfo->draw_width, height); | ||
867 | } else | ||
868 | gtk_widget_set_size_request(ginfo->draw, ginfo->draw_width, ginfo->draw_height); | 900 | gtk_widget_set_size_request(ginfo->draw, ginfo->draw_width, ginfo->draw_height); |
869 | 901 | ||
870 | dprintf(1, "set val %f\n", ginfo->vadj_value); | 902 | dprintf(1, "set val %f\n", ginfo->vadj_value); |
@@ -895,7 +927,6 @@ static void zoom_out_window(struct graph_info *ginfo, gint start, gint end) | |||
895 | gdouble divider; | 927 | gdouble divider; |
896 | gdouble curr_width; | 928 | gdouble curr_width; |
897 | gdouble new_width; | 929 | gdouble new_width; |
898 | gdouble height; | ||
899 | gdouble mid; | 930 | gdouble mid; |
900 | gdouble start_x; | 931 | gdouble start_x; |
901 | unsigned long long time; | 932 | unsigned long long time; |
@@ -950,11 +981,9 @@ static void zoom_out_window(struct graph_info *ginfo, gint start, gint end) | |||
950 | dprintf(1, "new width=%d\n", ginfo->draw_width); | 981 | dprintf(1, "new width=%d\n", ginfo->draw_width); |
951 | 982 | ||
952 | /* make sure the width is sent */ | 983 | /* make sure the width is sent */ |
953 | if (ginfo->draw_width == old_width) { | 984 | if (ginfo->draw_width == old_width) |
954 | redraw_pixmap_backend(ginfo); | 985 | redraw_graph(ginfo); |
955 | height = ginfo->draw->allocation.height; | 986 | else |
956 | update_with_backend(ginfo, 0, 0, ginfo->draw_width, height); | ||
957 | } else | ||
958 | gtk_widget_set_size_request(ginfo->draw, ginfo->draw_width, ginfo->draw_height); | 987 | gtk_widget_set_size_request(ginfo->draw, ginfo->draw_width, ginfo->draw_height); |
959 | 988 | ||
960 | mid = (time - ginfo->view_start_time) * ginfo->resolution; | 989 | mid = (time - ginfo->view_start_time) * ginfo->resolution; |
@@ -988,7 +1017,7 @@ button_release_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | |||
988 | return TRUE; | 1017 | return TRUE; |
989 | } | 1018 | } |
990 | 1019 | ||
991 | static gint do_hash(gint val) | 1020 | static guint do_hash(gint val) |
992 | { | 1021 | { |
993 | int hash, tmp; | 1022 | int hash, tmp; |
994 | 1023 | ||
@@ -1117,6 +1146,7 @@ static void draw_cpu(struct graph_info *ginfo, gint cpu, | |||
1117 | gint p1 = 0, p2 = 0, p3 = 0; | 1146 | gint p1 = 0, p2 = 0, p3 = 0; |
1118 | gint last_event_id = 0; | 1147 | gint last_event_id = 0; |
1119 | gint event_id; | 1148 | gint event_id; |
1149 | gboolean filter; | ||
1120 | const char *comm; | 1150 | const char *comm; |
1121 | 1151 | ||
1122 | /* Calculate the size of 16 characters */ | 1152 | /* Calculate the size of 16 characters */ |
@@ -1179,8 +1209,11 @@ static void draw_cpu(struct graph_info *ginfo, gint cpu, | |||
1179 | last_pid = pid; | 1209 | last_pid = pid; |
1180 | set_color_by_pid(ginfo->draw, gc, pid); | 1210 | set_color_by_pid(ginfo->draw, gc, pid); |
1181 | } | 1211 | } |
1212 | |||
1213 | filter = filter_on_task(ginfo, last_pid); | ||
1182 | 1214 | ||
1183 | if (last_pid) | 1215 | if (!filter && last_pid) |
1216 | |||
1184 | gdk_draw_rectangle(ginfo->curr_pixmap, gc, | 1217 | gdk_draw_rectangle(ginfo->curr_pixmap, gc, |
1185 | TRUE, | 1218 | TRUE, |
1186 | last_x, CPU_BOX_TOP(cpu), | 1219 | last_x, CPU_BOX_TOP(cpu), |
@@ -1192,25 +1225,32 @@ static void draw_cpu(struct graph_info *ginfo, gint cpu, | |||
1192 | set_color_by_pid(ginfo->draw, gc, pid); | 1225 | set_color_by_pid(ginfo->draw, gc, pid); |
1193 | } | 1226 | } |
1194 | 1227 | ||
1195 | gdk_draw_line(ginfo->curr_pixmap, gc, // ginfo->draw->style->black_gc, | 1228 | filter = filter_on_task(ginfo, pid); |
1196 | x, CPU_TOP(cpu), x, CPU_BOTTOM(cpu)); | 1229 | |
1230 | if (!filter) | ||
1231 | gdk_draw_line(ginfo->curr_pixmap, gc, // ginfo->draw->style->black_gc, | ||
1232 | x, CPU_TOP(cpu), x, CPU_BOTTOM(cpu)); | ||
1197 | 1233 | ||
1198 | /* Figure out if we can show the text for the previous record */ | 1234 | if (!filter) { |
1235 | /* Figure out if we can show the text for the previous record */ | ||
1199 | 1236 | ||
1200 | p3 = x; | 1237 | p3 = x; |
1201 | 1238 | ||
1202 | /* Make sure p2 will be non-zero the next iteration */ | 1239 | /* Make sure p2 will be non-zero the next iteration */ |
1203 | if (!p3) | 1240 | if (!p3) |
1204 | p3 = 1; | 1241 | p3 = 1; |
1205 | 1242 | ||
1206 | /* first record, continue */ | 1243 | /* first record, continue */ |
1207 | if (p2) | 1244 | if (p2) |
1208 | draw_event_label(ginfo, cpu, last_event_id, last_pid, | 1245 | draw_event_label(ginfo, cpu, last_event_id, last_pid, |
1209 | p1, p2, p3, width_16, font); | 1246 | p1, p2, p3, width_16, font); |
1247 | |||
1248 | p1 = p2; | ||
1249 | p2 = p3; | ||
1250 | |||
1251 | last_event_id = event_id; | ||
1252 | } | ||
1210 | 1253 | ||
1211 | p1 = p2; | ||
1212 | p2 = p3; | ||
1213 | last_event_id = event_id; | ||
1214 | free_record(record); | 1254 | free_record(record); |
1215 | } | 1255 | } |
1216 | 1256 | ||
@@ -1218,8 +1258,9 @@ static void draw_cpu(struct graph_info *ginfo, gint cpu, | |||
1218 | draw_event_label(ginfo, cpu, last_event_id, last_pid, | 1258 | draw_event_label(ginfo, cpu, last_event_id, last_pid, |
1219 | p1, p2, ginfo->draw_width, width_16, font); | 1259 | p1, p2, ginfo->draw_width, width_16, font); |
1220 | 1260 | ||
1261 | if (last_pid > 0 && | ||
1262 | !filter_on_task(ginfo, last_pid)) { | ||
1221 | 1263 | ||
1222 | if (last_pid > 0) { | ||
1223 | x = ginfo->draw_width; | 1264 | x = ginfo->draw_width; |
1224 | 1265 | ||
1225 | gdk_draw_rectangle(ginfo->curr_pixmap, gc, | 1266 | gdk_draw_rectangle(ginfo->curr_pixmap, gc, |