aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2013-11-19 18:29:37 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-11-27 12:58:34 -0500
commit12e55569a244996a23cb401e8116e5a060b664f0 (patch)
treef899fbffb03df4015638236f26307c5f12e57a87 /tools/lib
parent65661f96d3b32f4b28fef26d21be81d7e173b965 (diff)
tools lib traceevent: Use helper trace-seq in print functions like kernel does
Jiri Olsa reported that his plugin for scsi was chopping off part of the output. Investigating this, I found that Jiri used the same functions as what is in the kernel, which adds the following: trace_seq_putc(p, 0); This adds a '\0' to the output string. The reason this works in the kernel is that the "p" that is passed to the function helper is a temporary trace_seq. But in the libtraceevent library, it's the pointer to the trace_seq used to output. By adding the '\0', it truncates the line and nothing added after that will be printed. We can solve this in two ways. One is to have the helper functions for the library not add the unnecessary '\0'. The other is to change the library to also use a helper trace_seq structure that gets copied to the main trace_seq just like the kernel does. The latter allows the helper functions in the plugins to be the same as the kernel, which is the better solution. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Reported-by: Jiri Olsa <jolsa@redhat.com> Tested-by: Jiri Olsa <jolsa@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/20131119182937.401668e3@gandalf.local.home Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/traceevent/event-parse.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 217c82ee3665..900fca01bdd3 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4099,6 +4099,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
4099 unsigned long long val; 4099 unsigned long long val;
4100 struct func_map *func; 4100 struct func_map *func;
4101 const char *saveptr; 4101 const char *saveptr;
4102 struct trace_seq p;
4102 char *bprint_fmt = NULL; 4103 char *bprint_fmt = NULL;
4103 char format[32]; 4104 char format[32];
4104 int show_func; 4105 int show_func;
@@ -4306,8 +4307,12 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
4306 format[len] = 0; 4307 format[len] = 0;
4307 if (!len_as_arg) 4308 if (!len_as_arg)
4308 len_arg = -1; 4309 len_arg = -1;
4309 print_str_arg(s, data, size, event, 4310 /* Use helper trace_seq */
4311 trace_seq_init(&p);
4312 print_str_arg(&p, data, size, event,
4310 format, len_arg, arg); 4313 format, len_arg, arg);
4314 trace_seq_terminate(&p);
4315 trace_seq_puts(s, p.buffer);
4311 arg = arg->next; 4316 arg = arg->next;
4312 break; 4317 break;
4313 default: 4318 default: