From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753105AbdK3NUr (ORCPT ); Thu, 30 Nov 2017 08:20:47 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:46893 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753054AbdK3NUp (ORCPT ); Thu, 30 Nov 2017 08:20:45 -0500 X-Google-Smtp-Source: AGs4zMYmcb/T6MvYDdos7Td7RTBa7oMCFp3+4FOe0hWjBGdy8UgTsn7P4JP9LaV6JAcWA2Lji+33Nw== From: "Vladislav Valtchev (VMware)" To: rostedt@goodmis.org Cc: linux-kernel@vger.kernel.org, y.karadz@gmail.com, "Vladislav Valtchev (VMware)" Subject: [PATCH v2 09/10] trace-cmd: Extract finalize_record_trace() Date: Thu, 30 Nov 2017 15:19:56 +0200 Message-Id: <20171130131957.21617-10-vladislav.valtchev@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171130131957.21617-1-vladislav.valtchev@gmail.com> References: <20171130131957.21617-1-vladislav.valtchev@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch splits record_trace() in two parts by moving its finalization part in a separate function. This will also allow splitting out trace-cmd extract code from trace-cmd record code, by using a shared function. Signed-off-by: Vladislav Valtchev (VMware) --- trace-record.c | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/trace-record.c b/trace-record.c index ec0eaed..749c205 100644 --- a/trace-record.c +++ b/trace-record.c @@ -4767,6 +4767,31 @@ static enum trace_type get_trace_cmd_type(enum trace_cmd cmd) die("Trace type UNKNOWN for the given cmd_fun"); } +static void finalize_record_trace(struct common_record_context *ctx) +{ + if (keep) + return; + + update_reset_files(); + update_reset_triggers(); + if (clear_function_filters) + clear_func_filters(); + + set_plugin("nop"); + + tracecmd_remove_instances(); + + /* If tracing_on was enabled before we started, set it on now */ + for_all_instances(ctx->instance) { + if (ctx->instance->keep) + write_tracing_on(ctx->instance, + ctx->instance->tracing_on_init_val); + } + + if (host) + tracecmd_output_close(network_handle); +} + /* * This function contains common code for the following commands: * record, start, extract, stream, profile. @@ -4910,28 +4935,7 @@ static void record_trace(int argc, char **argv, print_stats(); destroy_stats(); - - if (keep) - return; - - update_reset_files(); - update_reset_triggers(); - if (clear_function_filters) - clear_func_filters(); - - set_plugin("nop"); - - tracecmd_remove_instances(); - - /* If tracing_on was enabled before we started, set it on now */ - for_all_instances(ctx->instance) { - if (ctx->instance->keep) - write_tracing_on(ctx->instance, - ctx->instance->tracing_on_init_val); - } - - if (host) - tracecmd_output_close(network_handle); + finalize_record_trace(ctx); } void trace_start(int argc, char **argv) -- 2.14.1