-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrace_reader.c
46 lines (35 loc) · 933 Bytes
/
trace_reader.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/** Code by @author Wonsun Ahn
*
* Utility program to read and print out the contents of a trace file in human
* readable format. Takes as argument the name of the file.
*/
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <arpa/inet.h>
#include "trace.h"
int main(int argc, char **argv)
{
instruction *tr_entry = (instruction *) malloc(sizeof(instruction));
size_t size;
char *trace_file_name;
dynamic_inst dinst = {0};
if (argc == 1) {
fprintf(stdout, "\nMissing argument: the name of the file to be read\n");
exit(0);
}
trace_file_name = argv[1];
trace_fd = fopen(trace_file_name, "rb");
trace_init();
while(1) {
size = trace_get_item(&tr_entry);
if (!size)
break;
// Display the generated trace
dinst.seq++;
dinst.inst = *tr_entry;
printf("%s\n", get_instruction_string(dinst, LONG_FORM));
}
trace_uninit();
exit(0);
}