From 64be78aa61dfda0c5fdf5c7ccfc2d9a93ba52aa5 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Mon, 5 Apr 2010 20:56:05 -0400 Subject: trace-view: Add save and load of task filters Include saving of the task filters to the filter file as well as the ability to load them. Signed-off-by: Steven Rostedt --- trace-hash.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'trace-hash.c') diff --git a/trace-hash.c b/trace-hash.c index 1197913..3349715 100644 --- a/trace-hash.c +++ b/trace-hash.c @@ -19,6 +19,7 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include +#include #include #include @@ -155,3 +156,29 @@ struct filter_task *filter_task_hash_copy(struct filter_task *hash) return new_hash; } + +int *filter_task_pids(struct filter_task *hash) +{ + struct filter_task_item *task; + int *pids; + int count = 0; + int i; + + if (!hash->count) + return NULL; + + pids = malloc(sizeof(*pids) * (hash->count + 1)); + if (!pids) + return NULL; + + for (i = 0; i < FILTER_TASK_HASH_SIZE; i++) { + task = hash->hash[i]; + while (task) { + pids[count++] = task->pid; + task = task->next; + } + } + pids[count] = -1; + + return pids; +} -- cgit v1.2.2 From f501cf496f91df0a71a41aee74d1b213799d85e4 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Thu, 10 Jun 2010 16:33:59 -0400 Subject: 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 --- trace-hash.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'trace-hash.c') 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) return pids; } + +/** + * filter_task_compare - compare two task hashs to see if they are equal + * @hash1: one hash to compare + * @hash2: another hash to compare to @hash1 + * + * Returns 1 if the two hashes are the same, 0 otherwise. + */ +int filter_task_compare(struct filter_task *hash1, struct filter_task *hash2) +{ + int *pids; + int ret = 0; + int i; + + /* If counts don't match, then they obviously are not the same */ + if (hash1->count != hash2->count) + return 0; + + /* If both hashes are empty, they are the same */ + if (!hash1->count && !hash2->count) + return 1; + + /* Now compare the pids of one hash with the other */ + pids = filter_task_pids(hash1); + for (i = 0; pids[i] >= 0; i++) { + if (!filter_task_find_pid(hash2, pids[i])) + break; + } + + if (pids[i] == -1) + ret = 1; + + free(pids); + + return ret; +} -- cgit v1.2.2