diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-22 21:12:44 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-22 21:12:44 -0400 |
commit | a9fa5274f88475570483c579f6ef5ee9eb64d80a (patch) | |
tree | 1569bb760a2d19eac6ed1b88d97d03254854ca6f | |
parent | 5ef64e006c200e7213ae3cc52cb02bd172bfe97d (diff) |
add dump tool
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | src/ftdump.c | 44 |
2 files changed, 49 insertions, 1 deletions
@@ -13,7 +13,7 @@ vpath %.c src/ | |||
13 | 13 | ||
14 | .PHONY: clean | 14 | .PHONY: clean |
15 | 15 | ||
16 | TOOLS = ftcat ft2csv | 16 | TOOLS = ftcat ft2csv ftdump |
17 | 17 | ||
18 | all: ${TOOLS} | 18 | all: ${TOOLS} |
19 | 19 | ||
@@ -25,5 +25,9 @@ FT2CSV_OBJ = ft2csv.o mapping.o timestamp.o | |||
25 | ft2csv: ${FT2CSV_OBJ} | 25 | ft2csv: ${FT2CSV_OBJ} |
26 | ${CC} ${CFLAGS} -o ft2csv ${FT2CSV_OBJ} | 26 | ${CC} ${CFLAGS} -o ft2csv ${FT2CSV_OBJ} |
27 | 27 | ||
28 | FT2CSV_OBJ = ftdump.o mapping.o timestamp.o | ||
29 | ftdump: ${FT2CSV_OBJ} | ||
30 | ${CC} ${CFLAGS} -o ftdump ${FT2CSV_OBJ} | ||
31 | |||
28 | clean: | 32 | clean: |
29 | rm -rf *.o ${TOOLS} | 33 | rm -rf *.o ${TOOLS} |
diff --git a/src/ftdump.c b/src/ftdump.c new file mode 100644 index 0000000..849d6ee --- /dev/null +++ b/src/ftdump.c | |||
@@ -0,0 +1,44 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <string.h> | ||
4 | #include <errno.h> | ||
5 | |||
6 | #include "mapping.h" | ||
7 | |||
8 | #include "timestamp.h" | ||
9 | |||
10 | static void dump(struct timestamp* ts, size_t count) | ||
11 | { | ||
12 | struct timestamp *x; | ||
13 | while (count--) { | ||
14 | x = ts++; | ||
15 | printf("event:%d seq:%u cpu:%d type:%d\n", | ||
16 | (int) x->event, x->seq_no, x->cpu, x->task_type); | ||
17 | } | ||
18 | } | ||
19 | |||
20 | static void die(char* msg) | ||
21 | { | ||
22 | if (errno) | ||
23 | perror("error: "); | ||
24 | fprintf(stderr, "%s\n", msg); | ||
25 | exit(1); | ||
26 | } | ||
27 | |||
28 | int main(int argc, char** argv) | ||
29 | { | ||
30 | void* mapped; | ||
31 | size_t size, count; | ||
32 | struct timestamp* ts; | ||
33 | |||
34 | if (argc != 2) | ||
35 | die("Usage: ftdump <logfile>"); | ||
36 | if (map_file(argv[1], &mapped, &size)) | ||
37 | die("could not map file"); | ||
38 | |||
39 | ts = (struct timestamp*) mapped; | ||
40 | count = size / sizeof(struct timestamp); | ||
41 | |||
42 | dump(ts, count); | ||
43 | return 0; | ||
44 | } | ||