aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/timestamp.h55
-rw-r--r--src/ftcat.c20
-rw-r--r--src/timestamp.c29
3 files changed, 19 insertions, 85 deletions
diff --git a/include/timestamp.h b/include/timestamp.h
index b3393ed..3670541 100644
--- a/include/timestamp.h
+++ b/include/timestamp.h
@@ -47,59 +47,4 @@ const char* event2str(cmd_t id);
47#define TS_PLUGIN_TICK_START TIMESTAMP(130) 47#define TS_PLUGIN_TICK_START TIMESTAMP(130)
48#define TS_PLUGIN_TICK_END TIMESTAMP(131) 48#define TS_PLUGIN_TICK_END TIMESTAMP(131)
49 49
50#define TS_ENTER_NP_START TIMESTAMP(140)
51#define TS_ENTER_NP_END TIMESTAMP(141)
52
53#define TS_EXIT_NP_START TIMESTAMP(150)
54#define TS_EXIT_NP_END TIMESTAMP(151)
55
56#define TS_SRP_UP_START TIMESTAMP(160)
57#define TS_SRP_UP_END TIMESTAMP(161)
58#define TS_SRP_DOWN_START TIMESTAMP(162)
59#define TS_SRP_DOWN_END TIMESTAMP(163)
60
61#define TS_PI_UP_START TIMESTAMP(170)
62#define TS_PI_UP_END TIMESTAMP(171)
63#define TS_PI_DOWN_START TIMESTAMP(172)
64#define TS_PI_DOWN_END TIMESTAMP(173)
65
66#define TS_FIFO_UP_START TIMESTAMP(180)
67#define TS_FIFO_UP_END TIMESTAMP(181)
68#define TS_FIFO_DOWN_START TIMESTAMP(182)
69#define TS_FIFO_DOWN_END TIMESTAMP(183)
70
71#define PCP1 200
72#define PCP2 204
73
74#define DPCP 210
75#define MPCP 220
76#define FMLP 230
77#define SRPT 240
78
79#define TS_PCP_UP_START TIMESTAMP(PCP1)
80#define TS_PCP_UP_END TIMESTAMP(PCP1 + 1)
81#define TS_PCP1_DOWN_START TIMESTAMP(PCP1 + 2)
82#define TS_PCP1_DOWN_END TIMESTAMP(PCP1 + 3)
83#define TS_PCP2_DOWN_START TIMESTAMP(PCP2 + 2)
84
85#define TS_PCP2_DOWN_END TIMESTAMP(PCP2 + 3)
86
87#define TS_DPCP_INVOKE_START TIMESTAMP(DPCP)
88#define TS_DPCP_INVOKE_END TIMESTAMP(DPCP + 1)
89#define TS_DPCP_AGENT1_START TIMESTAMP(DPCP + 2)
90#define TS_DPCP_AGENT1_END TIMESTAMP(DPCP + 3)
91#define TS_DPCP_AGENT2_START TIMESTAMP(DPCP + 4)
92#define TS_DPCP_AGENT2_END TIMESTAMP(DPCP + 5)
93
94#define TS_MPCP_UP_START TIMESTAMP(MPCP)
95#define TS_MPCP_UP_END TIMESTAMP(MPCP + 1)
96#define TS_MPCP_DOWN_START TIMESTAMP(MPCP + 2)
97#define TS_MPCP_DOWN_END TIMESTAMP(MPCP + 3)
98
99
100#define TS_SRPT_START TIMESTAMP(SRPT)
101#define TS_SRPT_END TIMESTAMP(SRPT + 1)
102
103
104
105#endif 50#endif
diff --git a/src/ftcat.c b/src/ftcat.c
index 28f1924..f0a1c5f 100644
--- a/src/ftcat.c
+++ b/src/ftcat.c
@@ -21,6 +21,8 @@
21#include <string.h> 21#include <string.h>
22#include <signal.h> 22#include <signal.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <unistd.h>
25#include <errno.h>
24 26
25#include "timestamp.h" 27#include "timestamp.h"
26 28
@@ -44,14 +46,16 @@ static int disable_all(int fd)
44 return size == ret; 46 return size == ret;
45} 47}
46 48
47static int enable_events(int fd, char* str) 49static int enable_event(int fd, char* str)
48{ 50{
49 cmd_t *id; 51 cmd_t *id;
50 cmd_t cmd[2]; 52 cmd_t cmd[2];
51 53
52 id = ids + event_count; 54 id = ids + event_count;
53 if (!str2event(str, id)) 55 if (!str2event(str, id)) {
56 errno = EINVAL;
54 return 0; 57 return 0;
58 }
55 59
56 event_count += 1; 60 event_count += 1;
57 cmd[0] = ENABLE_CMD; 61 cmd[0] = ENABLE_CMD;
@@ -60,7 +64,7 @@ static int enable_events(int fd, char* str)
60} 64}
61 65
62 66
63static void cat2stdout(int fd) 67static void cat2stdout(int fd)
64{ 68{
65 static char buf[4096]; 69 static char buf[4096];
66 int rd; 70 int rd;
@@ -73,7 +77,7 @@ static void cat2stdout(int fd)
73 77
74static void usage(void) 78static void usage(void)
75{ 79{
76 fprintf(stderr, 80 fprintf(stderr,
77 "Usage: ftcat <ft device> TS1 TS2 ...." 81 "Usage: ftcat <ft device> TS1 TS2 ...."
78 "\n"); 82 "\n");
79 exit(1); 83 exit(1);
@@ -94,12 +98,12 @@ static void shutdown(int sig)
94 fprintf(stderr, "disable_all: %m\n"); 98 fprintf(stderr, "disable_all: %m\n");
95} 99}
96 100
97int main(int argc, char** argv) 101int main(int argc, char** argv)
98{ 102{
99 const char* trace_file; 103 const char* trace_file;
100 if (argc < 3) 104 if (argc < 3)
101 usage(); 105 usage();
102 106
103 trace_file = argv[1]; 107 trace_file = argv[1];
104 fd = open(trace_file, O_RDWR); 108 fd = open(trace_file, O_RDWR);
105 if (fd < 0) { 109 if (fd < 0) {
@@ -112,7 +116,7 @@ int main(int argc, char** argv)
112 signal(SIGUSR1, shutdown); 116 signal(SIGUSR1, shutdown);
113 signal(SIGTERM, shutdown); 117 signal(SIGTERM, shutdown);
114 while (argc--) { 118 while (argc--) {
115 if (!enable_events(fd, *argv)) { 119 if (!enable_event(fd, *argv)) {
116 fprintf(stderr, "Enabling %s failed: %m\n", *argv); 120 fprintf(stderr, "Enabling %s failed: %m\n", *argv);
117 return 2; 121 return 2;
118 } 122 }
diff --git a/src/timestamp.c b/src/timestamp.c
index f3f7861..9ad43f1 100644
--- a/src/timestamp.c
+++ b/src/timestamp.c
@@ -8,9 +8,11 @@ struct event_name {
8 cmd_t id; 8 cmd_t id;
9}; 9};
10 10
11#define EVENT(name) {#name, TS_ ## name ## _START} 11#define EVENT(name) \
12 {#name "_START", TS_ ## name ## _START}, \
13 {#name "_END", TS_ ## name ## _END}
12 14
13static struct event_name event_table[] = 15static struct event_name event_table[] =
14{ 16{
15 EVENT(SCHED), 17 EVENT(SCHED),
16 EVENT(SCHED2), 18 EVENT(SCHED2),
@@ -19,28 +21,11 @@ static struct event_name event_table[] =
19 EVENT(PLUGIN_SCHED), 21 EVENT(PLUGIN_SCHED),
20 EVENT(PLUGIN_TICK), 22 EVENT(PLUGIN_TICK),
21 EVENT(CXS), 23 EVENT(CXS),
22 EVENT(ENTER_NP),
23 EVENT(EXIT_NP),
24 EVENT(SRP_UP),
25 EVENT(SRP_DOWN),
26 EVENT(PI_UP),
27 EVENT(PI_DOWN),
28 EVENT(FIFO_UP),
29 EVENT(FIFO_DOWN),
30 EVENT(PCP_UP),
31 EVENT(PCP1_DOWN),
32 EVENT(PCP2_DOWN),
33 EVENT(DPCP_INVOKE),
34 EVENT(DPCP_AGENT1),
35 EVENT(DPCP_AGENT2),
36 EVENT(MPCP_UP),
37 EVENT(MPCP_DOWN),
38 EVENT(SRPT)
39}; 24};
40 25
41int str2event(const char* str, cmd_t *id) 26int str2event(const char* str, cmd_t *id)
42{ 27{
43 int i; 28 int i;
44 29
45 for (i = 0; i < sizeof(event_table) / sizeof(event_table[0]); i++) 30 for (i = 0; i < sizeof(event_table) / sizeof(event_table[0]); i++)
46 if (!strcmp(str, event_table[i].name)) { 31 if (!strcmp(str, event_table[i].name)) {
@@ -53,11 +38,11 @@ int str2event(const char* str, cmd_t *id)
53 38
54const char* event2str(cmd_t id) 39const char* event2str(cmd_t id)
55{ 40{
56 int i; 41 int i;
57 42
58 for (i = 0; i < sizeof(event_table) / sizeof(event_table[0]); i++) 43 for (i = 0; i < sizeof(event_table) / sizeof(event_table[0]); i++)
59 if (event_table[i].id == id) 44 if (event_table[i].id == id)
60 return event_table[i].name; 45 return event_table[i].name;
61 46
62 return NULL; 47 return NULL;
63} 48}