1 #include <stdio.h>
2 #include <unistd.h>
3 #include <stdlib.h>
4 #include <inttypes.h>
5 #include <string.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\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 != 1) {
23 Usage(argv[0]);
24 exit(1);
25 }
26
27 char *trace_filename = argv[optind];
28 TraceReader<> *trace = new TraceReader<>;
29 trace->Open(trace_filename);
30 trace->SetRoot(root);
31
32 while (1) {
33 BBEvent event, ignored;
34 symbol_type *dummy_sym;
35
36 if (GetNextValidEvent(trace, &event, &ignored, &dummy_sym))
37 break;
38 }
39
40 int num_procs;
41 ProcessState *processes = trace->GetProcesses(&num_procs);
42
43 ProcessState *pstate = &processes[0];
44 for (int ii = 0; ii < num_procs; ++ii, ++pstate) {
45 if (pstate->name == NULL)
46 pstate->name = "";
47 ProcessState *manager = pstate->addr_manager;
48 printf("pid %d regions: %d %s",
49 pstate->pid, manager->nregions, pstate->name);
50 for (int jj = 1; jj < pstate->argc; ++jj) {
51 printf(" %s", pstate->argv[jj]);
52 }
53 printf("\n");
54 trace->DumpRegions(stdout, pstate);
55 }
56
57 delete trace;
58 return 0;
59 }
60