The Android Open Source Project | 52d4c30 | 2009-03-03 19:29:09 -0800 | [diff] [blame^] | 1 | #include <stdio.h> |
| 2 | #include <unistd.h> |
| 3 | #include <stdlib.h> |
| 4 | #include <inttypes.h> |
| 5 | #include "trace_reader.h" |
| 6 | #include "parse_options.h" |
| 7 | |
| 8 | typedef TraceReader<> TraceReaderType; |
| 9 | |
| 10 | #include "parse_options-inl.h" |
| 11 | |
| 12 | void Usage(const char *program) |
| 13 | { |
| 14 | fprintf(stderr, "Usage: %s [options] trace_name elf_file\n", |
| 15 | program); |
| 16 | OptionsUsage(); |
| 17 | } |
| 18 | |
| 19 | int main(int argc, char **argv) { |
| 20 | ParseOptions(argc, argv); |
| 21 | if (argc - optind != 2) { |
| 22 | Usage(argv[0]); |
| 23 | exit(1); |
| 24 | } |
| 25 | |
| 26 | char *qemu_trace_file = argv[optind++]; |
| 27 | char *elf_file = argv[optind++]; |
| 28 | TraceReaderType *trace = new TraceReaderType; |
| 29 | trace->Open(qemu_trace_file); |
| 30 | trace->ReadKernelSymbols(elf_file); |
| 31 | trace->SetRoot(root); |
| 32 | |
| 33 | while (1) { |
| 34 | MethodRec method_record; |
| 35 | symbol_type *sym; |
| 36 | TraceReaderType::ProcessState *proc; |
| 37 | |
| 38 | if (trace->ReadMethodSymbol(&method_record, &sym, &proc)) |
| 39 | break; |
| 40 | if (sym != NULL) { |
| 41 | printf("%lld p %d 0x%x %d %s\n", |
| 42 | method_record.time, proc->pid, method_record.addr, |
| 43 | method_record.flags, sym->name); |
| 44 | } else { |
| 45 | printf("%lld p %d 0x%x %d\n", |
| 46 | method_record.time, proc->pid, method_record.addr, |
| 47 | method_record.flags); |
| 48 | } |
| 49 | proc->DumpStack(); |
| 50 | } |
| 51 | return 0; |
| 52 | } |