Index: llvm/docs/CommandGuide/llvm-dwarfdump.rst =================================================================== --- llvm/docs/CommandGuide/llvm-dwarfdump.rst +++ llvm/docs/CommandGuide/llvm-dwarfdump.rst @@ -112,7 +112,8 @@ .. option:: --statistics Collect debug info quality metrics and print the results - as machine-readable single-line JSON output. + as machine-readable single-line JSON output. The output + format is described in the section below (:ref:`stats-format`). .. option:: --summarize-types @@ -162,6 +163,30 @@ Read command-line options from ``. +.. _stats-format: + +FORMAT OF STATISTICS OUTPUT +--------------------------- + +The ::option:`--statistics` option generates single-line JSON output +representing quality metrics of the processed debug info. These metrics are +useful to compare changes between two compilers, particularly for judging +the effect that a change to the compiler has on the debug info quality. + +The output is formatted as key-value pairs. The first pair contains a version +number. The following naming scheme is used for the keys: + + - `variables` ==> local variables and parameters + - `local vars` ==> local variables + - `params` ==> formal parameters + +For aggregated values, the following keys are used: + + - `sum_of_all_variables(...)` ==> the sum applied to all variables + - `#bytes` ==> the number of bytes + - `#variables - entry values ...` ==> the number of variables excluding + the entry values etc. + EXIT STATUS ----------- Index: llvm/test/DebugInfo/X86/dwarf-callsite-related-attrs.ll =================================================================== --- llvm/test/DebugInfo/X86/dwarf-callsite-related-attrs.ll +++ llvm/test/DebugInfo/X86/dwarf-callsite-related-attrs.ll @@ -20,7 +20,7 @@ ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis -o /dev/null ; VERIFY: No errors. -; STATS: "call site DIEs":6 +; STATS: "#call site DIEs":6 @sink = global i32 0, align 4, !dbg !0 Index: llvm/test/tools/llvm-dwarfdump/X86/locstats.ll =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/locstats.ll +++ llvm/test/tools/llvm-dwarfdump/X86/locstats.ll @@ -1,89 +1,89 @@ ; RUN: llc -debug-entry-values %s -o - -filetype=obj \ ; RUN: | llvm-dwarfdump -statistics - | FileCheck %s -; -; CHECK: "entry value scope bytes covered":5 -; CHECK: "formal params scope bytes total":20 -; CHECK: "formal params scope bytes covered":20 -; CHECK: "formal params entry value scope bytes covered":5 -; CHECK: "vars scope bytes total":90 -; CHECK: "vars scope bytes covered":60 -; CHECK: "vars entry value scope bytes covered":0 -; CHECK: "total variables procesed by location statistics":6 -; CHECK: "variables with 0% of its scope covered":1 -; CHECK: "variables with (0%,10%) of its scope covered":0 -; CHECK: "variables with [10%,20%) of its scope covered":0 -; CHECK: "variables with [20%,30%) of its scope covered":0 -; CHECK: "variables with [30%,40%) of its scope covered":0 -; CHECK: "variables with [40%,50%) of its scope covered":0 -; CHECK: "variables with [50%,60%) of its scope covered":1 -; CHECK: "variables with [60%,70%) of its scope covered":0 -; CHECK: "variables with [70%,80%) of its scope covered":0 -; CHECK: "variables with [80%,90%) of its scope covered":1 -; CHECK: "variables with [90%,100%) of its scope covered":0 -; CHECK: "variables with 100% of its scope covered":3 -; CHECK: "variables (excluding the debug entry values) with 0% of its scope covered":1 -; CHECK: "variables (excluding the debug entry values) with (0%,10%) of its scope covered":0 -; CHECK: "variables (excluding the debug entry values) with [10%,20%) of its scope covered":0 -; CHECK: "variables (excluding the debug entry values) with [20%,30%) of its scope covered":0 -; CHECK: "variables (excluding the debug entry values) with [30%,40%) of its scope covered":0 -; CHECK: "variables (excluding the debug entry values) with [40%,50%) of its scope covered":0 -; CHECK: "variables (excluding the debug entry values) with [50%,60%) of its scope covered":2 -; CHECK: "variables (excluding the debug entry values) with [60%,70%) of its scope covered":0 -; CHECK: "variables (excluding the debug entry values) with [70%,80%) of its scope covered":0 -; CHECK: "variables (excluding the debug entry values) with [80%,90%) of its scope covered":1 -; CHECK: "variables (excluding the debug entry values) with [90%,100%) of its scope covered":0 -; CHECK: "variables (excluding the debug entry values) with 100% of its scope covered":2 -; CHECK: "total params procesed by location statistics":2 -; CHECK: "params with 0% of its scope covered":0 -; CHECK: "params with (0%,10%) of its scope covered":0 -; CHECK: "params with [10%,20%) of its scope covered":0 -; CHECK: "params with [20%,30%) of its scope covered":0 -; CHECK: "params with [30%,40%) of its scope covered":0 -; CHECK: "params with [40%,50%) of its scope covered":0 -; CHECK: "params with [50%,60%) of its scope covered":0 -; CHECK: "params with [60%,70%) of its scope covered":0 -; CHECK: "params with [70%,80%) of its scope covered":0 -; CHECK: "params with [80%,90%) of its scope covered":0 -; CHECK: "params with [90%,100%) of its scope covered":0 -; CHECK: "params with 100% of its scope covered":2 -; CHECK: "params (excluding the debug entry values) with 0% of its scope covered":0 -; CHECK: "params (excluding the debug entry values) with (0%,10%) of its scope covered":0 -; CHECK: "params (excluding the debug entry values) with [10%,20%) of its scope covered":0 -; CHECK: "params (excluding the debug entry values) with [20%,30%) of its scope covered":0 -; CHECK: "params (excluding the debug entry values) with [30%,40%) of its scope covered":0 -; CHECK: "params (excluding the debug entry values) with [40%,50%) of its scope covered":0 -; CHECK: "params (excluding the debug entry values) with [50%,60%) of its scope covered":1 -; CHECK: "params (excluding the debug entry values) with [60%,70%) of its scope covered":0 -; CHECK: "params (excluding the debug entry values) with [70%,80%) of its scope covered":0 -; CHECK: "params (excluding the debug entry values) with [80%,90%) of its scope covered":0 -; CHECK: "params (excluding the debug entry values) with [90%,100%) of its scope covered":0 -; CHECK: "params (excluding the debug entry values) with 100% of its scope covered":1 -; CHECK: "total vars procesed by location statistics":4 -; CHECK: "vars with 0% of its scope covered":1 -; CHECK: "vars with (0%,10%) of its scope covered":0 -; CHECK: "vars with [10%,20%) of its scope covered":0 -; CHECK: "vars with [20%,30%) of its scope covered":0 -; CHECK: "vars with [30%,40%) of its scope covered":0 -; CHECK: "vars with [40%,50%) of its scope covered":0 -; CHECK: "vars with [50%,60%) of its scope covered":1 -; CHECK: "vars with [60%,70%) of its scope covered":0 -; CHECK: "vars with [70%,80%) of its scope covered":0 -; CHECK: "vars with [80%,90%) of its scope covered":1 -; CHECK: "vars with [90%,100%) of its scope covered":0 -; CHECK: "vars with 100% of its scope covered":1 -; CHECK: "vars (excluding the debug entry values) with 0% of its scope covered":1 -; CHECK: "vars (excluding the debug entry values) with (0%,10%) of its scope covered":0 -; CHECK: "vars (excluding the debug entry values) with [10%,20%) of its scope covered":0 -; CHECK: "vars (excluding the debug entry values) with [20%,30%) of its scope covered":0 -; CHECK: "vars (excluding the debug entry values) with [30%,40%) of its scope covered":0 -; CHECK: "vars (excluding the debug entry values) with [40%,50%) of its scope covered":0 -; CHECK: "vars (excluding the debug entry values) with [50%,60%) of its scope covered":1 -; CHECK: "vars (excluding the debug entry values) with [60%,70%) of its scope covered":0 -; CHECK: "vars (excluding the debug entry values) with [70%,80%) of its scope covered":0 -; CHECK: "vars (excluding the debug entry values) with [80%,90%) of its scope covered":1 -; CHECK: "vars (excluding the debug entry values) with [90%,100%) of its scope covered":0 -; CHECK: "vars (excluding the debug entry values) with 100% of its scope covered":1 -; + +; CHECK: "sum_all_variables(#bytes in parent scope covered by DW_OP_entry_value)":5 +; CHECK: "sum_all_params(#bytes in parent scope)":20 +; CHECK: "sum_all_params(#bytes in parent scope covered by DW_AT_location)":20 +; CHECK: "sum_all_params(#bytes in parent scope covered by DW_OP_entry_value)":5 +; CHECK: "sum_all_local_vars(#bytes in parent scope)":90 +; CHECK: "sum_all_local_vars(#bytes in parent scope covered by DW_AT_location)":60 +; CHECK: "sum_all_local_vars(#bytes in parent scope covered by DW_OP_entry_value)":0 +; CHECK: "#variables processed by location statistics":6 +; CHECK: "#variables with 0% of parent scope covered by DW_AT_location":1 +; CHECK: "#variables with (0%,10%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables with [10%,20%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables with [20%,30%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables with [30%,40%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables with [40%,50%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables with [50%,60%) of parent scope covered by DW_AT_location":1 +; CHECK: "#variables with [60%,70%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables with [70%,80%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables with [80%,90%) of parent scope covered by DW_AT_location":1 +; CHECK: "#variables with [90%,100%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables with 100% of parent scope covered by DW_AT_location":3 +; CHECK: "#variables - entry values with 0% of parent scope covered by DW_AT_location":1 +; CHECK: "#variables - entry values with (0%,10%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables - entry values with [10%,20%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables - entry values with [20%,30%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables - entry values with [30%,40%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables - entry values with [40%,50%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables - entry values with [50%,60%) of parent scope covered by DW_AT_location":2 +; CHECK: "#variables - entry values with [60%,70%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables - entry values with [70%,80%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables - entry values with [80%,90%) of parent scope covered by DW_AT_location":1 +; CHECK: "#variables - entry values with [90%,100%) of parent scope covered by DW_AT_location":0 +; CHECK: "#variables - entry values with 100% of parent scope covered by DW_AT_location":2 +; CHECK: "#params processed by location statistics":2 +; CHECK: "#params with 0% of parent scope covered by DW_AT_location":0 +; CHECK: "#params with (0%,10%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params with [10%,20%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params with [20%,30%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params with [30%,40%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params with [40%,50%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params with [50%,60%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params with [60%,70%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params with [70%,80%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params with [80%,90%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params with [90%,100%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params with 100% of parent scope covered by DW_AT_location":2 +; CHECK: "#params - entry values with 0% of parent scope covered by DW_AT_location":0 +; CHECK: "#params - entry values with (0%,10%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params - entry values with [10%,20%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params - entry values with [20%,30%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params - entry values with [30%,40%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params - entry values with [40%,50%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params - entry values with [50%,60%) of parent scope covered by DW_AT_location":1 +; CHECK: "#params - entry values with [60%,70%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params - entry values with [70%,80%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params - entry values with [80%,90%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params - entry values with [90%,100%) of parent scope covered by DW_AT_location":0 +; CHECK: "#params - entry values with 100% of parent scope covered by DW_AT_location":1 +; CHECK: "#local vars processed by location statistics":4 +; CHECK: "#local vars with 0% of parent scope covered by DW_AT_location":1 +; CHECK: "#local vars with (0%,10%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars with [10%,20%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars with [20%,30%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars with [30%,40%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars with [40%,50%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars with [50%,60%) of parent scope covered by DW_AT_location":1 +; CHECK: "#local vars with [60%,70%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars with [70%,80%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars with [80%,90%) of parent scope covered by DW_AT_location":1 +; CHECK: "#local vars with [90%,100%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars with 100% of parent scope covered by DW_AT_location":1 +; CHECK: "#local vars - entry values with 0% of parent scope covered by DW_AT_location":1 +; CHECK: "#local vars - entry values with (0%,10%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars - entry values with [10%,20%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars - entry values with [20%,30%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars - entry values with [30%,40%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars - entry values with [40%,50%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars - entry values with [50%,60%) of parent scope covered by DW_AT_location":1 +; CHECK: "#local vars - entry values with [60%,70%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars - entry values with [70%,80%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars - entry values with [80%,90%) of parent scope covered by DW_AT_location":1 +; CHECK: "#local vars - entry values with [90%,100%) of parent scope covered by DW_AT_location":0 +; CHECK: "#local vars - entry values with 100% of parent scope covered by DW_AT_location":1 + ; The source code of the test case: ; extern void fn3(int *); ; extern void fn2 (int); @@ -102,7 +102,7 @@ ; fn2 (a); ; u --; ; } -; + ; __attribute__((noinline)) ; int f() ; { @@ -112,7 +112,7 @@ ; fn1 (l, k); ; return 0; ; } -; + ; ModuleID = 'test.c' source_filename = "test.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: llvm/test/tools/llvm-dwarfdump/X86/statistics-base-address.s =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/statistics-base-address.s +++ llvm/test/tools/llvm-dwarfdump/X86/statistics-base-address.s @@ -5,8 +5,8 @@ # RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj -o %t # RUN: llvm-dwarfdump --statistics %t | FileCheck %s -# CHECK: "vars scope bytes total":12 -# CHECK: "vars scope bytes covered":8 +# CHECK: "sum_all_local_vars(#bytes in parent scope)":12 +# CHECK: "sum_all_local_vars(#bytes in parent scope covered by DW_AT_location)":8 .text Index: llvm/test/tools/llvm-dwarfdump/X86/statistics-dwo.test =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/statistics-dwo.test +++ llvm/test/tools/llvm-dwarfdump/X86/statistics-dwo.test @@ -69,28 +69,28 @@ # } # -CHECK: "version":4 -CHECK: "source functions":3 -CHECK: "source functions with location":3 -CHECK: "inlined functions":7 -CHECK: "inlined funcs with abstract origins":7 -CHECK: "unique source variables":9 -CHECK: "source variables":30 +CHECK: "version":5 +CHECK: "#functions":3 +CHECK: "#functions with location":3 +CHECK: "#inlined functions":7 +CHECK: "#inlined functions with abstract origins":7 +CHECK: "#unique source variables":9 +CHECK: "#source variables":30 # Ideally the value below would be 33 but currently it's not. -CHECK: "variables with location":22 -CHECK: "call site entries":7 -CHECK: "scope bytes total":2817 -CHECK: "scope bytes covered":1160 -CHECK: "total function size":594 -CHECK: "total inlined function size":345 -CHECK: "total formal params":12 -CHECK: "formal params with source location":12 -CHECK: "formal params with type":12 -CHECK: "formal params with binary location":12 -CHECK: "total vars":18 -CHECK: "vars with source location":18 -CHECK: "vars with type":18 +CHECK: "#source variables with location":22 +CHECK: "#call site entries":7 +CHECK: "sum_all_variables(#bytes in parent scope)":2817 +CHECK: "sum_all_variables(#bytes in parent scope covered by DW_AT_location)":1160 +CHECK: "#bytes witin functions":594 +CHECK: "#bytes witin inlined functions":345 +CHECK: "#params":12 +CHECK: "#params with source location":12 +CHECK: "#params with type":12 +CHECK: "#params with binary location":12 +CHECK: "#local vars":18 +CHECK: "#local vars with source location":18 +CHECK: "#local vars with type":18 # Ideally the value below would be 18, but currently it's not. -CHECK: "vars with binary location":10 +CHECK: "#local vars with binary location":10 Index: llvm/test/tools/llvm-dwarfdump/X86/statistics-v3.test =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/statistics-v3.test +++ llvm/test/tools/llvm-dwarfdump/X86/statistics-v3.test @@ -64,28 +64,28 @@ # } # -CHECK: "version":4 -CHECK: "source functions":3 -CHECK: "source functions with location":3 -CHECK: "inlined functions":8 -CHECK: "inlined funcs with abstract origins":8 -CHECK: "unique source variables":9 -CHECK: "source variables":33 +CHECK: "version":5 +CHECK: "#functions":3 +CHECK: "#functions with location":3 +CHECK: "#inlined functions":8 +CHECK: "#inlined functions with abstract origins":8 +CHECK: "#unique source variables":9 +CHECK: "#source variables":33 # Ideally the value below would be 33 but currently it's not. -CHECK: "variables with location":24 -CHECK: "call site entries":8 -CHECK: "scope bytes total":3072 -CHECK: "scope bytes covered":1188 -CHECK: "total function size":636 -CHECK: "total inlined function size":388 -CHECK: "total formal params":13 -CHECK: "formal params with source location":13 -CHECK: "formal params with type":13 -CHECK: "formal params with binary location":13 -CHECK: "total vars":20 -CHECK: "vars with source location":20 -CHECK: "vars with type":20 +CHECK: "#source variables with location":24 +CHECK: "#call site entries":8 +CHECK: "sum_all_variables(#bytes in parent scope)":3072 +CHECK: "sum_all_variables(#bytes in parent scope covered by DW_AT_location)":1188 +CHECK: "#bytes witin functions":636 +CHECK: "#bytes witin inlined functions":388 +CHECK: "#params":13 +CHECK: "#params with source location":13 +CHECK: "#params with type":13 +CHECK: "#params with binary location":13 +CHECK: "#local vars":20 +CHECK: "#local vars with source location":20 +CHECK: "#local vars with type":20 # Ideally the value below would be 20, but currently it's not. -CHECK: "vars with binary location":11 +CHECK: "#local vars with binary location":11 Index: llvm/test/tools/llvm-dwarfdump/X86/statistics.ll =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/statistics.ll +++ llvm/test/tools/llvm-dwarfdump/X86/statistics.ll @@ -1,6 +1,6 @@ ; RUN: llc -O0 %s -o - -filetype=obj \ ; RUN: | llvm-dwarfdump -statistics - | FileCheck %s -; CHECK: "version":4 +; CHECK: "version":5 ; namespace test { ; extern int a; @@ -35,24 +35,24 @@ ; - non-constant member S:fn, ; - arguments of S:fn. -; CHECK: "unique source variables":9 +; CHECK: "#unique source variables":9 ; +1 extra inline i. -; CHECK: "source variables":10 +; CHECK: "#source variables":10 ; -1 square::i -; CHECK: "variables with location":9 -; CHECK: "scope bytes total":[[BYTES:[0-9]+]] +; CHECK: "#source variables with location":9 +; CHECK: "sum_all_local_vars(#bytes in parent scope)":[[BYTES:[0-9]+]] ; Because of the dbg.value in the middle of the function, the pc range coverage ; must be below 100%. -; CHECK-NOT: "scope bytes covered":0 -; CHECK-NOT: "scope bytes covered":[[BYTES]] -; CHECK: "scope bytes covered": -; CHECK: "total function size":[[FUNCSIZE:[0-9]+]] -; CHECK: "total inlined function size":[[INLINESIZE:[0-9]+]] -; CHECK: "size of __debug_info":380 -; CHECK: "size of __debug_loc":35 -; CHECK: "size of __debug_abbrev":303 -; CHECK: "size of __debug_line":117 -; CHECK: "size of __debug_str":204 +; CHECK-NOT: "sum_all_local_vars(#bytes in parent scope covered by DW_AT_location)":0 +; CHECK-NOT "sum_all_local_vars(#bytes in parent scope covered by DW_AT_location)":[[BYTES]] +; CHECK: "sum_all_local_vars(#bytes in parent scope covered by DW_AT_location)": +; CHECK: "#bytes witin functions":[[FUNCSIZE:[0-9]+]] +; CHECK: "#bytes witin inlined functions":[[INLINESIZE:[0-9]+]] +; CHECK: "#bytes in __debug_info":380 +; CHECK: "#bytes in __debug_loc":35 +; CHECK: "#bytes in __debug_abbrev":303 +; CHECK: "#bytes in __debug_line":117 +; CHECK: "#bytes in __debug_str":204 ; ModuleID = '/tmp/quality.cpp' source_filename = "/tmp/quality.cpp" Index: llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll +++ llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll @@ -12,8 +12,8 @@ ; foo(&local1, arg2, 10, 15, arg3 + 3, arg1 + arg2); ; } ; -; CHECK: "call site DIEs":2 -; CHECK-SAME: "call site parameter DIEs":6 +; CHECK: "#call site DIEs":2 +; CHECK-SAME: "#call site parameter DIEs":6 ; ; ModuleID = 'test.c' source_filename = "test.c" Index: llvm/test/tools/llvm-dwarfdump/X86/stats-inlining-multi-cu.ll =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/stats-inlining-multi-cu.ll +++ llvm/test/tools/llvm-dwarfdump/X86/stats-inlining-multi-cu.ll @@ -3,11 +3,11 @@ ; Test that abstract origins in multiple CUs are uniqued. -; CHECK: "source functions":4, -; CHECK-SAME: "inlined functions":2, -; CHECK-SAME: "unique source variables":4 -; CHECK-SAME: "source variables":6 -; CHECK-SAME: "variables with location":6 +; CHECK: "#functions":4, +; CHECK-SAME: "#inlined functions":2, +; CHECK-SAME: "#unique source variables":4 +; CHECK-SAME: "#source variables":6 +; CHECK-SAME: "#source variables with location":6 ;header.h: ;extern "C" int getchar(); Index: llvm/test/tools/llvm-dwarfdump/X86/stats-inlining-single-cu.ll =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/stats-inlining-single-cu.ll +++ llvm/test/tools/llvm-dwarfdump/X86/stats-inlining-single-cu.ll @@ -4,11 +4,11 @@ ; This test serves as a baseline / sanity-check for stats-inlining-multi-cu.ll ; The results for both tests should be identical. -; CHECK: "source functions":4, -; CHECK-SAME: "inlined functions":2, -; CHECK-SAME: "unique source variables":4 -; CHECK-SAME: "source variables":6 -; CHECK-SAME: "variables with location":6 +; CHECK: "#functions":4, +; CHECK-SAME: "#inlined functions":2, +; CHECK-SAME: "#unique source variables":4 +; CHECK-SAME: "#source variables":6 +; CHECK-SAME: "#source variables with location":6 ;header.h: ;extern "C" int getchar(); Index: llvm/test/tools/llvm-dwarfdump/X86/stats-mulitple-cu-out-of-line.ll =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/stats-mulitple-cu-out-of-line.ll +++ llvm/test/tools/llvm-dwarfdump/X86/stats-mulitple-cu-out-of-line.ll @@ -18,12 +18,12 @@ ; #include "test.h" ; int far() { return foo(42); } -; CHECK: "source functions":3 -; CHECK-SAME: "source functions with location":3 -; CHECK-SAME: "inlined functions":0 -; CHECK-SAME: "unique source variables":1 -; CHECK-SAME: "source variables":2 -; CHECK-SAME: "variables with location":2 +; CHECK: "#functions":3 +; CHECK-SAME: "#functions with location":3 +; CHECK-SAME: "#inlined functions":0 +; CHECK-SAME: "#unique source variables":1 +; CHECK-SAME: "#source variables":2 +; CHECK-SAME: "#source variables with location":2 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: llvm/test/tools/llvm-dwarfdump/X86/stats-multiple-cu-members.ll =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/stats-multiple-cu-members.ll +++ llvm/test/tools/llvm-dwarfdump/X86/stats-multiple-cu-members.ll @@ -16,8 +16,8 @@ ; #include "test.h" ; s S2; -; CHECK: "source variables":4 -; CHECK-SAME: "variables with location":4 +; CHECK: "#source variables":4 +; CHECK-SAME: "#source variables with location":4 source_filename = "llvm-link" target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" Index: llvm/test/tools/llvm-dwarfdump/X86/stats-multiple-cu-same-name.ll =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/stats-multiple-cu-same-name.ll +++ llvm/test/tools/llvm-dwarfdump/X86/stats-multiple-cu-same-name.ll @@ -3,9 +3,9 @@ ; Test that statistics distinguish functions with the same name. -; CHECK: "source functions":4, -; CHECK-SAME: "unique source variables":2 -; CHECK-SAME: "source variables":2 +; CHECK: "#functions":4, +; CHECK-SAME: "#unique source variables":2 +; CHECK-SAME: "#source variables":2 ; $ cat test1.cpp ; static int foo(int a) { Index: llvm/tools/llvm-dwarfdump/Statistics.cpp =================================================================== --- llvm/tools/llvm-dwarfdump/Statistics.cpp +++ llvm/tools/llvm-dwarfdump/Statistics.cpp @@ -58,14 +58,14 @@ unsigned NumParamTypes = 0; /// Number of function parameters with a DW_AT_location. unsigned NumParamLocations = 0; - /// Number of variables. - unsigned NumVars = 0; - /// Number of variables with source location. - unsigned NumVarSourceLocations = 0; - /// Number of variables with type. - unsigned NumVarTypes = 0; - /// Number of variables with DW_AT_location. - unsigned NumVarLocations = 0; + /// Number of local variables. + unsigned NumLocalVars = 0; + /// Number of local variables with source location. + unsigned NumLocalVarSourceLocations = 0; + /// Number of local variables with type. + unsigned NumLocalVarTypes = 0; + /// Number of local variables with DW_AT_location. + unsigned NumLocalVarLocations = 0; }; /// Holds accumulated global statistics about DIEs. @@ -80,21 +80,19 @@ /// Total number of PC range bytes covered by DW_AT_locations of /// formal parameters. unsigned ParamScopeBytesCovered = 0; - /// Total number of PC range bytes in each variable's enclosing scope - /// (only for parameters). + /// Total number of PC range bytes in each parameter's enclosing scope. unsigned ParamScopeBytes = 0; /// Total number of PC range bytes covered by DW_AT_locations with /// the debug entry values (DW_OP_entry_value) (only for parameters). unsigned ParamScopeEntryValueBytesCovered = 0; /// Total number of PC range bytes covered by DW_AT_locations (only for local /// variables). - unsigned VarScopeBytesCovered = 0; - /// Total number of PC range bytes in each variable's enclosing scope - /// (only for local variables). - unsigned VarScopeBytes = 0; + unsigned LocalVarScopeBytesCovered = 0; + /// Total number of PC range bytes in each local variable's enclosing scope. + unsigned LocalVarScopeBytes = 0; /// Total number of PC range bytes covered by DW_AT_locations with /// the debug entry values (DW_OP_entry_value) (only for local variables). - unsigned VarScopeEntryValueBytesCovered = 0; + unsigned LocalVarScopeEntryValueBytesCovered = 0; /// Total number of call site entries (DW_AT_call_file & DW_AT_call_line). unsigned CallSiteEntries = 0; /// Total number of call site DIEs (DW_TAG_call_site). @@ -130,10 +128,10 @@ std::vector ParamNonEntryValLocStats{ std::vector(NumOfCoverageCategories, 0)}; /// The debug location statistics for local variables. - std::vector VarLocStats{ + std::vector LocalVarLocStats{ std::vector(NumOfCoverageCategories, 0)}; /// Map non debug entry values coverage for local variables. - std::vector VarNonEntryValLocStats{ + std::vector LocalVarNonEntryValLocStats{ std::vector(NumOfCoverageCategories, 0)}; /// Total number of local variables and function parameters processed. unsigned NumVarParam = 0; @@ -148,8 +146,8 @@ static void collectLocStats(uint64_t BytesCovered, uint64_t BytesInScope, std::vector &VarParamLocStats, std::vector &ParamLocStats, - std::vector &VarLocStats, bool IsParam, - bool IsLocalVar) { + std::vector &LocalVarLocStats, + bool IsParam, bool IsLocalVar) { auto getCoverageBucket = [BytesCovered, BytesInScope]() -> unsigned { // No debug location at all for the variable. if (BytesCovered == 0) @@ -168,7 +166,7 @@ if (IsParam) ParamLocStats[CoverageBucket]++; else if (IsLocalVar) - VarLocStats[CoverageBucket]++; + LocalVarLocStats[CoverageBucket]++; } /// Construct an identifier for a given DIE from its Prefix, Name, DeclFileName /// and DeclLine. The identifier aims to be unique for any unique entities, @@ -214,7 +212,7 @@ uint64_t BytesEntryValuesCovered = 0; auto &FnStats = FnStatMap[FnPrefix]; bool IsParam = Die.getTag() == dwarf::DW_TAG_formal_parameter; - bool IsVariable = Die.getTag() == dwarf::DW_TAG_variable; + bool IsLocalVar = Die.getTag() == dwarf::DW_TAG_variable; bool IsConstantMember = Die.getTag() == dwarf::DW_TAG_member && Die.find(dwarf::DW_AT_const_value); @@ -230,13 +228,13 @@ return; } - if (!IsParam && !IsVariable && !IsConstantMember) { + if (!IsParam && !IsLocalVar && !IsConstantMember) { // Not a variable or constant member. return; } // Ignore declarations of global variables. - if (IsVariable && Die.find(dwarf::DW_AT_declaration)) + if (IsLocalVar && Die.find(dwarf::DW_AT_declaration)) return; if (Die.findRecursively(dwarf::DW_AT_decl_file) && @@ -293,17 +291,17 @@ LocStats.NumVarParam++; if (IsParam) LocStats.NumParam++; - else if (IsVariable) + else if (IsLocalVar) LocStats.NumVar++; collectLocStats(BytesCovered, BytesInScope, LocStats.VarParamLocStats, - LocStats.ParamLocStats, LocStats.VarLocStats, IsParam, - IsVariable); + LocStats.ParamLocStats, LocStats.LocalVarLocStats, IsParam, + IsLocalVar); // Non debug entry values coverage statistics. collectLocStats(BytesCovered - BytesEntryValuesCovered, BytesInScope, LocStats.VarParamNonEntryValLocStats, LocStats.ParamNonEntryValLocStats, - LocStats.VarNonEntryValLocStats, IsParam, IsVariable); + LocStats.LocalVarNonEntryValLocStats, IsParam, IsLocalVar); } // Collect PC range coverage data. @@ -324,10 +322,12 @@ std::min(BytesInScope, BytesCovered); GlobalStats.ParamScopeBytes += BytesInScope; GlobalStats.ParamScopeEntryValueBytesCovered += BytesEntryValuesCovered; - } else if (IsVariable) { - GlobalStats.VarScopeBytesCovered += std::min(BytesInScope, BytesCovered); - GlobalStats.VarScopeBytes += BytesInScope; - GlobalStats.VarScopeEntryValueBytesCovered += BytesEntryValuesCovered; + } else if (IsLocalVar) { + GlobalStats.LocalVarScopeBytesCovered += + std::min(BytesInScope, BytesCovered); + GlobalStats.LocalVarScopeBytes += BytesInScope; + GlobalStats.LocalVarScopeEntryValueBytesCovered += + BytesEntryValuesCovered; } assert(GlobalStats.ScopeBytesCovered <= GlobalStats.ScopeBytes); } @@ -352,14 +352,14 @@ FnStats.NumParamSourceLocations++; if (HasLoc) FnStats.NumParamLocations++; - } else if (IsVariable) { - FnStats.NumVars++; + } else if (IsLocalVar) { + FnStats.NumLocalVars++; if (HasType) - FnStats.NumVarTypes++; + FnStats.NumLocalVarTypes++; if (HasSrcLoc) - FnStats.NumVarSourceLocations++; + FnStats.NumLocalVarSourceLocations++; if (HasLoc) - FnStats.NumVarLocations++; + FnStats.NumLocalVarLocations++; } } @@ -473,33 +473,41 @@ LLVM_DEBUG(llvm::dbgs() << Key << ": " << Value << '\n'); } -static void printLocationStats(raw_ostream &OS, - const char *Key, +static void printLocationStats(raw_ostream &OS, const char *Key, std::vector &LocationStats) { - OS << ",\"" << Key << " with 0% of its scope covered\":" + OS << ",\"" << Key << " with 0% of parent scope covered by DW_AT_location\":" << LocationStats[0]; - LLVM_DEBUG(llvm::dbgs() << Key << " with 0% of its scope covered: " - << LocationStats[0] << '\n'); - OS << ",\"" << Key << " with (0%,10%) of its scope covered\":" + LLVM_DEBUG( + llvm::dbgs() << Key + << " with 0% of parent scope covered by DW_AT_location: \\" + << LocationStats[0] << '\n'); + OS << ",\"" << Key + << " with (0%,10%) of parent scope covered by DW_AT_location\":" << LocationStats[1]; - LLVM_DEBUG(llvm::dbgs() << Key << " with (0%,10%) of its scope covered: " - << LocationStats[1] << '\n'); + LLVM_DEBUG(llvm::dbgs() + << Key + << " with (0%,10%) of parent scope covered by DW_AT_location: " + << LocationStats[1] << '\n'); for (unsigned i = 2; i < NumOfCoverageCategories - 1; ++i) { OS << ",\"" << Key << " with [" << (i - 1) * 10 << "%," << i * 10 - << "%) of its scope covered\":" << LocationStats[i]; + << "%) of parent scope covered by DW_AT_location\":" << LocationStats[i]; LLVM_DEBUG(llvm::dbgs() << Key << " with [" << (i - 1) * 10 << "%," << i * 10 - << "%) of its scope covered: " << LocationStats[i]); + << "%) of parent scope covered by DW_AT_location: " + << LocationStats[i]); } - OS << ",\"" << Key << " with 100% of its scope covered\":" + OS << ",\"" << Key + << " with 100% of parent scope covered by DW_AT_location\":" << LocationStats[NumOfCoverageCategories - 1]; - LLVM_DEBUG(llvm::dbgs() << Key << " with 100% of its scope covered: " - << LocationStats[NumOfCoverageCategories - 1]); + LLVM_DEBUG( + llvm::dbgs() << Key + << " with 100% of parent scope covered by DW_AT_location: " + << LocationStats[NumOfCoverageCategories - 1]); } static void printSectionSizes(raw_ostream &OS, const SectionSizes &Sizes) { for (const auto &DebugSec : Sizes.DebugSectionSizes) - OS << ",\"size of " << DebugSec.getKey() << "\":" << DebugSec.getValue(); + OS << ",\"#bytes in " << DebugSec.getKey() << "\":" << DebugSec.getValue(); } /// \} @@ -531,7 +539,7 @@ /// The version number should be increased every time the algorithm is changed /// (including bug fixes). New metrics may be added without increasing the /// version. - unsigned Version = 4; + unsigned Version = 5; unsigned VarParamTotal = 0; unsigned VarParamUnique = 0; unsigned VarParamWithLoc = 0; @@ -543,17 +551,18 @@ unsigned ParamWithType = 0; unsigned ParamWithLoc = 0; unsigned ParamWithSrcLoc = 0; - unsigned VarTotal = 0; - unsigned VarWithType = 0; - unsigned VarWithSrcLoc = 0; - unsigned VarWithLoc = 0; + unsigned LocalVarTotal = 0; + unsigned LocalVarWithType = 0; + unsigned LocalVarWithSrcLoc = 0; + unsigned LocalVarWithLoc = 0; for (auto &Entry : Statistics) { PerFunctionStats &Stats = Entry.getValue(); unsigned TotalVars = Stats.VarsInFunction.size() * (Stats.NumFnInlined + Stats.NumFnOutOfLine); // Count variables in global scope. if (!Stats.IsFunction) - TotalVars = Stats.NumVars + Stats.ConstantMembers + Stats.NumArtificial; + TotalVars = + Stats.NumLocalVars + Stats.ConstantMembers + Stats.NumArtificial; unsigned Constants = Stats.ConstantMembers; VarParamWithLoc += Stats.TotalVarWithLoc + Constants; VarParamTotal += TotalVars; @@ -569,10 +578,10 @@ ParamWithType += Stats.NumParamTypes; ParamWithLoc += Stats.NumParamLocations; ParamWithSrcLoc += Stats.NumParamSourceLocations; - VarTotal += Stats.NumVars; - VarWithType += Stats.NumVarTypes; - VarWithLoc += Stats.NumVarLocations; - VarWithSrcLoc += Stats.NumVarSourceLocations; + LocalVarTotal += Stats.NumLocalVars; + LocalVarWithType += Stats.NumLocalVarTypes; + LocalVarWithLoc += Stats.NumLocalVarLocations; + LocalVarWithSrcLoc += Stats.NumLocalVarSourceLocations; } // Print summary. @@ -580,57 +589,97 @@ OS << "{\"version\":" << Version; LLVM_DEBUG(llvm::dbgs() << "Variable location quality metrics\n"; llvm::dbgs() << "---------------------------------\n"); + printDatum(OS, "file", Filename.str()); printDatum(OS, "format", FormatName); - printDatum(OS, "source functions", NumFunctions); - printDatum(OS, "source functions with location", NumFuncsWithSrcLoc); - printDatum(OS, "inlined functions", NumInlinedFunctions); - printDatum(OS, "inlined funcs with abstract origins", NumAbstractOrigins); - printDatum(OS, "unique source variables", VarParamUnique); - printDatum(OS, "source variables", VarParamTotal); - printDatum(OS, "variables with location", VarParamWithLoc); - printDatum(OS, "call site entries", GlobalStats.CallSiteEntries); - printDatum(OS, "call site DIEs", GlobalStats.CallSiteDIEs); - printDatum(OS, "call site parameter DIEs", GlobalStats.CallSiteParamDIEs); - printDatum(OS, "scope bytes total", GlobalStats.ScopeBytes); - printDatum(OS, "scope bytes covered", GlobalStats.ScopeBytesCovered); - printDatum(OS, "entry value scope bytes covered", + + printDatum(OS, "#functions", NumFunctions); + printDatum(OS, "#functions with location", NumFuncsWithSrcLoc); + printDatum(OS, "#inlined functions", NumInlinedFunctions); + printDatum(OS, "#inlined functions with abstract origins", + NumAbstractOrigins); + + // This includes local variables and formal parameters. + printDatum(OS, "#unique source variables", VarParamUnique); + printDatum(OS, "#source variables", VarParamTotal); + printDatum(OS, "#source variables with location", VarParamWithLoc); + + printDatum(OS, "#call site entries", GlobalStats.CallSiteEntries); + printDatum(OS, "#call site DIEs", GlobalStats.CallSiteDIEs); + printDatum(OS, "#call site parameter DIEs", GlobalStats.CallSiteParamDIEs); + + printDatum(OS, "sum_all_variables(#bytes in parent scope)", + GlobalStats.ScopeBytes); + printDatum(OS, + "sum_all_variables(#bytes in parent scope covered by " + "DW_AT_location)", + GlobalStats.ScopeBytesCovered); + printDatum(OS, + "sum_all_variables(#bytes in parent scope covered by " + "DW_OP_entry_value)", GlobalStats.ScopeEntryValueBytesCovered); - printDatum(OS, "formal params scope bytes total", + + printDatum(OS, "sum_all_params(#bytes in parent scope)", GlobalStats.ParamScopeBytes); - printDatum(OS, "formal params scope bytes covered", - GlobalStats.ParamScopeBytesCovered); - printDatum(OS, "formal params entry value scope bytes covered", + printDatum( + OS, + "sum_all_params(#bytes in parent scope covered by DW_AT_location)", + GlobalStats.ParamScopeBytesCovered); + printDatum(OS, + "sum_all_params(#bytes in parent scope covered by " + "DW_OP_entry_value)", GlobalStats.ParamScopeEntryValueBytesCovered); - printDatum(OS, "vars scope bytes total", GlobalStats.VarScopeBytes); - printDatum(OS, "vars scope bytes covered", GlobalStats.VarScopeBytesCovered); - printDatum(OS, "vars entry value scope bytes covered", - GlobalStats.VarScopeEntryValueBytesCovered); - printDatum(OS, "total function size", GlobalStats.FunctionSize); - printDatum(OS, "total inlined function size", GlobalStats.InlineFunctionSize); - printDatum(OS, "total formal params", ParamTotal); - printDatum(OS, "formal params with source location", ParamWithSrcLoc); - printDatum(OS, "formal params with type", ParamWithType); - printDatum(OS, "formal params with binary location", ParamWithLoc); - printDatum(OS, "total vars", VarTotal); - printDatum(OS, "vars with source location", VarWithSrcLoc); - printDatum(OS, "vars with type", VarWithType); - printDatum(OS, "vars with binary location", VarWithLoc); - printDatum(OS, "total variables procesed by location statistics", - LocStats.NumVarParam); + + printDatum(OS, "sum_all_local_vars(#bytes in parent scope)", + GlobalStats.LocalVarScopeBytes); + printDatum(OS, + "sum_all_local_vars(#bytes in parent scope covered by " + "DW_AT_location)", + GlobalStats.LocalVarScopeBytesCovered); + printDatum(OS, + "sum_all_local_vars(#bytes in parent scope covered by " + "DW_OP_entry_value)", + GlobalStats.LocalVarScopeEntryValueBytesCovered); + + printDatum(OS, "#bytes witin functions", GlobalStats.FunctionSize); + printDatum(OS, "#bytes witin inlined functions", + GlobalStats.InlineFunctionSize); + + // Print the summary for formal parameters. + printDatum(OS, "#params", ParamTotal); + printDatum(OS, "#params with source location", ParamWithSrcLoc); + printDatum(OS, "#params with type", ParamWithType); + printDatum(OS, "#params with binary location", ParamWithLoc); + + // Print the summary for local variables. + printDatum(OS, "#local vars", LocalVarTotal); + printDatum(OS, "#local vars with source location", LocalVarWithSrcLoc); + printDatum(OS, "#local vars with type", LocalVarWithType); + printDatum(OS, "#local vars with binary location", LocalVarWithLoc); + + // Print the debug section sizes. printSectionSizes(OS, Sizes); - printLocationStats(OS, "variables", LocStats.VarParamLocStats); - printLocationStats(OS, "variables (excluding the debug entry values)", + + // Print the location statistics for variables (includes local variables + // and formal parameters). + printDatum(OS, "#variables processed by location statistics", + LocStats.NumVarParam); + printLocationStats(OS, "#variables", LocStats.VarParamLocStats); + printLocationStats(OS, "#variables - entry values", LocStats.VarParamNonEntryValLocStats); - printDatum(OS, "total params procesed by location statistics", - LocStats.NumParam); - printLocationStats(OS, "params", LocStats.ParamLocStats); - printLocationStats(OS, "params (excluding the debug entry values)", + + // Print the location statistics for formal parameters. + printDatum(OS, "#params processed by location statistics", LocStats.NumParam); + printLocationStats(OS, "#params", LocStats.ParamLocStats); + printLocationStats(OS, "#params - entry values", LocStats.ParamNonEntryValLocStats); - printDatum(OS, "total vars procesed by location statistics", LocStats.NumVar); - printLocationStats(OS, "vars", LocStats.VarLocStats); - printLocationStats(OS, "vars (excluding the debug entry values)", - LocStats.VarNonEntryValLocStats); + + // Print the location statistics for local variables. + printDatum(OS, "#local vars processed by location statistics", + LocStats.NumVar); + printLocationStats(OS, "#local vars", LocStats.LocalVarLocStats); + printLocationStats(OS, "#local vars - entry values", + LocStats.LocalVarNonEntryValLocStats); OS << "}\n"; LLVM_DEBUG( llvm::dbgs() << "Total Availability: " Index: llvm/utils/llvm-locstats/llvm-locstats.py =================================================================== --- llvm/utils/llvm-locstats/llvm-locstats.py +++ llvm/utils/llvm-locstats/llvm-locstats.py @@ -188,74 +188,85 @@ print ('error: No valid llvm-dwarfdump statistics found.') sys.exit(1) + # TODO: Parse the statistics Version from JSON. + if opts.only_variables: # Read the JSON only for local variables. variables_total_locstats = \ - json_parsed['total vars procesed by location statistics'] + json_parsed['#local vars processed by location statistics'] variables_scope_bytes_covered = \ - json_parsed['vars scope bytes covered'] + json_parsed['sum_all_local_vars(#bytes in parent scope covered' \ + ' by DW_AT_location)'] variables_scope_bytes = \ - json_parsed['vars scope bytes total'] + json_parsed['sum_all_local_vars(#bytes in parent scope)'] if not opts.ignore_debug_entry_values: for cov_bucket in coverage_buckets(): - cov_category = "vars with {} of its scope covered".format(cov_bucket) + cov_category = "#local vars with {} of parent scope covered " \ + "by DW_AT_location".format(cov_bucket) variables_coverage_map[cov_bucket] = json_parsed[cov_category] else: variables_scope_bytes_entry_values = \ - json_parsed['vars entry value scope bytes covered'] + json_parsed['sum_all_local_vars(#bytes in parent scope ' \ + 'covered by DW_OP_entry_value)'] variables_scope_bytes_covered = variables_scope_bytes_covered \ - variables_scope_bytes_entry_values for cov_bucket in coverage_buckets(): cov_category = \ - "vars (excluding the debug entry values) " \ - "with {} of its scope covered".format(cov_bucket) + "#local vars - entry values with {} of parent scope " \ + "covered by DW_AT_location".format(cov_bucket) variables_coverage_map[cov_bucket] = json_parsed[cov_category] elif opts.only_formal_parameters: # Read the JSON only for formal parameters. variables_total_locstats = \ - json_parsed['total params procesed by location statistics'] + json_parsed['#params processed by location statistics'] variables_scope_bytes_covered = \ - json_parsed['formal params scope bytes covered'] + json_parsed['sum_all_params(#bytes in parent scope covered ' \ + 'by DW_AT_location)'] variables_scope_bytes = \ - json_parsed['formal params scope bytes total'] + json_parsed['sum_all_params(#bytes in parent scope)'] if not opts.ignore_debug_entry_values: for cov_bucket in coverage_buckets(): - cov_category = "params with {} of its scope covered".format(cov_bucket) + cov_category = "#params with {} of parent scope covered " \ + "by DW_AT_location".format(cov_bucket) variables_coverage_map[cov_bucket] = json_parsed[cov_category] else: variables_scope_bytes_entry_values = \ - json_parsed['formal params entry value scope bytes covered'] + json_parsed['sum_all_params(#bytes in parent scope covered ' \ + 'by DW_OP_entry_value)'] variables_scope_bytes_covered = variables_scope_bytes_covered \ - variables_scope_bytes_entry_values for cov_bucket in coverage_buckets(): cov_category = \ - "params (excluding the debug entry values) " \ - "with {} of its scope covered".format(cov_bucket) + "#params - entry values with {} of parent scope covered" \ + " by DW_AT_location".format(cov_bucket) variables_coverage_map[cov_bucket] = json_parsed[cov_category] else: # Read the JSON for both local variables and formal parameters. variables_total = \ - json_parsed['source variables'] - variables_with_loc = json_parsed['variables with location'] + json_parsed['#source variables'] + variables_with_loc = json_parsed['#source variables with location'] variables_total_locstats = \ - json_parsed['total variables procesed by location statistics'] + json_parsed['#variables processed by location statistics'] variables_scope_bytes_covered = \ - json_parsed['scope bytes covered'] + json_parsed['sum_all_variables(#bytes in parent scope covered ' \ + 'by DW_AT_location)'] variables_scope_bytes = \ - json_parsed['scope bytes total'] + json_parsed['sum_all_variables(#bytes in parent scope)'] if not opts.ignore_debug_entry_values: for cov_bucket in coverage_buckets(): - cov_category = "variables with {} of its scope covered". \ - format(cov_bucket) + cov_category = "#variables with {} of parent scope covered " \ + "by DW_AT_location".format(cov_bucket) variables_coverage_map[cov_bucket] = json_parsed[cov_category] else: variables_scope_bytes_entry_values = \ - json_parsed['entry value scope bytes covered'] + json_parsed['sum_all_variables(#bytes in parent scope covered ' \ + 'by DW_OP_entry_value)'] variables_scope_bytes_covered = variables_scope_bytes_covered \ - variables_scope_bytes_entry_values for cov_bucket in coverage_buckets(): - cov_category = "variables (excluding the debug entry values) " \ - "with {} of its scope covered". format(cov_bucket) + cov_category = \ + "#variables - entry values with {} of parent scope covered " \ + "by DW_AT_location".format(cov_bucket) variables_coverage_map[cov_bucket] = json_parsed[cov_category] return LocationStats(binary, variables_total, variables_total_locstats,