All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Javi Merino <javi.merino@arm.com>
Cc: jolsa@redhat.com, linux-kernel@vger.kernel.org,
	namhyung@kernel.org, Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH v9] tools lib traceevent: Add support for __print_array()
Date: Tue, 24 Mar 2015 12:48:43 -0300	[thread overview]
Message-ID: <20150324154843.GB2161@redhat.com> (raw)
In-Reply-To: <1427195239-15730-1-git-send-email-javi.merino@arm.com>

Em Tue, Mar 24, 2015 at 11:07:19AM +0000, Javi Merino escreveu:
> Since 6ea22486ba46 ("tracing: Add array printing helper") trace can
> generate traces with variable element size arrays.  Add support to
> parse them.
> 
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Acked-by: Steven Rostedt <rostedt@goodmis.org>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Javi Merino <javi.merino@arm.com>
> ---
> 
> Changes since v8:
>   - Add PRINT_INT_ARRAY to define_event_symbols() in perf's scripting
>     engines as Arnaldo suggested.
>   - Use %lu instead of %llu for uint64_t
> 
> Note, I'm not familiar with perf, so I've only compile-tested the
> changes in tools/perf/util/scripting-engines/trace-event-python.c and
> tools/perf/util/scripting-engines/trace-event-perl.c by imitating the
> code that is around.  I'm not sure if that is the correct fix or it
> should be ignored like PRINT_DYNAMIC_ARRAY and friends.

Yeah, would be good to get some acked-by tags, Steven? Jiri? Namhyung?

What you did is equivalent, but explicitely ignoring it on the switches,
so I think I can keep the acks you got, just checking...

And now it builds fine, thanks.

- Arnaldo
 
