1 #include <stdio.h>
2 #include <unistd.h>
3 #include <stdlib.h>
4 #include <inttypes.h>
5 #include <assert.h>
6 #include "trace_reader.h"
7 #include "parse_options.h"
8
9 typedef TraceReader<> TraceReaderType;
10
11 #include "parse_options-inl.h"
12
Usage(const char * program)13 void Usage(const char *program)
14 {
15 fprintf(stderr, "Usage: %s [options] trace_file elf_file\n", program);
16 OptionsUsage();
17 }
18
main(int argc,char ** argv)19 int main(int argc, char **argv) {
20 // Parse the options
21 ParseOptions(argc, argv);
22 if (argc - optind != 2) {
23 Usage(argv[0]);
24 exit(1);
25 }
26
27 char *trace_filename = argv[optind++];
28 char *elf_file = argv[optind++];
29 TraceReader<> *trace = new TraceReader<>;
30 trace->Open(trace_filename);
31 trace->ReadKernelSymbols(elf_file);
32 trace->SetRoot(root);
33
34 printf("# time bb pid num_insns bb_addr\n");
35 while (1) {
36 symbol_type *sym;
37 BBEvent event;
38 BBEvent ignored;
39
40 if (GetNextValidEvent(trace, &event, &ignored, &sym))
41 break;
42 printf("%7lld %4lld %5d %3d 0x%08x %s\n",
43 event.time, event.bb_num, event.pid, event.num_insns,
44 event.bb_addr, sym->name);
45 }
46 return 0;
47 }
48