OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [kernel/] [v2_0/] [host/] [instr/] [dump_instr.c] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
 
2
#include <pkgconf/kernel.h>
3
#include <cyg/kernel/ktypes.h>         // base kernel types
4
#include <cyg/kernel/instrmnt.h>
5
 
6
#include <stdio.h>
7
#include <stdlib.h>
8
 
9
// -------------------------------------------------------------------------
10
// Instrumentation record.
11
 
12
struct Instrument_Record
13
{
14
    CYG_WORD16  type;                   // record type
15
    CYG_WORD16  thread;                 // current thread id
16
    CYG_WORD    timestamp;              // 32 bit timestamp
17
    CYG_WORD    arg1;                   // first arg
18
    CYG_WORD    arg2;                   // second arg
19
};
20
 
21
// -------------------------------------------------------------------------
22
 
23
#ifdef CYGDBG_KERNEL_INSTRUMENT_MSGS
24
#define CYGDBG_KERNEL_INSTRUMENT_MSGS_DEFINE_TABLE
25
#include <cyg/kernel/instrument_desc.h>
26
#define NELEM(x) (sizeof(x)/sizeof*(x))
27
externC char * cyg_instrument_msg(CYG_WORD16 type) {
28
 
29
  struct instrument_desc_s *record;
30
  struct instrument_desc_s *end_record;
31
  CYG_WORD cl, event;
32
 
33
  record = instrument_desc;
34
  end_record = &instrument_desc[NELEM(instrument_desc)-1];
35
  cl = type & 0xff00;
36
  event = type & 0x00ff;
37
 
38
  while ((record != end_record) && (record->num != cl)) {
39
    record++;
40
  }
41
 
42
  if (record->num == cl) {
43
    record++;
44
    while ((record != end_record) && (record->num != event) &&
45
           (record->num < 0xff)) {
46
      record++;
47
    }
48
 
49
    if (record->num == event) {
50
      return (record->msg);
51
    }
52
  }
53
  return("Unknown event");
54
}
55
#endif // CYGDBG_KERNEL_INSTRUMENT_MSGS
56
 
57
void usage(char *myname)
58
{
59
  fprintf(stderr,"Usage: %s <filename>\n",myname);
60
  fprintf(stderr,"where filename is that of the instrumentation data");
61
}
62
 
63
int main(int argc, char * argv[])
64
{
65
 
66
  FILE * file;
67
  char * filename;
68
  struct Instrument_Record record;
69
  int cnt=0;
70
 
71
  if (argc != 2) {
72
    usage(argv[0]);
73
    exit(1);
74
  }
75
 
76
  filename = argv[1];
77
 
78
  file = fopen(filename, "r");
79
  if (!file) {
80
    fprintf(stderr,"Error opening file %s: ",filename);
81
    perror("");
82
    exit(1);
83
  }
84
 
85
  while (!feof(file)) {
86
    fread(&record,sizeof(record),1,file);
87
    if (record.type == 0) {
88
      break;
89
    }
90
 
91
#ifdef CYGDBG_KERNEL_INSTRUMENT_MSGS 
92
    printf("%4d Record type (0x%04x): %-20s thread %2d, ",
93
           cnt++,record.type,cyg_instrument_msg(record.type),
94
           record.thread);
95
#else
96
    printf("%4d Record type 0x%04x, thread %2d, ",
97
           cnt++,record.type, record.thread);
98
#endif
99
    printf("time %5d, arg1 0x%08x, arg2 0x%08x\n",
100
           record.timestamp, record.arg1,
101
           record.arg2);
102
  }
103
 
104
  fclose(file);
105
  return (0);
106
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.