As we discussed on the D65585, this patch introduces the llvm-locstats tool.
The line 0 shows the number (and the percentage) of DIEs with no location information, but the line 100 shows the number (and the percentage) of DIEs where there is location information in all code section bytes (where the variable or parameter is in the scope). The line 51..59 shows the number (and the percentage) of DIEs where the location information is in between 51 and 59 percentage of its scope covered. There are options for considering only local variables or formal parameters, and also there is an option for reporting the stats by ignoring the debug entry values generated.
Using the tool
llvm-locstats test.o
================================================= Debug Location Statistics ================================================= cov% samples percentage(~) ------------------------------------------------- 0 1 16% 1..9 0 0% 10..19 0 0% 20..29 0 0% 30..39 0 0% 40..49 0 0% 50..99 1 16% 60..69 0 0% 70..79 0 0% 80..89 1 16% 90..99 0 0% 100 3 50% ================================================= -the number of debug variables processed: 6 -PC ranges covered: 81% ------------------------------------------------- -total availability: 83% =================================================
Or,
llvm-locstats -ignore-debug-entry-values test.o
================================================= Debug Location Statistics ================================================= cov% samples percentage(~) ------------------------------------------------- 0 1 16% 1..9 0 0% 10..19 0 0% 20..29 0 0% 30..39 0 0% 40..49 0 0% 50..99 2 33% 60..69 0 0% 70..79 0 0% 80..89 1 16% 90..99 0 0% 100 2 33% ================================================= -the number of debug variables processed: 6 -PC ranges covered: 76% ------------------------------------------------- -total availability: 83% =================================================
This assumes that llvm-dwarfdump exists in the same directory as llvm-locstats, which may not be true, e.g. for build systems that build dwardump and locstats in separate build trees. Can this be configurable? Possibly a regular $PATH lookup makes sense here (with cwd as a preferred location), although allowing a flag pointing to the location of dwarfdump would be the most flexible.