00001
00018
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021
00022
00023
00024
00025
00026
00027
00028
00029
00032 typedef char tag_t;
00033
00035 typedef unsigned long long int timestamp_t;
00036
00038 typedef unsigned char length_t;
00039
00042 typedef unsigned long int address_space_ID_t;
00043
00045 typedef unsigned long int address_t;
00046
00049 struct reference_record_s {
00050
00051 tag_t tag;
00052 timestamp_t timestamp;
00053 length_t length;
00054 address_space_ID_t address_space_ID;
00055 address_t virtual_address;
00056
00057 };
00058
00059
00060
00061
00062
00063
00064
00065 const tag_t TAG_END_OF_TRACE = 'e';
00066
00067
00068
00069
00070
00084 int
00085 main (const unsigned int argc, const char** const argv) {
00086
00087
00088 if (argc != 1) {
00089
00090
00091 fprintf(stderr, "Usage: %s <NO ARGUMENTS>\n", argv[0]);
00092 return 1;
00093
00094 }
00095
00096
00097
00098 reference_record_s binary_record;
00099
00100
00101 do {
00102
00103
00104 size_t read_result = fread(&binary_record,
00105 sizeof(binary_record),
00106 1,
00107 stdin);
00108
00109
00110 if (read_result != 1) {
00111
00112 if (feof(stdin)) {
00113 fprintf(stderr, "Premature EOF\n");
00114 } else {
00115 fprintf(stderr, "Failed in reading binary record\n");
00116 }
00117
00118 exit(1);
00119
00120 }
00121
00122
00123
00124 if (binary_record.tag == TAG_END_OF_TRACE) {
00125
00126 printf("%c\n", binary_record.tag);
00127
00128 } else {
00129
00130 printf("%c %qx %hx %lx %lx\n",
00131 binary_record.tag,
00132 binary_record.timestamp,
00133 binary_record.length,
00134 binary_record.address_space_ID,
00135 binary_record.virtual_address);
00136
00137 }
00138
00139 } while (binary_record.tag != TAG_END_OF_TRACE);
00140
00141
00142 return 0;
00143
00144 }
00145