2 #include <pkgconf/kernel.h>
3 #include <cyg/kernel/ktypes.h> // base kernel types
4 #include <cyg/kernel/instrmnt.h>
9 // -------------------------------------------------------------------------
10 // Instrumentation record.
12 struct Instrument_Record
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
21 // -------------------------------------------------------------------------
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) {
29 struct instrument_desc_s *record;
30 struct instrument_desc_s *end_record;
33 record = instrument_desc;
34 end_record = &instrument_desc[NELEM(instrument_desc)-1];
36 event = type & 0x00ff;
38 while ((record != end_record) && (record->num != cl)) {
42 if (record->num == cl) {
44 while ((record != end_record) && (record->num != event) &&
45 (record->num < 0xff)) {
49 if (record->num == event) {
53 return("Unknown event");
55 #endif // CYGDBG_KERNEL_INSTRUMENT_MSGS
57 void usage(char *myname)
59 fprintf(stderr,"Usage: %s <filename>\n",myname);
60 fprintf(stderr,"where filename is that of the instrumentation data");
63 int main(int argc, char * argv[])
68 struct Instrument_Record record;
78 file = fopen(filename, "r");
80 fprintf(stderr,"Error opening file %s: ",filename);
86 fread(&record,sizeof(record),1,file);
87 if (record.type == 0) {
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),
96 printf("%4d Record type 0x%04x, thread %2d, ",
97 cnt++,record.type, record.thread);
99 printf("time %5d, arg1 0x%08x, arg2 0x%08x\n",
100 record.timestamp, record.arg1,