Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+11 -4
+2
tools/lib/traceevent/event-parse.h
··· 22 22 23 23 #include <stdbool.h> 24 24 #include <stdarg.h> 25 + #include <stdio.h> 25 26 #include <regex.h> 26 27 #include <string.h> 27 28 ··· 92 91 93 92 extern void trace_seq_terminate(struct trace_seq *s); 94 93 94 + extern int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp); 95 95 extern int trace_seq_do_printf(struct trace_seq *s); 96 96 97 97
+9 -4
tools/lib/traceevent/trace-seq.c
··· 231 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 236 TRACE_SEQ_CHECK(s); 237 237 238 238 switch (s->state) { 239 239 case TRACE_SEQ__GOOD: 240 - return printf("%.*s", s->len, s->buffer); 240 + return fprintf(fp, "%.*s", s->len, s->buffer); 241 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 243 break; 244 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 246 break; 247 247 } 248 248 return -1; 249 + } 250 + 251 + int trace_seq_do_printf(struct trace_seq *s) 252 + { 253 + return trace_seq_do_fprintf(s, stdout); 249 254 }