All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] tools lib traceevent: Teach [ce]tags about libtraceeevent error codes
@ 2012-06-22  8:10 Namhyung Kim
  2012-06-22  8:10 ` [PATCH 2/2] tools lib traceevent: Check string is really printable Namhyung Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Namhyung Kim @ 2012-06-22  8:10 UTC (permalink / raw)
  To: Steven Rostedt, Arnaldo Carvalho de Melo
  Cc: Frederic Weisbecker, Peter Zijlstra, Ingo Molnar, LKML, Namhyung Kim

From: Namhyung Kim <namhyung.kim@lge.com>

As we use a macro trick to sync each error codes with its
description string, teach [ce]tags to process them properly.

This patch modifies the libtraceevent's Makefile not a
kernel one.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-3101nsbg52glxdqih291qj74@git.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/lib/traceevent/Makefile |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 56daa768b9e3..15f6eb8f4935 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -284,11 +284,13 @@ TRACEEVENT-CFLAGS: force
 
 tags:	force
 	$(RM) tags
-	find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px
+	find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
+	--regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
 
 TAGS:	force
 	$(RM) TAGS
-	find . -name '*.[ch]' | xargs etags
+	find . -name '*.[ch]' | xargs etags \
+	--regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
 
 define do_install
 	$(print_install)				\
-- 
1.7.10.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] tools lib traceevent: Check string is really printable
  2012-06-22  8:10 [PATCH 1/2] tools lib traceevent: Teach [ce]tags about libtraceeevent error codes Namhyung Kim
@ 2012-06-22  8:10 ` Namhyung Kim
  2012-06-28 16:17   ` Arnaldo Carvalho de Melo
  2012-07-06 10:53   ` [tip:perf/core] " tip-bot for Namhyung Kim
  2012-06-28 16:14 ` [PATCH 1/2] tools lib traceevent: Teach [ce]tags about libtraceeevent error codes Arnaldo Carvalho de Melo
  2012-07-06 10:51 ` [tip:perf/core] tools lib traceevent: Teach [ce] tags " tip-bot for Namhyung Kim
  2 siblings, 2 replies; 6+ messages in thread
From: Namhyung Kim @ 2012-06-22  8:10 UTC (permalink / raw)
  To: Steven Rostedt, Arnaldo Carvalho de Melo
  Cc: Frederic Weisbecker, Peter Zijlstra, Ingo Molnar, LKML, Namhyung Kim

From: Namhyung Kim <namhyung.kim@lge.com>

When libtraceevent parses format fields, it assumes that
array of 1 byte is string but it's not always true. The
kvm_emulate_insn contains 15 u8 array of insn that contains
(binary) instructions. Thus when it's printed, it'll have
broken output like below:

  kvm_emulate_insn:     [FAILED TO PARSE] rip=3238197797 csbase=0 len=2 \
  insn=<89>P^]<B4>& flags=5 failed=0

With this patch:

  kvm_emulate_insn:     [FAILED TO PARSE] rip=3238197797 csbase=0 len=2 \
  insn=ARRAY[89, 10, 5d, c3, 8d, b4, 26, 00, 00, 00, 00, 55, 89, e5, 3e] flags=5 failed=0

Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-c5ypr2k43uuc57ru6b8vi7ax@git.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/lib/traceevent/event-parse.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 853b604b6240..eb195cbc841c 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,
-- 
1.7.10.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] tools lib traceevent: Teach [ce]tags about libtraceeevent error codes
  2012-06-22  8:10 [PATCH 1/2] tools lib traceevent: Teach [ce]tags about libtraceeevent error codes Namhyung Kim
  2012-06-22  8:10 ` [PATCH 2/2] tools lib traceevent: Check string is really printable Namhyung Kim
@ 2012-06-28 16:14 ` Arnaldo Carvalho de Melo
  2012-07-06 10:51 ` [tip:perf/core] tools lib traceevent: Teach [ce] tags " tip-bot for Namhyung Kim
  2 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2012-06-28 16:14 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Steven Rostedt, Frederic Weisbecker, Peter Zijlstra, Ingo Molnar,
	LKML, Namhyung Kim

Em Fri, Jun 22, 2012 at 05:10:14PM +0900, Namhyung Kim escreveu:
> From: Namhyung Kim <namhyung.kim@lge.com>
> 
> As we use a macro trick to sync each error codes with its
> description string, teach [ce]tags to process them properly.
> 
> This patch modifies the libtraceevent's Makefile not a
> kernel one.

Thanks, applied to perf/core.

- Arnaldo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] tools lib traceevent: Check string is really printable
  2012-06-22  8:10 ` [PATCH 2/2] tools lib traceevent: Check string is really printable Namhyung Kim
@ 2012-06-28 16:17   ` Arnaldo Carvalho de Melo
  2012-07-06 10:53   ` [tip:perf/core] " tip-bot for Namhyung Kim
  1 sibling, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2012-06-28 16:17 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Steven Rostedt, Frederic Weisbecker, Peter Zijlstra, Ingo Molnar,
	LKML, Namhyung Kim

