Skip to content

Commit

Permalink
tools lib traceevent: Use helper trace-seq in print functions like ke…
Browse files Browse the repository at this point in the history
…rnel 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 <[email protected]>
Reported-by: Jiri Olsa <[email protected]>
Tested-by: Jiri Olsa <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
rostedt authored and acmel committed Nov 27, 2013
1 parent 65661f9 commit 12e5556
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -4099,6 +4099,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
unsigned long long val;
struct func_map *func;
const char *saveptr;
struct trace_seq p;
char *bprint_fmt = NULL;
char format[32];
int show_func;
Expand Down Expand Up @@ -4306,8 +4307,12 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
format[len] = 0;
if (!len_as_arg)
len_arg = -1;
print_str_arg(s, data, size, event,
/* Use helper trace_seq */
trace_seq_init(&p);
print_str_arg(&p, data, size, event,
format, len_arg, arg);
trace_seq_terminate(&p);
trace_seq_puts(s, p.buffer);
arg = arg->next;
break;
default:
Expand Down

0 comments on commit 12e5556

Please sign in to comment.