linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com>
Cc: linux-kernel@vger.kernel.org, y.karadz@gmail.com
Subject: Re: [PATCH 04/11] trace-cmd: Extract parse_record_options() from trace_record()
Date: Tue, 28 Nov 2017 11:48:22 -0500	[thread overview]
Message-ID: <20171128114822.0f80ed1e@gandalf.local.home> (raw)
In-Reply-To: <20171123163335.19078-5-vladislav.valtchev@gmail.com>

On Thu, 23 Nov 2017 18:33:28 +0200
"Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com> wrote:

> In this patch a huge part of trace_record(), dealing with parsing the command
> line options, has been extracted in a separate function. That allows the body
> of trace_record() to be focused only on the proper actions involved in a given
> type of tracing (record, stream, etc.) reducing, this way, the scope and the
> complexity of trace_record().

Hi Vladislav,

I applied patches 1-3.

> 
> Signed-off-by: Vladislav Valtchev (VMware) <vladislav.valtchev@gmail.com>
> ---
> +
> +static void parse_record_options(int argc,
> +				 char **argv,
> +				 struct common_record_context *ctx)
>  {
>  	const char *plugin = NULL;
> -	const char *output = NULL;
>  	const char *option;
>  	struct event_list *event = NULL;
>  	struct event_list *last_event = NULL;
> -	struct buffer_instance *instance = &top_instance;
> -	enum trace_type type = 0;
>  	char *pids;
>  	char *pid;
>  	char *sav;
> -	char *date2ts = NULL;
> -	int record_all = 0;
> -	int total_disable = 0;
> -	int disable = 0;
> -	int events = 0;
> -	int record = 0;
> -	int extract = 0;
> -	int stream = 0;
> -	int profile = 0;
> -	int global = 0;
> -	int start = 0;
> -	int filtered = 0;
> -	int run_command = 0;
>  	int neg_event = 0;
> -	int date = 0;
> -	int manual = 0;
> -	char *max_graph_depth = NULL;
> -	int topt = 0;
> -	int do_child = 0;
> -	int data_flags = 0;
> -
> -	int c;
> -
> -	init_instance(instance);
> -
> -	cpu_count = count_cpus();
> -
> -	if ((record = (strcmp(argv[1], "record") == 0)))
> -		; /* do nothing */
> -	else if ((start = strcmp(argv[1], "start") == 0))
> -		; /* do nothing */
> -	else if ((extract = strcmp(argv[1], "extract") == 0))
> -		; /* do nothing */
> -	else if ((stream = strcmp(argv[1], "stream") == 0))
> -		; /* do nothing */
> -	else if ((profile = strcmp(argv[1], "profile") == 0)) {
> -		handle_init = trace_init_profile;
> -		events = 1;
> -	} else
> -		usage(argv);
>  
>  	for (;;) {
>  		int option_index = 0;
>  		int ret;
> +		int c;
>  		const char *opts;
>  		static struct option long_options[] = {
>  			{"date", no_argument, NULL, OPT_date},
> @@ -4431,7 +4419,7 @@ void trace_record(int argc, char **argv)
> 


+
> +static void init_common_record_context(struct common_record_context *ctx)
> +{
> +	memset(ctx, 0, sizeof(*ctx));
> +	ctx->instance = &top_instance;
> +	cpu_count = count_cpus();
> +}
> +
> +void trace_record(int argc, char **argv)
> +{
> +	struct common_record_context ctx;
> +	enum trace_type type = 0;
> +
> +	init_common_record_context(&ctx);
> +	init_instance(ctx.instance);

Is there a reason that init_instance() isn't called in
init_common_record_context()?

Also, why not just do the "init_common_record_context()" in
parse_record_options()?

-- Steve

> +
> +	if ((ctx.record = (strcmp(argv[1], "record") == 0)))
> +		; /* do nothing */
> +	else if ((ctx.start = strcmp(argv[1], "start") == 0))
> +		; /* do nothing */
> +	else if ((ctx.extract = strcmp(argv[1], "extract") == 0))
> +		; /* do nothing */
> +	else if ((ctx.stream = strcmp(argv[1], "stream") == 0))
> +		; /* do nothing */
> +	else if ((ctx.profile = strcmp(argv[1], "profile") == 0)) {
> +		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.
>  	 */

  reply	other threads:[~2017-11-28 16:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-23 16:33 [PATCH 00/11] trace-cmd: Refactoring trace_record() Vladislav Valtchev (VMware)
2017-11-23 16:33 ` [PATCH 01/11] trace-cmd: Extract trace_stop() from trace_record() Vladislav Valtchev (VMware)
2017-11-23 16:33 ` [PATCH 02/11] trace-cmd: Extract trace_restart() " Vladislav Valtchev (VMware)
2017-11-23 16:33 ` [PATCH 03/11] trace-cmd: Extract trace_reset() " Vladislav Valtchev (VMware)
2017-11-23 16:33 ` [PATCH 04/11] trace-cmd: Extract parse_record_options() " Vladislav Valtchev (VMware)
2017-11-28 16:48   ` Steven Rostedt [this message]
2017-11-28 18:17     ` Vladislav Valtchev
2017-11-28 18:30       ` Steven Rostedt
2017-11-28 18:57         ` Vladislav Valtchev
2017-11-28 19:15           ` Steven Rostedt
2017-11-29 14:53       ` Steven Rostedt
2017-11-29 15:18         ` Vladislav Valtchev
2017-11-23 16:33 ` [PATCH 05/11] trace-cmd: Rename trace_profile() to trace_profile_int() Vladislav Valtchev (VMware)
2017-11-28 17:05   ` Steven Rostedt
2017-11-28 19:00     ` Vladislav Valtchev
2017-11-23 16:33 ` [PATCH 06/11] trace-cmd: Replacing cmd flags w/ a trace_cmd enum Vladislav Valtchev (VMware)
2017-11-23 16:33 ` [PATCH 07/11] trace-cmd: Extracting record_trace() Vladislav Valtchev (VMware)
2017-11-23 16:33 ` [PATCH 08/11] trace-cmd: Making start,extract,stream,profile separate funcs Vladislav Valtchev (VMware)
2017-11-28 17:14   ` Steven Rostedt
2017-11-28 18:34     ` Vladislav Valtchev
2017-11-28 19:35       ` Steven Rostedt
2017-11-29 10:03         ` Vladislav Valtchev
2017-11-29 12:48           ` Steven Rostedt
2017-11-23 16:33 ` [PATCH 09/11] trace-cmd: Consolidate ARRAY_SIZE() in trace-cmd.h Vladislav Valtchev (VMware)
2017-11-28 17:16   ` Steven Rostedt
2017-11-23 16:33 ` [PATCH 10/11] trace-cmd: Making the "die" functions noreturn Vladislav Valtchev (VMware)
2017-11-23 16:33 ` [PATCH 11/11] trace-cmd: Introducing get_trace_cmd_type() Vladislav Valtchev (VMware)
2017-11-28 17:17   ` Steven Rostedt
2017-11-28 18:32     ` Steven Rostedt
2017-11-28 19:04       ` Vladislav Valtchev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171128114822.0f80ed1e@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vladislav.valtchev@gmail.com \
    --cc=y.karadz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).