-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
50 lines (43 loc) · 1.07 KB
/
main.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
45
46
47
48
49
50
#include "main.h"
#include "procMapsChecker/check.h"
#include <inttypes.h> // fmt of 'printf scanf'
#include <stdio.h> // fscanf, fprintf, fopen
#include <string.h> // strerror
static void usage(void)
{
fprintf(stdout, "Usage: mcpuc <path-to-maps> <path-to-memcount>\n");
}
int main(int argc, char **argv)
{
char *file_maps, *file_memcount;
if (argc != 3)
{
usage();
return -1;
}
else
{
file_maps = argv[1];
file_memcount = argv[2];
}
// init
PUC_init(file_maps);
FILE *FILE_memcount = fopen(file_memcount, "r");
if (!FILE_memcount)
{
fprintf(stderr, "mcpuc: cannot open the memory maps, %s\n",
strerror(errno));
return -1;
}
memcount_record mcr;
const char *scanfmt =
"%" SCNxPTR "%" SCNx32 "%" SCNu8 "%" SCNu8 "%" SCNxPTR;
while (fscanf(FILE_memcount, scanfmt, &mcr.pc, &mcr.inst, &mcr.rw,
&mcr.size, &mcr.addr) == NUM_MEMBER_MC_REC)
{
PUC_stat(mcr.addr);
}
PUC_print_stat();
PUC_exit();
return 0;
}