So far we have only one method that creates a new Data Collection. It is kshark_register_data_collection(). The problem with this method is that it automatically adds the new collection to the list of collections, owned by the context of the session. This patch adds a more generic method, which can be used to add new data collection to a given list. The method will be used by the Sched event plugin, which will keep its own list of collections, relevant only for the plugin. Signed-off-by: Yordan Karadzhov <ykaradzhov@xxxxxxxxxx> --- kernel-shark-qt/src/libkshark-collection.c | 45 +++++++++++++++++++++- kernel-shark-qt/src/libkshark.c | 1 + kernel-shark-qt/src/libkshark.h | 9 +++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/kernel-shark-qt/src/libkshark-collection.c b/kernel-shark-qt/src/libkshark-collection.c index 9838042..c70da1e 100644 --- a/kernel-shark-qt/src/libkshark-collection.c +++ b/kernel-shark-qt/src/libkshark-collection.c @@ -781,14 +781,55 @@ kshark_register_data_collection(struct kshark_context *kshark_ctx, { struct kshark_entry_collection *col; + col = kshark_add_collection_to_list(kshark_ctx, + &kshark_ctx->collections, + data, n_rows, + cond, val, + margin); + + return col; +} + +/** + * @brief Allocate and process data collection, defined with a given Matching + * condition function and value. Add this collection to a given list of + * collections. + * + * @param kshark_ctx: Input location for the session context pointer. + * @param col_list: Input location for the list of collections. + * @param data: Input location for the trace data. + * @param n_rows: The size of the inputted data. + * @param cond: Matching condition function for the collection to be + * registered. + * @param val: Matching condition value of for collection to be registered. + * @param margin: The size of the additional (margin) data which do not + * satisfy the matching condition, but is added at the + * beginning and at the end of each interval of the collection + * as well as at the beginning and at the end of data-set. If + * "0", no margin data is added. + * + * @returns Pointer to the registered Data collections on success, or NULL + * on failure. + */ +struct kshark_entry_collection * +kshark_add_collection_to_list(struct kshark_context *kshark_ctx, + struct kshark_entry_collection **col_list, + struct kshark_entry **data, + size_t n_rows, + matching_condition_func cond, + int val, + size_t margin) +{ + struct kshark_entry_collection *col; + col = kshark_data_collection_alloc(kshark_ctx, data, 0, n_rows, cond, val, margin); if (col) { - col->next = kshark_ctx->collections; - kshark_ctx->collections = col; + col->next = *col_list; + *col_list = col; } return col; diff --git a/kernel-shark-qt/src/libkshark.c b/kernel-shark-qt/src/libkshark.c index 86d3e58..598ea52 100644 --- a/kernel-shark-qt/src/libkshark.c +++ b/kernel-shark-qt/src/libkshark.c @@ -33,6 +33,7 @@ static bool kshark_default_context(struct kshark_context **context) return false; kshark_ctx->event_handlers = NULL; + kshark_ctx->collections = NULL; kshark_ctx->plugins = NULL; kshark_ctx->show_task_filter = tracecmd_filter_id_hash_alloc(); diff --git a/kernel-shark-qt/src/libkshark.h b/kernel-shark-qt/src/libkshark.h index b3bd646..7d1edfc 100644 --- a/kernel-shark-qt/src/libkshark.h +++ b/kernel-shark-qt/src/libkshark.h @@ -412,6 +412,15 @@ struct kshark_entry_collection { size_t size; }; +struct kshark_entry_collection * +kshark_add_collection_to_list(struct kshark_context *kshark_ctx, + struct kshark_entry_collection **col_list, + struct kshark_entry **data, + size_t n_rows, + matching_condition_func cond, + int val, + size_t margin); + struct kshark_entry_collection * kshark_register_data_collection(struct kshark_context *kshark_ctx, struct kshark_entry **data, size_t n_rows, -- 2.17.1