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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#define VERSION "24-Jan-94"
#define PROGNAME "ICount"
#define SHADE
#include <stdio.h>
#include <IHASH.h>
#include <ITYPES.h>
#include <instr.h>
#include <inames.h>
#include <shade.h>
#define TR_REGS
#include <trace.h>
#include <stdtr.h>
#include <trctl.h>
static long long info[NIHASH];
#define STATS_FILE "ICNT"
/* fwd decls */
void print_results();
#define CHECKPOINT 1000000 /* reporting frequency */
static long countdown = CHECKPOINT;
char *anal_usage = "";
char *anal_version = VERSION;
initialize(argc,argv,envp)
int argc;
char **argv, envp;
{
unsigned i, j;
/* Setup the trace */
shade_trctl_trsize(sizeof(Trace));
shade_trctl_it (IT_ANY, 1, 0, TC_IH);
/* init table */
for (j = 0; j < NIHASH; j++)
info[j] = 0LL;
}
int analyze(argc,argv,envp)
int argc;
char **argv, envp;
{
Trace *tr;
int i;
for (i = 0; tr = shade_step(); i++) {
info[tr->tr_ih] += 1LL;
if (countdown-- < 0) {
print_results("Intermediate:");
countdown = CHECKPOINT;
}
}
return(0);
}
void
terminate()
{
print_results("Final:");
}
void
print_results(header)
char *header;
{
int i, j;
static FILE *statf = NULL;
if ((statf = fopen("ICNT", "w")) == NULL) {
fprintf(stderr, "Cannot open statistics file ICNT\n");
exit(1);
}
fprintf(statf, "%s\n\n", header);
for (i = 0; i < NIHASH; i++) {
fprintf(statf, "%8x: %8ld\n", i, (long) info[i]);
}
fclose(statf);
}
|