summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2009-04-14 15:30:45 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2009-04-14 15:30:45 -0400
commit05f4d728dc070a7a25a5b9ec5b85bf3f0cdd0dd9 (patch)
tree15f54c55a967a11bd4eb731b4b283c075697aa23
parentdc1a00d9d138d574d250ef8d4cf2cbcb59a592c9 (diff)
support for -r (find system release and exit) in st_show
-rw-r--r--src/showst.c61
1 files changed, 52 insertions, 9 deletions
diff --git a/src/showst.c b/src/showst.c
index 5594ec5..3e68be6 100644
--- a/src/showst.c
+++ b/src/showst.c
@@ -1,29 +1,72 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <unistd.h>
3 4
4#include "load.h" 5#include "load.h"
5#include "sched_trace.h" 6#include "sched_trace.h"
6#include "eheap.h" 7#include "eheap.h"
7 8
9static void usage(const char *str)
10{
11 fprintf(stderr,
12 "\n USAGE\n"
13 "\n"
14 " st_show [opts] <file.st>+\n"
15 "\n"
16 " OPTIONS\n"
17 " -r -- find task system release and exit\n"
18 "\n\n"
19 );
20 fprintf(stderr, "Aborted: %s\n", str);
21 exit(1);
22}
23
24#define OPTSTR "r"
25
8int main(int argc, char** argv) 26int main(int argc, char** argv)
9{ 27{
10 unsigned int count; 28 unsigned int count;
11 struct heap *h; 29 struct heap *h;
12 struct heap_node *hn; 30 struct heap_node *hn;
13 u64 start_time = 0, time; 31 u64 time;
32 struct st_event_record *rec;
33 int find_release = 0;
34 int opt;
35
36 while ((opt = getopt(argc, argv, OPTSTR)) != -1) {
37 switch (opt) {
38 case 'r':
39 find_release = 1;
40 break;
41 case ':':
42 usage("Argument missing.");
43 break;
44 case '?':
45 default:
46 usage("Bad argument.");
47 break;
48 }
49 }
50
14 51
15 h = load(argv + 1, argc - 1, &count); 52 h = load(argv + optind, argc - optind, &count);
16 if (!h) 53 if (!h)
17 return 1; 54 return 1;
18 printf("Loaded %u events.\n", count); 55 if (!find_release)
56 printf("Loaded %u events.\n", count);
19 while ((hn = heap_take(earlier_event, h))) { 57 while ((hn = heap_take(earlier_event, h))) {
20 time = event_time(heap_node_value(hn)); 58 time = event_time(heap_node_value(hn));
21/* if (!start_time && time) 59 time /= 1000000; /* convert to milliseconds */
22 start_time = time; 60 if (!find_release) {
23 time -= start_time; 61 printf("[%10llu] ", (unsigned long long) time);
24*/ time /= 1000000; /* convert to milliseconds */ 62 print_event(heap_node_value(hn));
25 printf("[%10llu] ", time); 63 } else {
26 print_event(heap_node_value(hn)); 64 rec = heap_node_value(hn);
65 if (rec->hdr.type == ST_SYS_RELEASE) {
66 printf("%6.2fms\n", rec->data.raw[1] / 1000000.0);
67 break;
68 }
69 }
27 } 70 }
28 71
29 return 0; 72 return 0;