tools lib traceevent: Teach [ce]tags about libtraceeevent error codes
PATCH 1/2 tools lib traceevent: Teach [ce]tags about libtraceeevent error codes
From: Namhyung Kim <[email protected]>
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.
--- tools/lib/traceevent/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/lib/traceevent/Makefile +4 -2
@@ -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) \
Signature · 1 line
1.7.10.2
PATCH 2/2 tools lib traceevent: Check string is really printable
From: Namhyung Kim <[email protected]>
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
--- tools/lib/traceevent/event-parse.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +13 -1
@@ -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,
Signature · 1 line
1.7.10.2
Arnaldo Carvalho de Melo
AppliedEm Fri, Jun 22, 2012 at 05:10:14PM +0900, Namhyung Kim escreveu:
Quoted 7 lines
From: Namhyung Kim <[email protected]>
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
Makefilenot a kernel one.
Thanks, applied to perf/core.
- Arnaldo
Arnaldo Carvalho de Melo
AppliedRe: [PATCH 2/2] tools lib traceevent: Check string is really printable
In reply to Namhyung KimEm Fri, Jun 22, 2012 at 05:10:15PM +0900, Namhyung Kim escreveu:
Quoted 7 lines
From: Namhyung Kim <[email protected]>
When libtraceevent parses format fields, it assumes that array of 1 byte is string but it's not always true. The
kvm_emulate_insncontains 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
[tip:perf/core] tools lib traceevent: Teach [ce] tags about libtraceeevent error codes
In reply to Namhyung KimCommit-ID: 6545e3a8f0666b60b26202a5271a94f7cd9601a8 Gitweb: http://git.kernel.org/tip/6545e3a8f0666b60b26202a5271a94f7cd9601a8 Author: Namhyung Kim <[email protected]> AuthorDate: Fri, 22 Jun 2012 17:10:14 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/lib/traceevent/Makefile | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
tools/lib/traceevent/Makefile +4 -2
@@ -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) \
[tip:perf/core] tools lib traceevent: Check string is really printable
In reply to Namhyung KimCommit-ID: 600da3cfe19496485c5d8d52ff703590a0bd53f6 Gitweb: http://git.kernel.org/tip/600da3cfe19496485c5d8d52ff703590a0bd53f6 Author: Namhyung Kim <[email protected]> AuthorDate: Fri, 22 Jun 2012 17:10:15 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> 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
--- tools/lib/traceevent/event-parse.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-)
tools/lib/traceevent/event-parse.c +13 -1
@@ -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,