diff options
Diffstat (limited to 'src/ft2csv.c')
-rw-r--r-- | src/ft2csv.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/ft2csv.c b/src/ft2csv.c index 66efa42..ea497a3 100644 --- a/src/ft2csv.c +++ b/src/ft2csv.c | |||
@@ -48,7 +48,8 @@ static struct timestamp* next(struct timestamp* start, struct timestamp* end, | |||
48 | } | 48 | } |
49 | 49 | ||
50 | static struct timestamp* next_id(struct timestamp* start, struct timestamp* end, | 50 | static struct timestamp* next_id(struct timestamp* start, struct timestamp* end, |
51 | int cpu, unsigned long id, unsigned long stop_id) | 51 | int cpu, unsigned long id, |
52 | unsigned long stop_id) | ||
52 | { | 53 | { |
53 | struct timestamp* pos = start; | 54 | struct timestamp* pos = start; |
54 | int restarts = 0; | 55 | int restarts = 0; |
@@ -68,10 +69,12 @@ static struct timestamp* next_id(struct timestamp* start, struct timestamp* end, | |||
68 | return pos; | 69 | return pos; |
69 | } | 70 | } |
70 | 71 | ||
71 | static struct timestamp* find_second_ts(struct timestamp* start, struct timestamp* end) | 72 | static struct timestamp* find_second_ts(struct timestamp* start, |
73 | struct timestamp* end) | ||
72 | { | 74 | { |
73 | /* convention: the end->event is start->event + 1 */ | 75 | /* convention: the end->event is start->event + 1 */ |
74 | return next_id(start + 1, end, start->cpu, start->event + 1, start->event); | 76 | return next_id(start + 1, end, start->cpu, start->event + 1, |
77 | start->event); | ||
75 | } | 78 | } |
76 | 79 | ||
77 | static void show_csv(struct timestamp* first, struct timestamp *end) | 80 | static void show_csv(struct timestamp* first, struct timestamp *end) |
@@ -111,8 +114,9 @@ static inline uint64_t bput(uint64_t b, int pos) | |||
111 | 114 | ||
112 | static inline uint64_t ntohx(uint64_t q) | 115 | static inline uint64_t ntohx(uint64_t q) |
113 | { | 116 | { |
114 | return (bput(bget(0, q), 7) | bput(bget(1, q), 6) | bput(bget(2, q), 5) | | 117 | return (bput(bget(0, q), 7) | bput(bget(1, q), 6) | |
115 | bput(bget(3, q), 4) | bput(bget(4, q), 3) | bput(bget(5, q), 2) | | 118 | bput(bget(2, q), 5) | bput(bget(3, q), 4) | |
119 | bput(bget(4, q), 3) | bput(bget(5, q), 2) | | ||
116 | bput(bget(6, q), 1) | bput(bget(7, q), 0)); | 120 | bput(bget(6, q), 1) | bput(bget(7, q), 0)); |
117 | } | 121 | } |
118 | 122 | ||
@@ -126,7 +130,6 @@ static void restore_byte_order(struct timestamp* start, struct timestamp* end) | |||
126 | } | 130 | } |
127 | } | 131 | } |
128 | 132 | ||
129 | |||
130 | static void show_id(struct timestamp* start, struct timestamp* end, | 133 | static void show_id(struct timestamp* start, struct timestamp* end, |
131 | unsigned long id) | 134 | unsigned long id) |
132 | { | 135 | { |
@@ -167,13 +170,8 @@ int main(int argc, char** argv) | |||
167 | cmd_t id; | 170 | cmd_t id; |
168 | int swap_byte_order = 0; | 171 | int swap_byte_order = 0; |
169 | int opt; | 172 | int opt; |
173 | char event_name[80]; | ||
170 | 174 | ||
171 | /* | ||
172 | printf("%llx -> %llx\n", 0xaabbccddeeff1122ll, | ||
173 | ntohx(0xaabbccddeeff1122ll)); | ||
174 | printf("%x -> %x\n", 0xaabbccdd, | ||
175 | ntohl(0xaabbccdd)); | ||
176 | */ | ||
177 | while ((opt = getopt(argc, argv, OPTS)) != -1) { | 175 | while ((opt = getopt(argc, argv, OPTS)) != -1) { |
178 | switch (opt) { | 176 | switch (opt) { |
179 | case 'e': | 177 | case 'e': |
@@ -196,8 +194,13 @@ int main(int argc, char** argv) | |||
196 | if (map_file(argv[optind + 1], &mapped, &size)) | 194 | if (map_file(argv[optind + 1], &mapped, &size)) |
197 | die("could not map file"); | 195 | die("could not map file"); |
198 | 196 | ||
199 | if (!str2event(argv[optind], &id)) | 197 | if (!str2event(argv[optind], &id)) { |
200 | die("Unknown event!"); | 198 | /* see if it is a short name */ |
199 | snprintf(event_name, sizeof(event_name), "%s_START", | ||
200 | argv[optind]); | ||
201 | if (!str2event(event_name, &id)) | ||
202 | die("Unknown event!"); | ||
203 | } | ||
201 | 204 | ||
202 | ts = (struct timestamp*) mapped; | 205 | ts = (struct timestamp*) mapped; |
203 | count = size / sizeof(struct timestamp); | 206 | count = size / sizeof(struct timestamp); |