aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-09-24 17:14:09 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-09-24 17:14:09 -0400
commit4a8b806b5f13df589a4800051b84f062efc2951d (patch)
treecd628039a6bbd6b48975e7cbf2d154a9681287d8
parent4f4d1a3992af845d0751962759aceb44e0050e22 (diff)
add tool to dump sched_trace fiels
-rw-r--r--Makefile5
-rw-r--r--bin/showst.c67
2 files changed, 71 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index b00ae23..361a891 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ LIBS= ./liblitmus.a
19LIB_OBJ= litmus.o syscalls.o sched_trace.o task.o kernel_iface.o 19LIB_OBJ= litmus.o syscalls.o sched_trace.o task.o kernel_iface.o
20 20
21TARGETS = run rt_launch liblitmus.a \ 21TARGETS = run rt_launch liblitmus.a \
22 wait_test np_test mode_test base_task base_mt_task release_ts 22 wait_test np_test mode_test base_task base_mt_task release_ts showst
23 23
24vpath %.h include/ 24vpath %.h include/
25vpath %.c src/ bin/ 25vpath %.c src/ bin/
@@ -52,6 +52,9 @@ rt_launch: liblitmus.a litmus.h rt_launch.o common.o
52release_ts: liblitmus.a litmus.h release_ts.o 52release_ts: liblitmus.a litmus.h release_ts.o
53 ${CC} ${CFLAGS} -static -o release_ts release_ts.o ${LIBS} 53 ${CC} ${CFLAGS} -static -o release_ts release_ts.o ${LIBS}
54 54
55showst : liblitmus.a litmus.h showst.o
56 ${CC} ${CFLAGS} -o showst showst.o ${LIBS}
57
55liblitmus.a: ${LIB_OBJ} litmus.h 58liblitmus.a: ${LIB_OBJ} litmus.h
56 ${AR} rcs liblitmus.a ${LIB_OBJ} 59 ${AR} rcs liblitmus.a ${LIB_OBJ}
57 60
diff --git a/bin/showst.c b/bin/showst.c
new file mode 100644
index 0000000..1580adf
--- /dev/null
+++ b/bin/showst.c
@@ -0,0 +1,67 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <sys/types.h>
4#include <sys/stat.h>
5#include <sys/mman.h>
6#include <fcntl.h>
7#include <unistd.h>
8
9#include "sched_trace.h"
10
11static int map_file(const char* filename, void **addr, size_t *size)
12{
13 struct stat info;
14 int error = 0;
15 int fd;
16
17 error = stat(filename, &info);
18 if (!error) {
19 *size = info.st_size;
20 if (info.st_size > 0) {
21 fd = open(filename, O_RDONLY);
22 if (fd >= 0) {
23 *addr = mmap(NULL, *size,
24 PROT_READ | PROT_WRITE,
25 MAP_PRIVATE, fd, 0);
26 if (*addr == MAP_FAILED)
27 error = -1;
28 close(fd);
29 } else
30 error = fd;
31 } else
32 *addr = NULL;
33 }
34 return error;
35}
36
37static int map_trace(const char *name, void **start, void **end, size_t *size)
38{
39 int ret;
40
41 ret = map_file(name, start, size);
42 if (!ret)
43 *end = *start + *size;
44 return ret;
45}
46
47
48static void show(char* file)
49{
50 size_t s;
51 struct st_event_record *rec, *end;
52 unsigned int count;
53 if (map_trace(file, &rec, &end, &s) == 0) {
54 print_all(rec,
55 ((unsigned int)((char*) end - (char*) rec))
56 / sizeof(struct st_event_record));
57 } else
58 perror("mmap");
59}
60
61int main(int argc, char** argv)
62{
63 int i;
64 for (i = 1; i < argc; i++)
65 show(argv[i]);
66 return 0;
67}