aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/qtools/read_addr.cpp
blob: 38fc62a36a40210b9e27e11bf3345fa5ee0ad7d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "trace_reader.h"

int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s trace_file\n", argv[0]);
    exit(1);
  }

  char *trace_filename = argv[1];
  TraceReaderBase *trace = new TraceReaderBase;
  trace->Open(trace_filename);

  while (1) {
    uint64_t time;
    uint32_t addr;
    int flags;

    if (trace->ReadAddr(&time, &addr, &flags))
      break;
    char *op = "ld";
    if (flags == 1)
        op = "st";
    printf("%lld 0x%08x %s\n", time, addr, op);
  }
  return 0;
}