mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
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 <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: David Ahern <[email protected]> Cc: Don Zickus <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Steven Rostedt <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
1 parent
dc6254cf87
commit
402bb4e6ec
2 files changed
+11
-4
No files matched your search
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <regex.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -91,6 +92,7 @@ extern int trace_seq_putc(struct trace_seq *s, unsigned char c);
|
||||
|
||||
extern void trace_seq_terminate(struct trace_seq *s);
|
||||
|
||||
extern int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp);
|
||||
extern int trace_seq_do_printf(struct trace_seq *s);
|
||||
|
||||
|
||||
|
||||
@@ -231,19 +231,24 @@ void trace_seq_terminate(struct trace_seq *s)
|
||||
s->buffer[s->len] = 0;
|
||||
}
|
||||
|
||||
int trace_seq_do_printf(struct trace_seq *s)
|
||||
int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp)
|
||||
{
|
||||
TRACE_SEQ_CHECK(s);
|
||||
|
||||
switch (s->state) {
|
||||
case TRACE_SEQ__GOOD:
|
||||
return printf("%.*s", s->len, s->buffer);
|
||||
return fprintf(fp, "%.*s", s->len, s->buffer);
|
||||
case TRACE_SEQ__BUFFER_POISONED:
|
||||
puts("Usage of trace_seq after it was destroyed");
|
||||
fprintf(fp, "%s\n", "Usage of trace_seq after it was destroyed");
|
||||
break;
|
||||
case TRACE_SEQ__MEM_ALLOC_FAILED:
|
||||
puts("Can't allocate trace_seq buffer memory");
|
||||
fprintf(fp, "%s\n", "Can't allocate trace_seq buffer memory");
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int trace_seq_do_printf(struct trace_seq *s)
|
||||
{
|
||||
return trace_seq_do_fprintf(s, stdout);
|
||||
}
|
||||
Reference in new issue
Block a user