Em Fri, Jun 22, 2012 at 05:10:15PM +0900, Namhyung Kim escreveu:
> From: Namhyung Kim <namhyung.kim@lge.com>
> 
> When libtraceevent parses format fields, it assumes that
> array of 1 byte is string but it's not always true. The
> kvm_emulate_insn contains 15 u8 array of insn that contains
> (binary) instructions. Thus when it's printed, it'll have
> broken output like below:

Thanks, applied to perf/core.

- Arnaldo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:perf/core] tools lib traceevent: Teach [ce] tags about libtraceeevent error codes
  2012-06-22  8:10 [PATCH 1/2] tools lib traceevent: Teach [ce]tags about libtraceeevent error codes Namhyung Kim
  2012-06-22  8:10 ` [PATCH 2/2] tools lib traceevent: Check string is really printable Namhyung Kim
  2012-06-28 16:14 ` [PATCH 1/2] tools lib traceevent: Teach [ce]tags about libtraceeevent error codes Arnaldo Carvalho de Melo
@ 2012-07-06 10:51 ` tip-bot for Namhyung Kim
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Namhyung Kim @ 2012-07-06 10:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, a.p.zijlstra, namhyung.kim,
	namhyung, fweisbec, rostedt, tglx

Commit-ID:  6545e3a8f0666b60b26202a5271a94f7cd9601a8
Gitweb:     http://git.kernel.org/tip/6545e3a8f0666b60b26202a5271a94f7cd9601a8
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Fri, 22 Jun 2012 17:10:14 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 29 Jun 2012 13:28:12 -0300

tools lib traceevent: Teach [ce]tags about libtraceeevent error codes

As we use a macro trick to sync each error codes with its description
string, teach [ce]tags to process them properly.

This patch modifies the libtraceevent's Makefile not a kernel one.

Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-3101nsbg52glxdqih291qj74@git.kernel.org
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1340352615-20737-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/traceevent/Makefile |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 423f4b8..34a577e 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -270,11 +270,13 @@ endif
 
 tags:	force
 	$(RM) tags
-	find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px
+	find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
+	--regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
 
 TAGS:	force
 	$(RM) TAGS
-	find . -name '*.[ch]' | xargs etags
+	find . -name '*.[ch]' | xargs etags \
+	--regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
 
 define do_install
 	$(print_install)				\

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:perf/core] tools lib traceevent: Check string is really printable
  2012-06-22  8:10 ` [PATCH 2/2] tools lib traceevent: Check string is really printable Namhyung Kim
  2012-06-28 16:17   ` Arnaldo Carvalho de Melo
@ 2012-07-06 10:53   ` tip-bot for Namhyung Kim
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Namhyung Kim @ 2012-07-06 10:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, a.p.zijlstra, namhyung.kim,
	namhyung, fweisbec, rostedt, tglx

Commit-ID:  600da3cfe19496485c5d8d52ff703590a0bd53f6
Gitweb:     http://git.kernel.org/tip/600da3cfe19496485c5d8d52ff703590a0bd53f6
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Fri, 22 Jun 2012 17:10:15 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 29 Jun 2012 13:28:12 -0300

tools lib traceevent: Check string is really printable

When libtraceevent parses format fields, it assumes that array of 1 byte
is string but it's not always true. The kvm_emulate_insn contains 15 u8
array of insn that contains (binary) instructions. Thus when it's
printed, it'll have broken output like below:

  kvm_emulate_insn:     [FAILED TO PARSE] rip=3238197797 csbase=0 len=2 \
  insn=<89>P^]<B4>& flags=5 failed=0

With this patch:

  kvm_emulate_insn:     [FAILED TO PARSE] rip=3238197797 csbase=0 len=2 \
  insn=ARRAY[89, 10, 5d, c3, 8d, b4, 26, 00, 00, 00, 00, 55, 89, e5, 3e] flags=5 failed=0

Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1340352615-20737-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/traceevent/event-parse.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 5548282..b203a50 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3589,6 +3589,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)
 {
@@ -3608,7 +3618,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[");
@@ -3619,6 +3630,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,

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-07-06 10:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-22  8:10 [PATCH 1/2] tools lib traceevent: Teach [ce]tags about libtraceeevent error codes Namhyung Kim
2012-06-22  8:10 ` [PATCH 2/2] tools lib traceevent: Check string is really printable Namhyung Kim
2012-06-28 16:17   ` Arnaldo Carvalho de Melo
2012-07-06 10:53   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-06-28 16:14 ` [PATCH 1/2] tools lib traceevent: Teach [ce]tags about libtraceeevent error codes Arnaldo Carvalho de Melo
2012-07-06 10:51 ` [tip:perf/core] tools lib traceevent: Teach [ce] tags " tip-bot for Namhyung Kim

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.