diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-02-03 10:44:09 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-02-06 05:46:37 -0500 |
| commit | 402bb4e6ec6507ccbb2e556d7996bbc989db7f27 (patch) | |
| tree | aa7d8bfdc118b6bb834ae9414c7f0577ed2a5205 /tools | |
| parent | dc6254cf870732804b76a83ff2d8a72fea4365f6 (diff) | |
tools lib traceevent: Introduce trace_seq_do_fprintf function
So that we can specify a FILE object where to direct the formatted
output.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-a49bhdrx8851f04hppn8bqxq@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/lib/traceevent/event-parse.h | 2 | ||||
| -rw-r--r-- | tools/lib/traceevent/trace-seq.c | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 7a3873ff9a4f..5b4efc062320 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
| 24 | #include <stdarg.h> | 24 | #include <stdarg.h> |
| 25 | #include <stdio.h> | ||
| 25 | #include <regex.h> | 26 | #include <regex.h> |
| 26 | #include <string.h> | 27 | #include <string.h> |
| 27 | 28 | ||
| @@ -91,6 +92,7 @@ extern int trace_seq_putc(struct trace_seq *s, unsigned char c); | |||
| 91 | 92 | ||
| 92 | extern void trace_seq_terminate(struct trace_seq *s); | 93 | extern void trace_seq_terminate(struct trace_seq *s); |
| 93 | 94 | ||
| 95 | extern int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp); | ||
| 94 | extern int trace_seq_do_printf(struct trace_seq *s); | 96 | extern int trace_seq_do_printf(struct trace_seq *s); |
| 95 | 97 | ||
| 96 | 98 | ||
diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c index ec3bd16a5488..292dc9f1d233 100644 --- a/tools/lib/traceevent/trace-seq.c +++ b/tools/lib/traceevent/trace-seq.c | |||
| @@ -231,19 +231,24 @@ void trace_seq_terminate(struct trace_seq *s) | |||
| 231 | s->buffer[s->len] = 0; | 231 | s->buffer[s->len] = 0; |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | int trace_seq_do_printf(struct trace_seq *s) | 234 | int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp) |
| 235 | { | 235 | { |
| 236 | TRACE_SEQ_CHECK(s); | 236 | TRACE_SEQ_CHECK(s); |
| 237 | 237 | ||
| 238 | switch (s->state) { | 238 | switch (s->state) { |
| 239 | case TRACE_SEQ__GOOD: | 239 | case TRACE_SEQ__GOOD: |
| 240 | return printf("%.*s", s->len, s->buffer); | 240 | return fprintf(fp, "%.*s", s->len, s->buffer); |
| 241 | case TRACE_SEQ__BUFFER_POISONED: | 241 | case TRACE_SEQ__BUFFER_POISONED: |
| 242 | puts("Usage of trace_seq after it was destroyed"); | 242 | fprintf(fp, "%s\n", "Usage of trace_seq after it was destroyed"); |
| 243 | break; | 243 | break; |
| 244 | case TRACE_SEQ__MEM_ALLOC_FAILED: | 244 | case TRACE_SEQ__MEM_ALLOC_FAILED: |
| 245 | puts("Can't allocate trace_seq buffer memory"); | 245 | fprintf(fp, "%s\n", "Can't allocate trace_seq buffer memory"); |
| 246 | break; | 246 | break; |
| 247 | } | 247 | } |
| 248 | return -1; | 248 | return -1; |
| 249 | } | 249 | } |
| 250 | |||
| 251 | int trace_seq_do_printf(struct trace_seq *s) | ||
| 252 | { | ||
| 253 | return trace_seq_do_fprintf(s, stdout); | ||
| 254 | } | ||
