diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-01-07 15:35:33 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-01-07 15:35:33 -0500 |
commit | 30f7571850c130f3e48b6c05df0c1f092f59106b (patch) | |
tree | 530aac0daab243f3c85edba6731379f72b62d208 | |
parent | 858870d7840afb12b5cd5d68fd54ff5293db77bd (diff) |
trace-view: Add hiding of tasks to list
Pass the task filters for both hiding and filtering from the
graph to the list.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | kernel-shark.c | 61 | ||||
-rw-r--r-- | trace-graph.h | 4 | ||||
-rw-r--r-- | trace-view-store.c | 75 | ||||
-rw-r--r-- | trace-view-store.h | 14 | ||||
-rw-r--r-- | trace-view.c | 9 | ||||
-rw-r--r-- | trace-view.h | 5 |
6 files changed, 140 insertions, 28 deletions
diff --git a/kernel-shark.c b/kernel-shark.c index 4eb0c7e..ddeee9f 100644 --- a/kernel-shark.c +++ b/kernel-shark.c | |||
@@ -217,10 +217,11 @@ filter_list_enable_clicked (gpointer data) | |||
217 | info->list_filter_enabled ^= 1; | 217 | info->list_filter_enabled ^= 1; |
218 | 218 | ||
219 | if (info->list_filter_enabled) | 219 | if (info->list_filter_enabled) |
220 | trace_view_update_task_filter(info->treeview, | 220 | trace_view_update_filters(info->treeview, |
221 | info->ginfo->task_filter); | 221 | info->ginfo->task_filter, |
222 | info->ginfo->hide_tasks); | ||
222 | else | 223 | else |
223 | trace_view_update_task_filter(info->treeview, NULL); | 224 | trace_view_update_filters(info->treeview, NULL, NULL); |
224 | } | 225 | } |
225 | 226 | ||
226 | static void | 227 | static void |
@@ -231,11 +232,9 @@ filter_add_task_clicked (gpointer data) | |||
231 | trace_graph_filter_add_remove_task(info->ginfo, info->selected_task); | 232 | trace_graph_filter_add_remove_task(info->ginfo, info->selected_task); |
232 | 233 | ||
233 | if (info->list_filter_enabled) { | 234 | if (info->list_filter_enabled) { |
234 | if (filter_task_count(info->ginfo->task_filter)) | 235 | trace_view_update_filters(info->treeview, |
235 | trace_view_update_task_filter(info->treeview, | 236 | info->ginfo->task_filter, |
236 | info->ginfo->task_filter); | 237 | info->ginfo->hide_tasks); |
237 | else | ||
238 | trace_view_update_task_filter(info->treeview, NULL); | ||
239 | } | 238 | } |
240 | 239 | ||
241 | if (!filter_task_count(info->ginfo->task_filter)) | 240 | if (!filter_task_count(info->ginfo->task_filter)) |
@@ -243,6 +242,24 @@ filter_add_task_clicked (gpointer data) | |||
243 | } | 242 | } |
244 | 243 | ||
245 | static void | 244 | static void |
245 | filter_hide_task_clicked (gpointer data) | ||
246 | { | ||
247 | struct shark_info *info = data; | ||
248 | |||
249 | trace_graph_filter_hide_show_task(info->ginfo, info->selected_task); | ||
250 | |||
251 | if (info->list_filter_enabled) { | ||
252 | trace_view_update_filters(info->treeview, | ||
253 | info->ginfo->task_filter, | ||
254 | info->ginfo->hide_tasks); | ||
255 | } | ||
256 | |||
257 | if (!filter_task_count(info->ginfo->task_filter) && | ||
258 | !filter_task_count(info->ginfo->hide_tasks)) | ||
259 | info->list_filter_enabled = 0; | ||
260 | } | ||
261 | |||
262 | static void | ||
246 | filter_clear_tasks_clicked (gpointer data) | 263 | filter_clear_tasks_clicked (gpointer data) |
247 | { | 264 | { |
248 | struct shark_info *info = data; | 265 | struct shark_info *info = data; |
@@ -250,7 +267,7 @@ filter_clear_tasks_clicked (gpointer data) | |||
250 | trace_graph_clear_tasks(info->ginfo); | 267 | trace_graph_clear_tasks(info->ginfo); |
251 | 268 | ||
252 | if (info->list_filter_enabled) | 269 | if (info->list_filter_enabled) |
253 | trace_view_update_task_filter(info->treeview, NULL); | 270 | trace_view_update_filters(info->treeview, NULL, NULL); |
254 | 271 | ||
255 | info->list_filter_enabled = 0; | 272 | info->list_filter_enabled = 0; |
256 | } | 273 | } |
@@ -264,6 +281,7 @@ do_tree_popup(GtkWidget *widget, GdkEventButton *event, gpointer data) | |||
264 | static GtkWidget *menu_filter_graph_enable; | 281 | static GtkWidget *menu_filter_graph_enable; |
265 | static GtkWidget *menu_filter_list_enable; | 282 | static GtkWidget *menu_filter_list_enable; |
266 | static GtkWidget *menu_filter_add_task; | 283 | static GtkWidget *menu_filter_add_task; |
284 | static GtkWidget *menu_filter_hide_task; | ||
267 | static GtkWidget *menu_filter_clear_tasks; | 285 | static GtkWidget *menu_filter_clear_tasks; |
268 | struct record *record; | 286 | struct record *record; |
269 | TraceViewRecord *vrec; | 287 | TraceViewRecord *vrec; |
@@ -306,6 +324,14 @@ do_tree_popup(GtkWidget *widget, GdkEventButton *event, gpointer data) | |||
306 | G_CALLBACK (filter_add_task_clicked), | 324 | G_CALLBACK (filter_add_task_clicked), |
307 | data); | 325 | data); |
308 | 326 | ||
327 | menu_filter_hide_task = gtk_menu_item_new_with_label("Hide Task"); | ||
328 | gtk_widget_show(menu_filter_hide_task); | ||
329 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_filter_hide_task); | ||
330 | |||
331 | g_signal_connect_swapped (G_OBJECT (menu_filter_hide_task), "activate", | ||
332 | G_CALLBACK (filter_hide_task_clicked), | ||
333 | data); | ||
334 | |||
309 | menu_filter_clear_tasks = gtk_menu_item_new_with_label("Clear Task Filter"); | 335 | menu_filter_clear_tasks = gtk_menu_item_new_with_label("Clear Task Filter"); |
310 | gtk_widget_show(menu_filter_clear_tasks); | 336 | gtk_widget_show(menu_filter_clear_tasks); |
311 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_filter_clear_tasks); | 337 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_filter_clear_tasks); |
@@ -350,15 +376,27 @@ do_tree_popup(GtkWidget *widget, GdkEventButton *event, gpointer data) | |||
350 | 376 | ||
351 | gtk_menu_item_set_label(GTK_MENU_ITEM(menu_filter_add_task), | 377 | gtk_menu_item_set_label(GTK_MENU_ITEM(menu_filter_add_task), |
352 | text); | 378 | text); |
379 | |||
380 | if (trace_graph_hide_task_find_pid(ginfo, pid)) | ||
381 | snprintf(text, len, "Show %s-%d", comm, pid); | ||
382 | else | ||
383 | snprintf(text, len, "Hide %s-%d", comm, pid); | ||
384 | |||
385 | gtk_menu_item_set_label(GTK_MENU_ITEM(menu_filter_hide_task), | ||
386 | text); | ||
387 | |||
353 | g_free(text); | 388 | g_free(text); |
354 | 389 | ||
355 | info->selected_task = pid; | 390 | info->selected_task = pid; |
356 | 391 | ||
357 | gtk_widget_show(menu_filter_add_task); | 392 | gtk_widget_show(menu_filter_add_task); |
393 | gtk_widget_show(menu_filter_hide_task); | ||
358 | free_record(record); | 394 | free_record(record); |
359 | } | 395 | } |
360 | } else | 396 | } else { |
361 | gtk_widget_hide(menu_filter_add_task); | 397 | gtk_widget_hide(menu_filter_add_task); |
398 | gtk_widget_hide(menu_filter_hide_task); | ||
399 | } | ||
362 | 400 | ||
363 | if (ginfo->filter_enabled) | 401 | if (ginfo->filter_enabled) |
364 | gtk_menu_item_set_label(GTK_MENU_ITEM(menu_filter_graph_enable), | 402 | gtk_menu_item_set_label(GTK_MENU_ITEM(menu_filter_graph_enable), |
@@ -382,7 +420,8 @@ do_tree_popup(GtkWidget *widget, GdkEventButton *event, gpointer data) | |||
382 | gtk_widget_set_sensitive(menu_filter_list_enable, FALSE); | 420 | gtk_widget_set_sensitive(menu_filter_list_enable, FALSE); |
383 | } | 421 | } |
384 | 422 | ||
385 | if (filter_task_count(ginfo->task_filter)) | 423 | if (filter_task_count(ginfo->task_filter) || |
424 | filter_task_count(ginfo->hide_tasks)) | ||
386 | gtk_widget_set_sensitive(menu_filter_clear_tasks, TRUE); | 425 | gtk_widget_set_sensitive(menu_filter_clear_tasks, TRUE); |
387 | else | 426 | else |
388 | gtk_widget_set_sensitive(menu_filter_clear_tasks, FALSE); | 427 | gtk_widget_set_sensitive(menu_filter_clear_tasks, FALSE); |
diff --git a/trace-graph.h b/trace-graph.h index 91a3acd..d323acb 100644 --- a/trace-graph.h +++ b/trace-graph.h | |||
@@ -106,9 +106,13 @@ static inline GtkWidget *trace_graph_get_window(struct graph_info *ginfo) | |||
106 | 106 | ||
107 | struct filter_task_item * | 107 | struct filter_task_item * |
108 | trace_graph_filter_task_find_pid(struct graph_info *ginfo, gint pid); | 108 | trace_graph_filter_task_find_pid(struct graph_info *ginfo, gint pid); |
109 | struct filter_task_item * | ||
110 | trace_graph_hide_task_find_pid(struct graph_info *ginfo, gint pid); | ||
109 | void trace_graph_filter_toggle(struct graph_info *ginfo); | 111 | void trace_graph_filter_toggle(struct graph_info *ginfo); |
110 | void trace_graph_filter_add_remove_task(struct graph_info *info, | 112 | void trace_graph_filter_add_remove_task(struct graph_info *info, |
111 | gint pid); | 113 | gint pid); |
114 | void trace_graph_filter_hide_show_task(struct graph_info *ginfo, | ||
115 | gint pid); | ||
112 | void trace_graph_clear_tasks(struct graph_info *ginfo); | 116 | void trace_graph_clear_tasks(struct graph_info *ginfo); |
113 | 117 | ||
114 | #endif /* _TRACE_GRAPH_H */ | 118 | #endif /* _TRACE_GRAPH_H */ |
diff --git a/trace-view-store.c b/trace-view-store.c index 3ea7e3b..14d8b17 100644 --- a/trace-view-store.c +++ b/trace-view-store.c | |||
@@ -1249,7 +1249,17 @@ gint get_next_pid(TraceViewStore *store, struct pevent *pevent, struct record *r | |||
1249 | return val; | 1249 | return val; |
1250 | } | 1250 | } |
1251 | 1251 | ||
1252 | void trace_view_store_filter_tasks(TraceViewStore *store, struct filter_task *filter) | 1252 | static gboolean show_task(TraceViewStore *store, gint pid) |
1253 | { | ||
1254 | return (!store->task_filter || | ||
1255 | !filter_task_count(store->task_filter) || | ||
1256 | filter_task_find_pid(store->task_filter, pid)) && | ||
1257 | (!store->hide_tasks || | ||
1258 | !filter_task_count(store->hide_tasks) || | ||
1259 | !filter_task_find_pid(store->hide_tasks, pid)); | ||
1260 | } | ||
1261 | |||
1262 | static void update_filter_tasks(TraceViewStore *store) | ||
1253 | { | 1263 | { |
1254 | struct tracecmd_input *handle; | 1264 | struct tracecmd_input *handle; |
1255 | struct event_format *event; | 1265 | struct event_format *event; |
@@ -1261,14 +1271,6 @@ void trace_view_store_filter_tasks(TraceViewStore *store, struct filter_task *fi | |||
1261 | gint cpu; | 1271 | gint cpu; |
1262 | gint i; | 1272 | gint i; |
1263 | 1273 | ||
1264 | g_return_if_fail (TRACE_VIEW_IS_LIST (store)); | ||
1265 | |||
1266 | /* We may pass in the store->task_filter. Don't free it if we do */ | ||
1267 | if (store->task_filter && store->task_filter != filter) | ||
1268 | filter_task_hash_free(store->task_filter); | ||
1269 | |||
1270 | store->task_filter = filter_task_hash_copy(filter); | ||
1271 | |||
1272 | handle = store->handle; | 1274 | handle = store->handle; |
1273 | pevent = tracecmd_get_pevent(store->handle); | 1275 | pevent = tracecmd_get_pevent(store->handle); |
1274 | 1276 | ||
@@ -1305,7 +1307,7 @@ void trace_view_store_filter_tasks(TraceViewStore *store, struct filter_task *fi | |||
1305 | } | 1307 | } |
1306 | 1308 | ||
1307 | pid = pevent_data_pid(pevent, record); | 1309 | pid = pevent_data_pid(pevent, record); |
1308 | if (!filter || filter_task_find_pid(filter, pid)) | 1310 | if (show_task(store, pid)) |
1309 | store->cpu_list[cpu][i].visible = 1; | 1311 | store->cpu_list[cpu][i].visible = 1; |
1310 | else { | 1312 | else { |
1311 | if (store->sched_switch_next_field && | 1313 | if (store->sched_switch_next_field && |
@@ -1313,7 +1315,7 @@ void trace_view_store_filter_tasks(TraceViewStore *store, struct filter_task *fi | |||
1313 | store->sched_switch_event->id) { | 1315 | store->sched_switch_event->id) { |
1314 | /* show sched switch to task */ | 1316 | /* show sched switch to task */ |
1315 | pid = get_next_pid(store, pevent, record); | 1317 | pid = get_next_pid(store, pevent, record); |
1316 | if (filter_task_find_pid(filter, pid)) | 1318 | if (show_task(store, pid)) |
1317 | store->cpu_list[cpu][i].visible = 1; | 1319 | store->cpu_list[cpu][i].visible = 1; |
1318 | else | 1320 | else |
1319 | store->cpu_list[cpu][i].visible = 0; | 1321 | store->cpu_list[cpu][i].visible = 0; |
@@ -1331,11 +1333,60 @@ void trace_view_store_filter_tasks(TraceViewStore *store, struct filter_task *fi | |||
1331 | merge_sort_rows_ts(store); | 1333 | merge_sort_rows_ts(store); |
1332 | } | 1334 | } |
1333 | 1335 | ||
1336 | void trace_view_store_filter_tasks(TraceViewStore *store, struct filter_task *filter) | ||
1337 | { | ||
1338 | g_return_if_fail (TRACE_VIEW_IS_LIST (store)); | ||
1339 | |||
1340 | /* We may pass in the store->task_filter. Don't free it if we do */ | ||
1341 | if (store->task_filter && store->task_filter != filter) | ||
1342 | filter_task_hash_free(store->task_filter); | ||
1343 | |||
1344 | if (store->task_filter != filter) | ||
1345 | store->task_filter = filter_task_hash_copy(filter); | ||
1346 | |||
1347 | update_filter_tasks(store); | ||
1348 | } | ||
1349 | |||
1350 | void trace_view_store_hide_tasks(TraceViewStore *store, struct filter_task *filter) | ||
1351 | { | ||
1352 | g_return_if_fail (TRACE_VIEW_IS_LIST (store)); | ||
1353 | |||
1354 | /* We may pass in the store->task_filter. Don't free it if we do */ | ||
1355 | if (store->hide_tasks && store->hide_tasks != filter) | ||
1356 | filter_task_hash_free(store->hide_tasks); | ||
1357 | |||
1358 | if (store->hide_tasks != filter) | ||
1359 | store->hide_tasks = filter_task_hash_copy(filter); | ||
1360 | |||
1361 | update_filter_tasks(store); | ||
1362 | } | ||
1363 | |||
1334 | void trace_view_store_update_filter(TraceViewStore *store) | 1364 | void trace_view_store_update_filter(TraceViewStore *store) |
1335 | { | 1365 | { |
1336 | g_return_if_fail (TRACE_VIEW_IS_LIST (store)); | 1366 | g_return_if_fail (TRACE_VIEW_IS_LIST (store)); |
1337 | 1367 | ||
1338 | trace_view_store_filter_tasks(store, store->task_filter); | 1368 | update_filter_tasks(store); |
1369 | } | ||
1370 | |||
1371 | void trace_view_store_assign_filters(TraceViewStore *store, | ||
1372 | struct filter_task *task_filter, | ||
1373 | struct filter_task *hide_tasks) | ||
1374 | { | ||
1375 | g_return_if_fail (TRACE_VIEW_IS_LIST (store)); | ||
1376 | |||
1377 | /* We may pass in the store->task_filter. Don't free it if we do */ | ||
1378 | if (store->task_filter && store->task_filter != task_filter) | ||
1379 | filter_task_hash_free(store->task_filter); | ||
1380 | |||
1381 | if (store->hide_tasks && store->hide_tasks != hide_tasks) | ||
1382 | filter_task_hash_free(store->hide_tasks); | ||
1383 | |||
1384 | if (store->hide_tasks != hide_tasks) | ||
1385 | store->hide_tasks = filter_task_hash_copy(hide_tasks); | ||
1386 | |||
1387 | if (store->task_filter != task_filter) | ||
1388 | store->task_filter = filter_task_hash_copy(task_filter); | ||
1389 | |||
1339 | } | 1390 | } |
1340 | 1391 | ||
1341 | 1392 | ||
diff --git a/trace-view-store.h b/trace-view-store.h index 07c3a24..bceb2de 100644 --- a/trace-view-store.h +++ b/trace-view-store.h | |||
@@ -98,6 +98,7 @@ struct trace_view_store | |||
98 | gint systems_size; /* size of systems array */ | 98 | gint systems_size; /* size of systems array */ |
99 | gint event_types_size; /* size of event_types array */ | 99 | gint event_types_size; /* size of event_types array */ |
100 | struct filter_task *task_filter; /* hash of tasks to filter on */ | 100 | struct filter_task *task_filter; /* hash of tasks to filter on */ |
101 | struct filter_task *hide_tasks; /* hash of tasks to not display */ | ||
101 | 102 | ||
102 | gint all_cpus; /* set 1 when all cpus are enabled */ | 103 | gint all_cpus; /* set 1 when all cpus are enabled */ |
103 | /* else */ | 104 | /* else */ |
@@ -122,6 +123,12 @@ gint trace_view_store_get_timestamp_visible_row(TraceViewStore *store, guint64 t | |||
122 | 123 | ||
123 | void trace_view_store_filter_tasks(TraceViewStore *store, struct filter_task *filter); | 124 | void trace_view_store_filter_tasks(TraceViewStore *store, struct filter_task *filter); |
124 | 125 | ||
126 | void trace_view_store_hide_tasks(TraceViewStore *store, struct filter_task *filter); | ||
127 | |||
128 | void trace_view_store_assign_filters(TraceViewStore *store, | ||
129 | struct filter_task *task_filter, | ||
130 | struct filter_task *hide_tasks); | ||
131 | |||
125 | TraceViewRecord *trace_view_store_get_row(TraceViewStore *store, gint row); | 132 | TraceViewRecord *trace_view_store_get_row(TraceViewStore *store, gint row); |
126 | 133 | ||
127 | gboolean trace_view_store_system_enabled(TraceViewStore *store, const gchar *system); | 134 | gboolean trace_view_store_system_enabled(TraceViewStore *store, const gchar *system); |
@@ -198,6 +205,12 @@ static inline gint trace_view_store_get_page(TraceViewStore *store) | |||
198 | return store->page; | 205 | return store->page; |
199 | } | 206 | } |
200 | 207 | ||
208 | static inline gint trace_view_store_visible_rows(TraceViewStore *store) | ||
209 | { | ||
210 | g_return_val_if_fail (TRACE_VIEW_IS_LIST (store), 0); | ||
211 | return store->visible_rows; | ||
212 | } | ||
213 | |||
201 | static inline GtkWidget *trace_view_store_get_spin(TraceViewStore *store) | 214 | static inline GtkWidget *trace_view_store_get_spin(TraceViewStore *store) |
202 | { | 215 | { |
203 | g_return_val_if_fail (TRACE_VIEW_IS_LIST (store), NULL); | 216 | g_return_val_if_fail (TRACE_VIEW_IS_LIST (store), NULL); |
@@ -222,5 +235,4 @@ static inline gint *trace_view_store_get_events_enabled(TraceViewStore *store) | |||
222 | return store->event_types; | 235 | return store->event_types; |
223 | } | 236 | } |
224 | 237 | ||
225 | |||
226 | #endif /* _trace_view_store_h_included_ */ | 238 | #endif /* _trace_view_store_h_included_ */ |
diff --git a/trace-view.c b/trace-view.c index c73f95a..a00e877 100644 --- a/trace-view.c +++ b/trace-view.c | |||
@@ -271,7 +271,9 @@ void trace_view_make_selection_visible(GtkWidget *treeview) | |||
271 | gtk_tree_path_free(path); | 271 | gtk_tree_path_free(path); |
272 | } | 272 | } |
273 | 273 | ||
274 | void trace_view_update_task_filter(GtkWidget *treeview, struct filter_task *filter) | 274 | void trace_view_update_filters(GtkWidget *treeview, |
275 | struct filter_task *task_filter, | ||
276 | struct filter_task *hide_tasks) | ||
275 | { | 277 | { |
276 | GtkTreeView *tree = GTK_TREE_VIEW(treeview); | 278 | GtkTreeView *tree = GTK_TREE_VIEW(treeview); |
277 | TraceViewRecord *vrec; | 279 | TraceViewRecord *vrec; |
@@ -293,13 +295,14 @@ void trace_view_update_task_filter(GtkWidget *treeview, struct filter_task *filt | |||
293 | g_object_ref(model); | 295 | g_object_ref(model); |
294 | gtk_tree_view_set_model(tree, NULL); | 296 | gtk_tree_view_set_model(tree, NULL); |
295 | 297 | ||
296 | trace_view_store_filter_tasks(TRACE_VIEW_STORE(model), filter); | 298 | trace_view_store_assign_filters(TRACE_VIEW_STORE(model), task_filter, hide_tasks); |
299 | trace_view_store_update_filter(TRACE_VIEW_STORE(model)); | ||
297 | 300 | ||
298 | gtk_tree_view_set_model(tree, model); | 301 | gtk_tree_view_set_model(tree, model); |
299 | g_object_unref(model); | 302 | g_object_unref(model); |
300 | 303 | ||
301 | /* Keep selection near previous selection */ | 304 | /* Keep selection near previous selection */ |
302 | if (row >= 0) | 305 | if (row >= 0 && trace_view_store_visible_rows(TRACE_VIEW_STORE(model))) |
303 | trace_view_select(treeview, time); | 306 | trace_view_select(treeview, time); |
304 | } | 307 | } |
305 | 308 | ||
diff --git a/trace-view.h b/trace-view.h index 2b34f23..b637d82 100644 --- a/trace-view.h +++ b/trace-view.h | |||
@@ -10,7 +10,10 @@ trace_view_load(GtkWidget *view, struct tracecmd_input *handle, | |||
10 | 10 | ||
11 | void trace_view(int argc, char **argv); | 11 | void trace_view(int argc, char **argv); |
12 | 12 | ||
13 | void trace_view_update_task_filter(GtkWidget *treeview, struct filter_task *filter); | 13 | void trace_view_update_filters(GtkWidget *treeview, |
14 | struct filter_task *task_filter, | ||
15 | struct filter_task *hide_tasks); | ||
16 | |||
14 | void trace_view_make_selection_visible(GtkWidget *treeview); | 17 | void trace_view_make_selection_visible(GtkWidget *treeview); |
15 | 18 | ||
16 | void trace_view_select(GtkWidget *treeview, guint64 time); | 19 | void trace_view_select(GtkWidget *treeview, guint64 time); |