aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-06-10 16:33:59 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-06-10 16:33:59 -0400
commitf501cf496f91df0a71a41aee74d1b213799d85e4 (patch)
tree105e6ae0558f2a1d81dda1acecc2087e5c6e7d79
parentce6dcdc247fc6194566360e74fcb986fa656043a (diff)
kernelshark: Add tests if task filters are same
On load of task filters, if they are the same, then make them synced. On syncing of task filters, if they are already the same, do not ask which way to sync, just sync them and keep them synced. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--kernel-shark.c79
-rw-r--r--trace-hash.c36
-rw-r--r--trace-hash.h1
3 files changed, 91 insertions, 25 deletions
diff --git a/kernel-shark.c b/kernel-shark.c
index 91ecf82..3a0d0fb 100644
--- a/kernel-shark.c
+++ b/kernel-shark.c
@@ -241,6 +241,19 @@ static void unsync_task_filters(struct shark_info *info)
241 info->list_hide_tasks = filter_task_hash_copy(info->ginfo->hide_tasks); 241 info->list_hide_tasks = filter_task_hash_copy(info->ginfo->hide_tasks);
242} 242}
243 243
244static void sync_task_filters(struct shark_info *info)
245{
246 info->sync_task_filters = 1;
247 gtk_menu_item_set_label(GTK_MENU_ITEM(info->task_sync_menu),
248 "Unsync Graph and List Task Filters");
249 gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_task_menu),
250 "tasks");
251 gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_hide_task_menu),
252 "hide tasks");
253 gtk_widget_hide(info->list_task_menu);
254 gtk_widget_hide(info->list_hide_task_menu);
255}
256
244static void unsync_event_filters(struct shark_info *info) 257static void unsync_event_filters(struct shark_info *info)
245{ 258{
246 info->sync_event_filters = 0; 259 info->sync_event_filters = 0;
@@ -255,6 +268,19 @@ static void unsync_event_filters(struct shark_info *info)
255 gtk_widget_show(info->list_adv_events_menu); 268 gtk_widget_show(info->list_adv_events_menu);
256} 269}
257 270
271static void sync_event_filters(struct shark_info *info)
272{
273 info->sync_event_filters = 1;
274 gtk_menu_item_set_label(GTK_MENU_ITEM(info->events_sync_menu),
275 "Unsync Graph and List Event Filters");
276 gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_events_menu),
277 "events");
278 gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_adv_events_menu),
279 "advanced events");
280 gtk_widget_hide(info->list_events_menu);
281 gtk_widget_hide(info->list_adv_events_menu);
282}
283
258static void 284static void
259/* Callback for the clicked signal of the Load button */ 285/* Callback for the clicked signal of the Load button */
260load_clicked (gpointer data) 286load_clicked (gpointer data)
@@ -341,6 +367,16 @@ load_filters_clicked (gpointer data)
341 367
342 tracecmd_xml_close(handle); 368 tracecmd_xml_close(handle);
343 369
370 /*
371 * If the events or tasks filters are the same for both
372 * the list and graph, then sync them back.
373 */
374 if (filter_task_compare(ginfo->task_filter,
375 info->list_task_filter) &&
376 filter_task_compare(ginfo->hide_tasks,
377 info->list_hide_tasks))
378 sync_task_filters(info);
379
344 out: 380 out:
345 g_free(filename); 381 g_free(filename);
346 382
@@ -442,9 +478,17 @@ sync_task_filter_clicked (GtkWidget *subitem, gpointer data)
442 478
443 store = TRACE_VIEW_STORE(model); 479 store = TRACE_VIEW_STORE(model);
444 480
445 /* Ask user which way to sync */ 481 /* If they are already equal, then just perminently sync them */
446 result = trace_sync_select_menu("Sync Task Filters", 482 if (filter_task_compare(info->ginfo->task_filter,
447 selections, &keep); 483 info->list_task_filter) &&
484 filter_task_compare(info->ginfo->hide_tasks,
485 info->list_hide_tasks))
486 result = 2;
487
488 else
489 /* Ask user which way to sync */
490 result = trace_sync_select_menu("Sync Task Filters",
491 selections, &keep);
448 492
449 switch (result) { 493 switch (result) {
450 case 0: 494 case 0:
@@ -480,21 +524,15 @@ sync_task_filter_clicked (GtkWidget *subitem, gpointer data)
480 info->list_hide_tasks = NULL; 524 info->list_hide_tasks = NULL;
481 } 525 }
482 break; 526 break;
527 case 2:
528 keep = 1;
529 break;
483 default: 530 default:
484 keep = 0; 531 keep = 0;
485 } 532 }
486 533
487 if (keep) { 534 if (keep)
488 info->sync_task_filters = 1; 535 sync_task_filters(info);
489 gtk_menu_item_set_label(GTK_MENU_ITEM(info->task_sync_menu),
490 "Unsync Graph and List Task Filters");
491 gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_task_menu),
492 "tasks");
493 gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_hide_task_menu),
494 "hide tasks");
495 gtk_widget_hide(info->list_task_menu);
496 gtk_widget_hide(info->list_hide_task_menu);
497 }
498} 536}
499 537
500/* Callback for the clicked signal of the events sync filter button */ 538/* Callback for the clicked signal of the events sync filter button */
@@ -550,17 +588,8 @@ sync_events_filter_clicked (GtkWidget *subitem, gpointer data)
550 keep = 0; 588 keep = 0;
551 } 589 }
552 590
553 if (keep) { 591 if (keep)
554 info->sync_event_filters = 1; 592 sync_event_filters(info);
555 gtk_menu_item_set_label(GTK_MENU_ITEM(info->events_sync_menu),
556 "Unsync Graph and List Event Filters");
557 gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_events_menu),
558 "events");
559 gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_adv_events_menu),
560 "advanced events");
561 gtk_widget_hide(info->list_events_menu);
562 gtk_widget_hide(info->list_adv_events_menu);
563 }
564} 593}
565 594
566static void filter_list_enable_clicked (gpointer data); 595static void filter_list_enable_clicked (gpointer data);
diff --git a/trace-hash.c b/trace-hash.c
index 3349715..ed53ee1 100644
--- a/trace-hash.c
+++ b/trace-hash.c
@@ -182,3 +182,39 @@ int *filter_task_pids(struct filter_task *hash)
182 182
183 return pids; 183 return pids;
184} 184}
185
186/**
187 * filter_task_compare - compare two task hashs to see if they are equal
188 * @hash1: one hash to compare
189 * @hash2: another hash to compare to @hash1
190 *
191 * Returns 1 if the two hashes are the same, 0 otherwise.
192 */
193int filter_task_compare(struct filter_task *hash1, struct filter_task *hash2)
194{
195 int *pids;
196 int ret = 0;
197 int i;
198
199 /* If counts don't match, then they obviously are not the same */
200 if (hash1->count != hash2->count)
201 return 0;
202
203 /* If both hashes are empty, they are the same */
204 if (!hash1->count && !hash2->count)
205 return 1;
206
207 /* Now compare the pids of one hash with the other */
208 pids = filter_task_pids(hash1);
209 for (i = 0; pids[i] >= 0; i++) {
210 if (!filter_task_find_pid(hash2, pids[i]))
211 break;
212 }
213
214 if (pids[i] == -1)
215 ret = 1;
216
217 free(pids);
218
219 return ret;
220}
diff --git a/trace-hash.h b/trace-hash.h
index 29088e7..b5296eb 100644
--- a/trace-hash.h
+++ b/trace-hash.h
@@ -43,6 +43,7 @@ struct filter_task *filter_task_hash_alloc(void);
43void filter_task_hash_free(struct filter_task *hash); 43void filter_task_hash_free(struct filter_task *hash);
44struct filter_task *filter_task_hash_copy(struct filter_task *hash); 44struct filter_task *filter_task_hash_copy(struct filter_task *hash);
45int *filter_task_pids(struct filter_task *hash); 45int *filter_task_pids(struct filter_task *hash);
46int filter_task_compare(struct filter_task *hash1, struct filter_task *hash2);
46 47
47static inline gint filter_task_count(struct filter_task *hash) 48static inline gint filter_task_count(struct filter_task *hash)
48{ 49{