Received: by 10.223.164.202 with SMTP id h10csp647453wrb; Thu, 30 Nov 2017 05:22:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ4WAjjuBFBcD6cWW8EfnntoFyliVXPg0UPXi67I7iFH6OcmP+WqWOF4BsS9GgX+IJe1/CP X-Received: by 10.99.101.133 with SMTP id z127mr2368065pgb.139.1512048129669; Thu, 30 Nov 2017 05:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512048129; cv=none; d=google.com; s=arc-20160816; b=Qt8OPLgzsAbsPepxHQmxJu1pvl/lex3AGCKKaRxHkNOAkZjT0evUYpJZ3tDTwP2F9X vWO+ICbAaZN4AjWYmQF09sr0D6JhnvxAgdZ3ZNai7YkiRksx5cEX2JCWzBX8rrA+1Km4 MJ5GZRWoPDnL2LyxYc4yYpSllUfjlIRSIhr/GAW/cSyFvZhCz5s6ZfDaRH8gCgnsIfuT 4zbJGPAh9wlNy5HUWFoYMbNnPmzF/xSd0e7ILSopizAis+CegO9fgKhTpef7qenQK4lt F9SaYhRhI+O0PF0q4DNXnMA4aMFeTlsLEyC0hbX/XFkWIDek3cjbrLmgUf8uY+ft2pcu tG8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=JD+ef7StuohlV+8k1NLZBQG7OMARf/0l1IW6HssE+aY=; b=AWvqphxzKfWd64UKeLZ+5cp7yRRyKFhp/gZ6YjK2HxdtWEdITr6hz0aJmHILThHNxR YsREO7TcAdEzJ+niNI/f8EinbRx04+KH5DxdHzBj430erGCcY9B8yb7UQk5DoKdxXJIV 26zyiq8LBnD9PXDLo2ggYwSAFckFdE4cTUUP8MCfZiH1gyI4EkBVKOcPeTDJomikCWuh 11rLoQUcXZZmldX1ZP4BEt07XqgvHJ8ZeBqNd43jhmzSO3Q4Cup/fEJJA6K0HplBbNWx keGRMVCDgpyA80YPBn7ldta8013PsqASIM31tH1HxQm07Nh5UmPJ1wmB3GrJ6bC5iprm aTkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Jq120G67; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j186si3013436pgc.694.2017.11.30.05.21.55; Thu, 30 Nov 2017 05:22:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Jq120G67; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753064AbdK3NUp (ORCPT + 99 others); Thu, 30 Nov 2017 08:20:45 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:46810 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752644AbdK3NUi (ORCPT ); Thu, 30 Nov 2017 08:20:38 -0500 Received: by mail-wr0-f193.google.com with SMTP id x49so6542673wrb.13 for ; Thu, 30 Nov 2017 05:20:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JD+ef7StuohlV+8k1NLZBQG7OMARf/0l1IW6HssE+aY=; b=Jq120G67cpHJEn4NbOp9oz8gHf3awLDURh8FII1A10FaFiMFVNMFgtDvlNlLexkwUR cCqHH2OJc29nXd+VXr2R6RTHZPppruVmGbq5Z8VqYWx3SUNhPNFHHrLSE/4WfIMgpv7z EqZdx0N579WR4J1x/4sruIhWdX4bZymdPTEVqNF4vsh1bW9LVAXcrapJUUZqlN2AKwUC zQhVNnTyiVwu8aoBYb6M9QWVhdpUOxbDwQ94UkXALFW3exH2wTWBFdLx13ubLCxfmSrH nmTpO8nhXn6yGK+QwltxmEYTb7rNB+s53P/hN/kwxqW4ADyX7VZeQoB2YQ0yhvDeyObg ft4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JD+ef7StuohlV+8k1NLZBQG7OMARf/0l1IW6HssE+aY=; b=ZsgIeAHkNxSFVo3oq3+xciTvskZhAJbvLXp3lkxTssW+BuStEZJ41X+Ey+Ph/KpcAV MUJNDgLKkDSvJbOk8JmqXbhA/x4Y67PQjr6DdEBkkx5mxZp2ljtlnRzerK4L24tbQHgp VcNujEhY4eJQtSUQoaRg6VLKRZ0Pd8zCST9rpCKf03uUvHvey8imK8ZUAOvkq46Acgpo NiyMMXjdXCWAaImaXItNrSl/ppJ8lspRZuSAo0jbNe/zJ9M5o7JqcyyGjTCHlCjNZAYe LAON9iHVjOaXKfDjxZB6JSm5zZ4/WS6Ec0p++fGxoJAMYJBaodj0twgnKpQFiLxwHFuj 5zOA== X-Gm-Message-State: AJaThX5Q/EfMObQX/HTC6ZXE97emxKO8QcOSW22JZV6dMcz36+/G6p9o UKpnwLRPhBcCyda3Cayi2qE= X-Received: by 10.223.133.250 with SMTP id 55mr2042514wru.23.1512048037231; Thu, 30 Nov 2017 05:20:37 -0800 (PST) Received: from localhost.localdomain ([87.121.44.226]) by smtp.gmail.com with ESMTPSA id p200sm3539734wmd.9.2017.11.30.05.20.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Nov 2017 05:20:36 -0800 (PST) From: "Vladislav Valtchev (VMware)" To: rostedt@goodmis.org Cc: linux-kernel@vger.kernel.org, y.karadz@gmail.com, "Vladislav Valtchev (VMware)" Subject: [PATCH v2 03/10] trace-cmd: Extracting record_trace() Date: Thu, 30 Nov 2017 15:19:50 +0200 Message-Id: <20171130131957.21617-4-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch moves in a separate function almost all the code in trace_record() after the call of parse_record_options(). This is the last necessary preparation step before removing the command-multiplexing code from trace_record and allowing the commands 'start', 'extract', 'stream' and 'profile' to have an independent entry-point from 'record'. Signed-off-by: Vladislav Valtchev (VMware) --- trace-record.c | 146 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 75 insertions(+), 71 deletions(-) diff --git a/trace-record.c b/trace-record.c index 9e35de4..b37e073 100644 --- a/trace-record.c +++ b/trace-record.c @@ -4742,111 +4742,90 @@ static void parse_record_options(int argc, } -void trace_record(int argc, char **argv) +static void record_trace(int argc, char **argv, + struct common_record_context *ctx) { - struct common_record_context ctx; enum trace_type type = 0; - init_common_record_context(&ctx); - - if (strcmp(argv[1], "record") == 0) - ctx.curr_cmd = CMD_record; - else if (strcmp(argv[1], "start") == 0) - ctx.curr_cmd = CMD_start; - else if (strcmp(argv[1], "extract") == 0) - ctx.curr_cmd = CMD_extract; - else if (strcmp(argv[1], "stream") == 0) - ctx.curr_cmd = CMD_stream; - else if (strcmp(argv[1], "profile") == 0) { - ctx.curr_cmd = CMD_profile; - handle_init = trace_init_profile; - ctx.events = 1; - } else - usage(argv); - - - parse_record_options(argc, argv, &ctx); - - /* * If this is a profile run, and no instances were set, * then enable profiling on the top instance. */ - if (IS_PROFILE(&ctx) && !buffer_instances) + if (IS_PROFILE(ctx) && !buffer_instances) top_instance.profile = 1; /* * If top_instance doesn't have any plugins or events, then * remove it from being processed. */ - if (!IS_EXTRACT(&ctx) && !__check_doing_something(&top_instance)) + if (!IS_EXTRACT(ctx) && !__check_doing_something(&top_instance)) first_instance = buffer_instances; else - ctx.topt = 1; + ctx->topt = 1; - update_first_instance(ctx.instance, ctx.topt); + update_first_instance(ctx->instance, ctx->topt); - if (!IS_EXTRACT(&ctx)) + if (!IS_EXTRACT(ctx)) check_doing_something(); check_function_plugin(); - if (ctx.output) - output_file = ctx.output; + if (ctx->output) + output_file = ctx->output; /* Save the state of tracing_on before starting */ - for_all_instances(ctx.instance) { + for_all_instances(ctx->instance) { - if (!ctx.manual && ctx.instance->profile) - enable_profile(ctx.instance); + if (!ctx->manual && ctx->instance->profile) + enable_profile(ctx->instance); - ctx.instance->tracing_on_init_val = read_tracing_on(ctx.instance); + ctx->instance->tracing_on_init_val = read_tracing_on(ctx->instance); /* Some instances may not be created yet */ - if (ctx.instance->tracing_on_init_val < 0) - ctx.instance->tracing_on_init_val = 1; + if (ctx->instance->tracing_on_init_val < 0) + ctx->instance->tracing_on_init_val = 1; } /* Extracting data records all events in the system. */ - if (IS_EXTRACT(&ctx) && !ctx.record_all) + if (IS_EXTRACT(ctx) && !ctx->record_all) record_all_events(); - if (!IS_EXTRACT(&ctx)) + if (!IS_EXTRACT(ctx)) make_instances(); - if (ctx.events) + if (ctx->events) expand_event_list(); page_size = getpagesize(); - if (!IS_EXTRACT(&ctx)) { - fset = set_ftrace(!ctx.disable, ctx.total_disable); + if (!IS_EXTRACT(ctx)) { + fset = set_ftrace(!ctx->disable, ctx->total_disable); tracecmd_disable_all_tracing(1); - for_all_instances(ctx.instance) - set_clock(ctx.instance); + for_all_instances(ctx->instance) + set_clock(ctx->instance); /* Record records the date first */ - if (IS_RECORD(&ctx) && ctx.date) - ctx.date2ts = get_date_to_ts(); + if (IS_RECORD(ctx) && ctx->date) + ctx->date2ts = get_date_to_ts(); - for_all_instances(ctx.instance) { - set_funcs(ctx.instance); - set_mask(ctx.instance); + for_all_instances(ctx->instance) { + set_funcs(ctx->instance); + set_mask(ctx->instance); } - if (ctx.events) { - for_all_instances(ctx.instance) - enable_events(ctx.instance); + if (ctx->events) { + for_all_instances(ctx->instance) + enable_events(ctx->instance); } set_buffer_size(); } - if (IS_RECORD(&ctx)) + if (IS_RECORD(ctx)) type = TRACE_TYPE_RECORD; - else if (IS_STREAM(&ctx)) + else if (IS_STREAM(ctx)) type = TRACE_TYPE_STREAM; - else if (IS_EXTRACT(&ctx)) + else if (IS_EXTRACT(ctx)) type = TRACE_TYPE_EXTRACT; - else if (IS_PROFILE(&ctx)) + else if (IS_PROFILE(ctx)) type = TRACE_TYPE_STREAM; else type = TRACE_TYPE_START; @@ -4855,10 +4834,10 @@ void trace_record(int argc, char **argv) set_options(); - if (ctx.max_graph_depth) { - for_all_instances(ctx.instance) - set_max_graph_depth(ctx.instance, ctx.max_graph_depth); - free(ctx.max_graph_depth); + if (ctx->max_graph_depth) { + for_all_instances(ctx->instance) + set_max_graph_depth(ctx->instance, ctx->max_graph_depth); + free(ctx->max_graph_depth); } allocate_seq(); @@ -4866,10 +4845,10 @@ void trace_record(int argc, char **argv) if (type & (TRACE_TYPE_RECORD | TRACE_TYPE_STREAM)) { signal(SIGINT, finish); if (!latency) - start_threads(type, ctx.global); + start_threads(type, ctx->global); } - if (IS_EXTRACT(&ctx)) { + if (IS_EXTRACT(ctx)) { flush_threads(); } else { @@ -4879,7 +4858,7 @@ void trace_record(int argc, char **argv) exit(0); } - if (ctx.run_command) + if (ctx->run_command) run_cmd(type, (argc - optind) - 1, &argv[optind + 1]); else { update_task_filter(); @@ -4904,17 +4883,17 @@ void trace_record(int argc, char **argv) tracecmd_disable_all_tracing(0); /* extract records the date after extraction */ - if (IS_EXTRACT(&ctx) && ctx.date) { + if (IS_EXTRACT(ctx) && ctx->date) { /* * We need to start tracing, don't let other traces * screw with our trace_marker. */ tracecmd_disable_all_tracing(1); - ctx.date2ts = get_date_to_ts(); + ctx->date2ts = get_date_to_ts(); } - if (IS_RECORD(&ctx) || IS_EXTRACT(&ctx)) { - record_data(ctx.date2ts, ctx.data_flags); + if (IS_RECORD(ctx) || IS_EXTRACT(ctx)) { + record_data(ctx->date2ts, ctx->data_flags); delete_thread_data(); } else print_stats(); @@ -4934,17 +4913,42 @@ void trace_record(int argc, char **argv) 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); + 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); - if (IS_PROFILE(&ctx)) + if (IS_PROFILE(ctx)) trace_profile(); exit(0); } + +void trace_record(int argc, char **argv) +{ + struct common_record_context ctx; + + init_common_record_context(&ctx); + + if (strcmp(argv[1], "record") == 0) + ctx.curr_cmd = CMD_record; + else if (strcmp(argv[1], "start") == 0) + ctx.curr_cmd = CMD_start; + else if (strcmp(argv[1], "extract") == 0) + ctx.curr_cmd = CMD_extract; + else if (strcmp(argv[1], "stream") == 0) + ctx.curr_cmd = CMD_stream; + else if (strcmp(argv[1], "profile") == 0) { + ctx.curr_cmd = CMD_profile; + handle_init = trace_init_profile; + ctx.events = 1; + } else + usage(argv); + + parse_record_options(argc, argv, &ctx); + record_trace(argc, argv, &ctx); +} -- 2.14.1 From 1584802790918744227@xxx Wed Nov 22 21:21:58 +0000 2017 X-GM-THRID: 1584802790918744227 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread