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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [kernel/] [current/] [host/] [instr/] [dump_instr.c] - Blame information for rev 851

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

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

powered by: WebSVN 2.1.0

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