>  tools/lib/traceevent/event-parse.c                 | 93 ++++++++++++++++++++++
>  tools/lib/traceevent/event-parse.h                 |  8 ++
>  .../perf/util/scripting-engines/trace-event-perl.c |  5 ++
>  .../util/scripting-engines/trace-event-python.c    |  5 ++
>  4 files changed, 111 insertions(+)
> 
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index 8e5e4f6137bb..080d02714fb5 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -758,6 +758,11 @@ static void free_arg(struct print_arg *arg)
>  		free_arg(arg->hex.field);
>  		free_arg(arg->hex.size);
>  		break;
> +	case PRINT_INT_ARRAY:
> +		free_arg(arg->int_array.field);
> +		free_arg(arg->int_array.count);
> +		free_arg(arg->int_array.el_size);
> +		break;
>  	case PRINT_TYPE:
>  		free(arg->typecast.type);
>  		free_arg(arg->typecast.item);
> @@ -2537,6 +2542,32 @@ out:
>  }
>  
>  static enum event_type
> +process_int_array(struct event_format *event, struct print_arg *arg, char **tok)
> +{
> +	memset(arg, 0, sizeof(*arg));
> +	arg->type = PRINT_INT_ARRAY;
> +
> +	if (alloc_and_process_delim(event, ",", &arg->int_array.field))
> +		goto out;
> +
> +	if (alloc_and_process_delim(event, ",", &arg->int_array.count))
> +		goto free_field;
> +
> +	if (alloc_and_process_delim(event, ")", &arg->int_array.el_size))
> +		goto free_size;
> +
> +	return read_token_item(tok);
> +
> +free_size:
> +	free_arg(arg->int_array.count);
> +free_field:
> +	free_arg(arg->int_array.field);
> +out:
> +	*tok = NULL;
> +	return EVENT_ERROR;
> +}
> +
> +static enum event_type
>  process_dynamic_array(struct event_format *event, struct print_arg *arg, char **tok)
>  {
>  	struct format_field *field;
> @@ -2831,6 +2862,10 @@ process_function(struct event_format *event, struct print_arg *arg,
>  		free_token(token);
>  		return process_hex(event, arg, tok);
>  	}
> +	if (strcmp(token, "__print_array") == 0) {
> +		free_token(token);
> +		return process_int_array(event, arg, tok);
> +	}
>  	if (strcmp(token, "__get_str") == 0) {
>  		free_token(token);
>  		return process_str(event, arg, tok);
> @@ -3359,6 +3394,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
>  		break;
>  	case PRINT_FLAGS:
>  	case PRINT_SYMBOL:
> +	case PRINT_INT_ARRAY:
>  	case PRINT_HEX:
>  		break;
>  	case PRINT_TYPE:
> @@ -3769,6 +3805,54 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
>  		}
>  		break;
>  
> +	case PRINT_INT_ARRAY: {
> +		void *num;
> +		int el_size;
> +
> +		if (arg->int_array.field->type == PRINT_DYNAMIC_ARRAY) {
> +			unsigned long offset;
> +			struct format_field *field =
> +				arg->int_array.field->dynarray.field;
> +			offset = pevent_read_number(pevent,
> +						    data + field->offset,
> +						    field->size);
> +			num = data + (offset & 0xffff);
> +		} else {
> +			field = arg->int_array.field->field.field;
> +			if (!field) {
> +				str = arg->int_array.field->field.name;
> +				field = pevent_find_any_field(event, str);
> +				if (!field)
> +					goto out_warning_field;
> +				arg->int_array.field->field.field = field;
> +			}
> +			num = data + field->offset;
> +		}
> +		len = eval_num_arg(data, size, event, arg->int_array.count);
> +		el_size = eval_num_arg(data, size, event,
> +				       arg->int_array.el_size);
> +		for (i = 0; i < len; i++) {
> +			if (i)
> +				trace_seq_putc(s, ' ');
> +
> +			if (el_size == 1) {
> +				trace_seq_printf(s, "%u", *(uint8_t *)num);
> +			} else if (el_size == 2) {
> +				trace_seq_printf(s, "%u", *(uint16_t *)num);
> +			} else if (el_size == 4) {
> +				trace_seq_printf(s, "%u", *(uint32_t *)num);
> +			} else if (el_size == 8) {
> +				trace_seq_printf(s, "%lu", *(uint64_t *)num);
> +			} else {
> +				trace_seq_printf(s, "BAD SIZE:%d 0x%x",
> +						 el_size, *(uint8_t *)num);
> +				el_size = 1;
> +			}
> +
> +			num += el_size;
> +		}
> +		break;
> +	}
>  	case PRINT_TYPE:
>  		break;
>  	case PRINT_STRING: {
> @@ -5259,6 +5343,15 @@ static void print_args(struct print_arg *args)
>  		print_args(args->hex.size);
>  		printf(")");
>  		break;
> +	case PRINT_INT_ARRAY:
> +		printf("__print_array(");
> +		print_args(args->int_array.field);
> +		printf(", ");
> +		print_args(args->int_array.count);
> +		printf(", ");
> +		print_args(args->int_array.el_size);
> +		printf(")");
> +		break;
>  	case PRINT_STRING:
>  	case PRINT_BSTRING:
>  		printf("__get_str(%s)", args->string.string);
> diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
> index 6abda54d76f2..6285bea0610b 100644
> --- a/tools/lib/traceevent/event-parse.h
> +++ b/tools/lib/traceevent/event-parse.h
> @@ -247,6 +247,12 @@ struct print_arg_hex {
>  	struct print_arg	*size;
>  };
>  
> +struct print_arg_int_array {
> +	struct print_arg	*field;
> +	struct print_arg	*count;
> +	struct print_arg	*el_size;
> +};
> +
>  struct print_arg_dynarray {
>  	struct format_field	*field;
>  	struct print_arg	*index;
> @@ -275,6 +281,7 @@ enum print_arg_type {
>  	PRINT_FLAGS,
>  	PRINT_SYMBOL,
>  	PRINT_HEX,
> +	PRINT_INT_ARRAY,
>  	PRINT_TYPE,
>  	PRINT_STRING,
>  	PRINT_BSTRING,
> @@ -294,6 +301,7 @@ struct print_arg {
>  		struct print_arg_flags		flags;
>  		struct print_arg_symbol		symbol;
>  		struct print_arg_hex		hex;
> +		struct print_arg_int_array	int_array;
>  		struct print_arg_func		func;
>  		struct print_arg_string		string;
>  		struct print_arg_bitmask	bitmask;
> diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
> index 22ebc46226e7..8171fed4136e 100644
> --- a/tools/perf/util/scripting-engines/trace-event-perl.c
> +++ b/tools/perf/util/scripting-engines/trace-event-perl.c
> @@ -214,6 +214,11 @@ static void define_event_symbols(struct event_format *event,
>  		define_event_symbols(event, ev_name, args->hex.field);
>  		define_event_symbols(event, ev_name, args->hex.size);
>  		break;
> +	case PRINT_INT_ARRAY:
> +		define_event_symbols(event, ev_name, args->int_array.field);
> +		define_event_symbols(event, ev_name, args->int_array.count);
> +		define_event_symbols(event, ev_name, args->int_array.el_size);
> +		break;
>  	case PRINT_BSTRING:
>  	case PRINT_DYNAMIC_ARRAY:
>  	case PRINT_STRING:
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> index 0c815a40a6e8..2ec5dfb5a456 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -231,6 +231,11 @@ static void define_event_symbols(struct event_format *event,
>  		define_event_symbols(event, ev_name, args->hex.field);
>  		define_event_symbols(event, ev_name, args->hex.size);
>  		break;
> +	case PRINT_INT_ARRAY:
> +		define_event_symbols(event, ev_name, args->int_array.field);
> +		define_event_symbols(event, ev_name, args->int_array.count);
> +		define_event_symbols(event, ev_name, args->int_array.el_size);
> +		break;
>  	case PRINT_STRING:
>  		break;
>  	case PRINT_TYPE:
> -- 
> 1.9.1

  reply	other threads:[~2015-03-24 15:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 18:12 [RESEND PATCH v8 0/2] Add array printing support to libtraceevent Javi Merino
2015-03-20 18:12 ` [RESEND PATCH v8 1/2] tools lib traceevent: factor out allocating and processing args Javi Merino
2015-03-24 16:31   ` [tip:perf/core] tools lib traceevent: Factor " tip-bot for Javi Merino
2015-03-20 18:12 ` [RESEND PATCH v8 2/2] tools lib traceevent: Add support for __print_array() Javi Merino
2015-03-23 16:20   ` Arnaldo Carvalho de Melo
2015-03-24 11:07     ` [PATCH v9] " Javi Merino
2015-03-24 15:48       ` Arnaldo Carvalho de Melo [this message]
2015-03-24 16:35       ` [tip:perf/core] " tip-bot for Javi Merino
2015-03-23 16:18 ` [RESEND PATCH v8 0/2] Add array printing support to libtraceevent Arnaldo Carvalho de Melo

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=20150324154843.GB2161@redhat.com \
    --to=acme@redhat.com \
    --cc=javi.merino@arm.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.