diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | parse-events.c | 1 | ||||
| -rw-r--r-- | parse-events.h | 38 | ||||
| -rw-r--r-- | trace-seq.c | 11 | ||||
| -rw-r--r-- | trace-seq.h | 36 |
5 files changed, 43 insertions, 45 deletions
| @@ -14,7 +14,7 @@ all: $(TARGETS) | |||
| 14 | 14 | ||
| 15 | trace-read.o:: parse-events.h | 15 | trace-read.o:: parse-events.h |
| 16 | trace-cmd.o:: parse-events.h | 16 | trace-cmd.o:: parse-events.h |
| 17 | trace-seq.o:: parse-events.h trace-seq.h | 17 | trace-seq.o:: parse-events.h |
| 18 | 18 | ||
| 19 | trace-cmd:: trace-cmd.o trace-read.o trace-seq.o | 19 | trace-cmd:: trace-cmd.o trace-read.o trace-seq.o |
| 20 | $(CC) $^ -o $@ $(LIBS) | 20 | $(CC) $^ -o $@ $(LIBS) |
diff --git a/parse-events.c b/parse-events.c index 964b7c1..46eaf08 100644 --- a/parse-events.c +++ b/parse-events.c | |||
| @@ -29,7 +29,6 @@ | |||
| 29 | #include <errno.h> | 29 | #include <errno.h> |
| 30 | 30 | ||
| 31 | #include "parse-events.h" | 31 | #include "parse-events.h" |
| 32 | #include "trace-seq.h" | ||
| 33 | 32 | ||
| 34 | int header_page_ts_offset; | 33 | int header_page_ts_offset; |
| 35 | int header_page_ts_size; | 34 | int header_page_ts_size; |
diff --git a/parse-events.h b/parse-events.h index beee837..847d87e 100644 --- a/parse-events.h +++ b/parse-events.h | |||
| @@ -5,7 +5,43 @@ | |||
| 5 | #define __unused __attribute__ ((unused)) | 5 | #define __unused __attribute__ ((unused)) |
| 6 | #endif | 6 | #endif |
| 7 | 7 | ||
| 8 | #include "trace-seq.h" | 8 | /* ----------------------- trace_seq ----------------------- */ |
| 9 | |||
| 10 | |||
| 11 | #ifndef TRACE_SEQ_SIZE | ||
| 12 | #define TRACE_SEQ_SIZE 4096 | ||
| 13 | #endif | ||
| 14 | |||
| 15 | /* | ||
| 16 | * Trace sequences are used to allow a function to call several other functions | ||
| 17 | * to create a string of data to use (up to a max of PAGE_SIZE). | ||
| 18 | */ | ||
| 19 | |||
| 20 | struct trace_seq { | ||
| 21 | char buffer[TRACE_SEQ_SIZE]; | ||
| 22 | unsigned int len; | ||
| 23 | unsigned int readpos; | ||
| 24 | }; | ||
| 25 | |||
| 26 | static inline void | ||
| 27 | trace_seq_init(struct trace_seq *s) | ||
| 28 | { | ||
| 29 | s->len = 0; | ||
| 30 | s->readpos = 0; | ||
| 31 | } | ||
| 32 | |||
| 33 | extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | ||
| 34 | __attribute__ ((format (printf, 2, 3))); | ||
| 35 | extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | ||
| 36 | __attribute__ ((format (printf, 2, 0))); | ||
| 37 | |||
| 38 | extern int trace_seq_puts(struct trace_seq *s, const char *str); | ||
| 39 | extern int trace_seq_putc(struct trace_seq *s, unsigned char c); | ||
| 40 | |||
| 41 | extern int trace_seq_do_printf(struct trace_seq *s); | ||
| 42 | |||
| 43 | |||
| 44 | /* ----------------------- pevent ----------------------- */ | ||
| 9 | 45 | ||
| 10 | /* unique to trace-cmd */ | 46 | /* unique to trace-cmd */ |
| 11 | extern unsigned int page_size; | 47 | extern unsigned int page_size; |
diff --git a/trace-seq.c b/trace-seq.c index dc18893..3e3e059 100644 --- a/trace-seq.c +++ b/trace-seq.c | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | #include <stdarg.h> | 10 | #include <stdarg.h> |
| 11 | 11 | ||
| 12 | #include "parse-events.h" | 12 | #include "parse-events.h" |
| 13 | #include "trace-seq.h" | ||
| 14 | 13 | ||
| 15 | /** | 14 | /** |
| 16 | * trace_seq_printf - sequence printing of trace information | 15 | * trace_seq_printf - sequence printing of trace information |
| @@ -29,7 +28,7 @@ | |||
| 29 | int | 28 | int |
| 30 | trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | 29 | trace_seq_printf(struct trace_seq *s, const char *fmt, ...) |
| 31 | { | 30 | { |
| 32 | int len = (PAGE_SIZE - 1) - s->len; | 31 | int len = (TRACE_SEQ_SIZE - 1) - s->len; |
| 33 | va_list ap; | 32 | va_list ap; |
| 34 | int ret; | 33 | int ret; |
| 35 | 34 | ||
| @@ -63,7 +62,7 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |||
| 63 | int | 62 | int |
| 64 | trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | 63 | trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) |
| 65 | { | 64 | { |
| 66 | int len = (PAGE_SIZE - 1) - s->len; | 65 | int len = (TRACE_SEQ_SIZE - 1) - s->len; |
| 67 | int ret; | 66 | int ret; |
| 68 | 67 | ||
| 69 | if (!len) | 68 | if (!len) |
| @@ -94,7 +93,7 @@ int trace_seq_puts(struct trace_seq *s, const char *str) | |||
| 94 | { | 93 | { |
| 95 | int len = strlen(str); | 94 | int len = strlen(str); |
| 96 | 95 | ||
| 97 | if (len > ((PAGE_SIZE - 1) - s->len)) | 96 | if (len > ((TRACE_SEQ_SIZE - 1) - s->len)) |
| 98 | return 0; | 97 | return 0; |
| 99 | 98 | ||
| 100 | memcpy(s->buffer + s->len, str, len); | 99 | memcpy(s->buffer + s->len, str, len); |
| @@ -105,7 +104,7 @@ int trace_seq_puts(struct trace_seq *s, const char *str) | |||
| 105 | 104 | ||
| 106 | int trace_seq_putc(struct trace_seq *s, unsigned char c) | 105 | int trace_seq_putc(struct trace_seq *s, unsigned char c) |
| 107 | { | 106 | { |
| 108 | if (s->len >= (PAGE_SIZE - 1)) | 107 | if (s->len >= (TRACE_SEQ_SIZE - 1)) |
| 109 | return 0; | 108 | return 0; |
| 110 | 109 | ||
| 111 | s->buffer[s->len++] = c; | 110 | s->buffer[s->len++] = c; |
| @@ -121,7 +120,7 @@ int trace_seq_do_printf(struct trace_seq *s) | |||
| 121 | if (!s->len) | 120 | if (!s->len) |
| 122 | return 0; | 121 | return 0; |
| 123 | 122 | ||
| 124 | if (s->len < PAGE_SIZE) { | 123 | if (s->len < TRACE_SEQ_SIZE) { |
| 125 | s->buffer[s->len] = 0; | 124 | s->buffer[s->len] = 0; |
| 126 | return printf("%s", s->buffer); | 125 | return printf("%s", s->buffer); |
| 127 | } | 126 | } |
diff --git a/trace-seq.h b/trace-seq.h deleted file mode 100644 index 4bacc86..0000000 --- a/trace-seq.h +++ /dev/null | |||
| @@ -1,36 +0,0 @@ | |||
| 1 | #ifndef _TRACE_SEQ_H | ||
| 2 | #define _TRACE_SEQ_H | ||
| 3 | |||
| 4 | #ifndef PAGE_SIZE | ||
| 5 | #define PAGE_SIZE 4096 | ||
| 6 | #endif | ||
| 7 | |||
| 8 | /* | ||
| 9 | * Trace sequences are used to allow a function to call several other functions | ||
| 10 | * to create a string of data to use (up to a max of PAGE_SIZE). | ||
| 11 | */ | ||
| 12 | |||
| 13 | struct trace_seq { | ||
| 14 | char buffer[PAGE_SIZE]; | ||
| 15 | unsigned int len; | ||
| 16 | unsigned int readpos; | ||
| 17 | }; | ||
| 18 | |||
| 19 | static inline void | ||
| 20 | trace_seq_init(struct trace_seq *s) | ||
| 21 | { | ||
| 22 | s->len = 0; | ||
| 23 | s->readpos = 0; | ||
| 24 | } | ||
| 25 | |||
| 26 | extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | ||
| 27 | __attribute__ ((format (printf, 2, 3))); | ||
| 28 | extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | ||
| 29 | __attribute__ ((format (printf, 2, 0))); | ||
| 30 | |||
| 31 | extern int trace_seq_puts(struct trace_seq *s, const char *str); | ||
| 32 | extern int trace_seq_putc(struct trace_seq *s, unsigned char c); | ||
| 33 | |||
| 34 | extern int trace_seq_do_printf(struct trace_seq *s); | ||
| 35 | |||
| 36 | #endif /* _TRACE_SEQ_H */ | ||
