public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>,
	acme@ghostprotocols.net, linux-kernel@vger.kernel.org,
	fweisbec@gmail.com, namhyung.kim@lge.com, mingo@kernel.org,
	peterz@infradead.org
Subject: Re: [RFC PATCH 0/2] libtraceevent/perf: Add support for trace-cmd plugins
Date: Tue, 19 Jun 2012 23:39:34 +0900	[thread overview]
Message-ID: <87vcin9xi1.fsf@gmail.com> (raw)
In-Reply-To: <1340106882.25903.206.camel@gandalf.stny.rr.com> (Steven Rostedt's message of "Tue, 19 Jun 2012 07:54:42 -0400")

On Tue, 19 Jun 2012 07:54:42 -0400, Steven Rostedt wrote:
> We could simply check if all the characters in the array passes
> 'isprint()' and if it does then print the string, otherwise print the
> hex. Do this for all events, and if it one fails, then mark it always to
> print hex.
>

Ok, checking it at parse time is not possible because we cannot access
to its data. You meant something like this?


diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 853b604b6240..7dae44b74e0b 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3655,6 +3655,16 @@ static void print_mac_arg(struct trace_seq *s, int mac, void *data, int size,
        trace_seq_printf(s, fmt, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
 }
 
+static int is_printable_array(char *p, unsigned int len)
+{
+       unsigned int i;
+
+       for (i = 0; i < len && p[i]; i++)
+               if (!isprint(p[i]))
+                       return 0;
+       return 1;
+}
+
 static void print_event_fields(struct trace_seq *s, void *data, int size,
                               struct event_format *event)
 {
@@ -3674,7 +3684,8 @@ static void print_event_fields(struct trace_seq *s, void *data, int size,
                                len = offset >> 16;
                                offset &= 0xffff;
                        }
-                       if (field->flags & FIELD_IS_STRING) {
+                       if ((field->flags & FIELD_IS_STRING) &&
+                           is_printable_array(data + offset, len)) {
                                trace_seq_printf(s, "%s", (char *)data + offset);
                        } else {
                                trace_seq_puts(s, "ARRAY[");
@@ -3685,6 +3696,7 @@ static void print_event_fields(struct trace_seq *s, void *data, int size,
                                                         *((unsigned char *)data + offset + i));
                                }
                                trace_seq_putc(s, ']');
+                               field->flags &= ~FIELD_IS_STRING;
                        }
                } else {
                        val = pevent_read_number(event->pevent, data + field->offset,


  reply	other threads:[~2012-06-19 14:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14 17:35 [RFC PATCH 0/2] libtraceevent/perf: Add support for trace-cmd plugins David Ahern
2012-06-14 17:35 ` [RFC PATCH 1/2] libtraceevent: Add support for tracecmd plugins David Ahern
2012-06-14 17:35 ` [RFC PATCH 2/2] perf: add support for trace-cmd plugins David Ahern
2012-06-18  8:35 ` [RFC PATCH 0/2] libtraceevent/perf: Add " Namhyung Kim
2012-06-18 14:21   ` Steven Rostedt
2012-06-18 14:35     ` David Ahern
2012-06-18 14:38   ` David Ahern
2012-06-19  0:45     ` Namhyung Kim
2012-06-19  1:03       ` Steven Rostedt
2012-06-19  1:11         ` Namhyung Kim
2012-06-19  1:26           ` Steven Rostedt
2012-06-19  1:40             ` Namhyung Kim
2012-06-19  2:16               ` Steven Rostedt
2012-06-19  5:41                 ` Namhyung Kim
2012-06-19 11:54                   ` Steven Rostedt
2012-06-19 14:39                     ` Namhyung Kim [this message]
2012-06-19 14:44                       ` Steven Rostedt
2012-06-19  1:14       ` David Ahern

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=87vcin9xi1.fsf@gmail.com \
    --to=namhyung@kernel.org \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox