2 This script sums up the counters for seeing how many virtual calls are
3 actually being verified. The flag for generating the count data is
4 "-fvtv-counts". This flag will generate two files in /tmp,
5 "vtv_count_data.log" and "vtv_class_set_sizes.log". The first file is
6 the one that contains the info I mentioned; the second one is one I
7 generated because I was curious about how big the average set size was
8 for the vtable verification work.
10 After compiling the attached program, run it on the vtv_count_data.log
13 $ sum-counters /tmp/vtv_count_data.log
15 One can optionally pass a "--verbose" flag. This file generates an
16 output file whose name is the same as the input file, with ".summary"
17 appended to it, e.g. /tmp/vtv_count_data.log.summary . Without the
18 verbose flag, it will just contain something like this:
20 Total # virtual calls: 349123
21 Total # verified calls: 348236
22 Percent verified: 99 %
24 Total calls to __VLTRegisterSet: 42236
25 Total calls to __VLTRegisterPair: 84371
26 Total # unused vtable map vars: 1536333
28 With the --verbose flag it will also output one line for each
29 compilation unit for which it verified less than 90% of the virtual
30 calls (and there were more than 20 virtual calls in the file),
33 Verified 1 out of 25 (4.00%) : foo.cc
34 Verified 27 out of 43 (62.00%) : bar.cc
42 usage (const char *error_text
)
44 fprintf (stderr
, "%s", error_text
);
45 fprintf (stderr
, "Usage: \n");
46 fprintf (stderr
, "sum-counters <input-file> [--verbose]\n");
50 main (int argc
, char **argv
)
72 usage ("Error: Need an input file.\n");
76 fp_in
= fopen (argv
[1], "r");
79 snprintf (buffer
, 1024, "Error: Unable to open input file '%s'.\n",
87 if (strcmp (argv
[2], "--verbose") == 0)
91 snprintf (buffer
, 1024, "Error: Unrecognized option '%s'.\n",
98 snprintf (fname_out
, 1024, "%s.summary", argv
[1]);
100 fp_out
= fopen (fname_out
, "w");
103 fprintf (stderr
, "Error: Unable to open output file '%s'\n",
108 while (fscanf (fp_in
, "%s %d %d %d %d %d\n", fname_in
, &total
,
109 &verified
, ®set
, ®pair
, &unused
) != EOF
)
112 sum_verified
+= verified
;
113 sum_regset
+= regset
;
114 sum_regpair
+= regpair
;
115 sum_unused
+= unused
;
120 tmp_pct
= (verified
* 100) / total
;
122 if (verbose
&& tmp_pct
< 90 && total
>= 20)
124 fprintf (fp_out
, "Verified %d out of %d (%.2f%%) : %s\n",
125 verified
, total
, tmp_pct
, fname_in
);
132 fprintf (fp_out
, "\n\n");
133 fprintf (fp_out
, "Total # virtual calls: %d\n", sum_vcalls
);
134 fprintf (fp_out
, "Total # verified calls: %d\n", sum_verified
);
136 fprintf (fp_out
, "Percent verified: %d %%\n",
137 sum_verified
* 100 / sum_vcalls
);
139 fprintf (fp_out
, "Percent verified: NA %%\n");
141 fprintf (fp_out
, "\nTotal calls to __VLTRegisterSet: %d\n",
143 fprintf (fp_out
, "Total calls to __VLTRegisterPair: %d\n",
145 fprintf (fp_out
, "Total # unused vtable map vars: %d\n", sum_unused
);