source: rtems-tools/tester/covoar/qemu-dump-trace.c @ f9a4b2c

5
Last change on this file since f9a4b2c was 100f517, checked in by Chris Johns <chrisj@…>, on 05/09/14 at 11:50:37

covoar: Merger the covoar source from rtems-testing.git.

Use waf to build covoar.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#include <stdint.h>
2#include <stdio.h>
3#include <errno.h>
4#include <string.h>
5
6#include "qemu-traces.h"
7
8
9int dump_file(
10  const char *name
11)
12{
13  FILE *trace;
14  struct trace_header header;
15  struct trace_entry  entry;
16  size_t              bytes;
17  int                 instructions;
18
19  trace = fopen( name, "r" );
20  if ( !trace ) {
21    perror( "unable to open trace file" );
22    return -1;
23  }
24
25  bytes = fread( &header, sizeof(struct trace_header), 1, trace );
26  if ( bytes != 1 ) {
27    fprintf( stderr, "error reading header of %s (%s)\n",
28             name, strerror(errno) );
29    return -1;
30  }
31  printf( "magic = %s\n", header.magic );
32  printf( "version = %d\n", header.version );
33  printf( "kind = %d\n", header.kind );
34  printf( "sizeof_target_pc = %d\n", header.sizeof_target_pc );
35  printf( "big_endian = %d\n", header.big_endian );
36  printf( "machine = %02x:%02x\n", header.machine[0], header.machine[1] );
37
38  instructions = 0;
39  while (1) {
40    bytes = fread( &entry, sizeof(struct trace_entry), 1, trace );
41    if ( bytes != 1 )
42      break;
43    instructions++;
44    printf( "0x%08x %d 0x%2x\n", entry.pc, entry.size, entry.op );
45  }
46
47 
48  fclose( trace );
49  printf( "instructions = %d\n", instructions );
50 
51  return 0;
52
53}
54
55int main(
56  int argc,
57  char **argv
58)
59{
60  int i;
61
62  for (i=1 ; i<argc ; i++) {
63    if ( dump_file( argv[i] ) )
64      return -1;
65  }
66  return 0;
67}
Note: See TracBrowser for help on using the repository browser.