Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761254AbbKTU75 (ORCPT ); Fri, 20 Nov 2015 15:59:57 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:57486 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161343AbbKTU5r (ORCPT ); Fri, 20 Nov 2015 15:57:47 -0500 From: Josef Bacik To: , , Subject: [PATCH 03/11] trace-cmd: add a function to create a top instance Date: Fri, 20 Nov 2015 15:57:25 -0500 Message-ID: <1448053053-24188-4-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1448053053-24188-1-git-send-email-jbacik@fb.com> References: <1448053053-24188-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2015-11-20_12:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2829 Lines: 89 We need a way to allow external applications to create an instance for doing their tracing, so add a helper function that takes care of creating an instance, setting it as the main instance and doing the heavy lifting of creating the instance in the tracing directory. Thanks, Signed-off-by: Josef Bacik --- trace-cmd.h | 2 ++ trace-record.c | 25 ++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/trace-cmd.h b/trace-cmd.h index 2e59b46..b4fa7fd 100644 --- a/trace-cmd.h +++ b/trace-cmd.h @@ -123,6 +123,8 @@ int tracecmd_buffer_instances(struct tracecmd_input *handle); const char *tracecmd_buffer_instance_name(struct tracecmd_input *handle, int indx); struct tracecmd_input *tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx); int tracecmd_is_buffer_instance(struct tracecmd_input *handle); +void tracecmd_create_top_instance(char *name); +void tracecmd_remove_instances(void); void tracecmd_print_events(struct tracecmd_input *handle, const char *regex); diff --git a/trace-record.c b/trace-record.c index 616e17b..417b701 100644 --- a/trace-record.c +++ b/trace-record.c @@ -3342,7 +3342,7 @@ static void make_instances(void) } } -static void remove_instances(void) +void tracecmd_remove_instances(void) { struct buffer_instance *instance; char *path; @@ -3364,6 +3364,25 @@ static void remove_instances(void) } } +/** + * tracecmd_create_top_instance - create a top named instance + * @name: name of the instance to use. + * + * This is a library function for tools that want to do their tracing inside of + * an instance. All it does is create an instance and set it as a top instance, + * you don't want to call this more than once, and you want to call + * tracecmd_remove_instances to undo your work. + */ +void tracecmd_create_top_instance(char *name) +{ + struct buffer_instance *instance; + + instance = create_instance(name); + add_instance(instance); + update_first_instance(instance, 0); + make_instances(); +} + static void check_plugin(const char *plugin) { char *buf; @@ -3969,7 +3988,7 @@ void trace_record (int argc, char **argv) set_buffer_size(); clear_filters(); clear_triggers(); - remove_instances(); + tracecmd_remove_instances(); clear_func_filters(); exit(0); } else @@ -4402,7 +4421,7 @@ void trace_record (int argc, char **argv) set_plugin("nop"); - remove_instances(); + tracecmd_remove_instances(); /* If tracing_on was enabled before we started, set it on now */ for_all_instances(instance) { -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/