diff options
author | Tom de Vries <tdevries@suse.de> | 2018-08-21 07:39:29 +0000 |
---|---|---|
committer | Tom de Vries <vries@gcc.gnu.org> | 2018-08-21 07:39:29 +0000 |
commit | efd9eb2979c1d01c2bea341e5faf1a682c104ff4 (patch) | |
tree | 0247b12fe1a37d3b294a4750c853f5f72752a414 /gcc/dwarf2out.c | |
parent | 916f27adfdf0a2aa8a8d30fa68f86d5eab226ff9 (diff) | |
download | gcc-efd9eb2979c1d01c2bea341e5faf1a682c104ff4.zip gcc-efd9eb2979c1d01c2bea341e5faf1a682c104ff4.tar.gz gcc-efd9eb2979c1d01c2bea341e5faf1a682c104ff4.tar.bz2 |
[debug] Add debug and earlydebug dumps
With the introduction of early debug, we've added a phase in the compiler which
produces information which is not visible, unless we run the compiler in the
debugger and call debug_dwarf from dwarf2out_early_finish or some such.
This patch adds dumping of "early" and "final" debug info, into .earlydebug
and .debug dump files, enabled by -fdump-earlydebug and -fdumpdebug, such that
we can follow f.i. the upper bound of a vla type from early debug:
...
DW_AT_upper_bound: location descriptor:
(0x7f0d645b7550) DW_OP_GNU_variable_value , 0
...
to final debug:
...
DW_AT_upper_bound: location descriptor:
(0x7f0d645b7550) DW_OP_fbreg 18446744073709551592, 0
(0x7f0d645b7a00) DW_OP_deref 8, 0
...
to -dA annotated assembly file:
...
.uleb128 0x3 # DW_AT_upper_bound
.byte 0x91 # DW_OP_fbreg
.sleb128 -24
.byte 0x6 # DW_OP_deref
...
The .debug file shows the same information as the annotated assembly, but in
the same format as the "early" debug info.
Bootstrapped and reg-tested on x86_64.
2018-08-21 Tom de Vries <tdevries@suse.de>
* cgraph.h (debuginfo_early_init, debuginfo_init, debuginfo_fini)
(debuginfo_start, debuginfo_stop, debuginfo_early_start)
(debuginfo_early_stop): Declare.
* cgraphunit.c (debuginfo_early_init, debuginfo_init, debuginfo_fini)
(debuginfo_start, debuginfo_stop, debuginfo_early_start)
(debuginfo_early_stop): New function.
(symbol_table::finalize_compilation_unit): Call debuginfo_early_start
and debuginfo_early_stop.
* dwarf2out.c (dwarf2out_finish, dwarf2out_early_finish): Dump dwarf.
* toplev.c (compile_file): Call debuginfo_start and debuginfo_stop.
(general_init): Call debuginfo_early_init.
(finalize): Call debuginfo_fini.
(do_compile): Call debuginfo_init.
* doc/invoke.texi (@gccoptlist): Add -fdump-debug and
-fdump-early-debug.
(@item -fdump-debug, @item -fdump-earlydebug): Add.
* lto.c (lto_main): Call debuginfo_early_start and
debuginfo_early_stop.
* gcc.c-torture/unsorted/dump-noaddr.x: Use -gno-record-gcc-switches
to avoid mismatch in .debug and .earlydebug dump files.
From-SVN: r263687
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index ffb332a..fb71ff3 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -31112,7 +31112,7 @@ reset_dies (dw_die_ref die) and generate the DWARF-2 debugging info. */ static void -dwarf2out_finish (const char *) +dwarf2out_finish (const char *filename) { comdat_type_node *ctnode; dw_die_ref main_comp_unit_die; @@ -31193,6 +31193,12 @@ dwarf2out_finish (const char *) resolve_addr (comp_unit_die ()); move_marked_base_types (); + if (dump_file) + { + fprintf (dump_file, "DWARF for %s\n", filename); + print_die (comp_unit_die (), dump_file); + } + /* Initialize sections and labels used for actual assembler output. */ unsigned generation = init_sections_and_labels (false); @@ -31888,6 +31894,11 @@ dwarf2out_early_finish (const char *filename) if (in_lto_p) { early_dwarf_finished = true; + if (dump_file) + { + fprintf (dump_file, "LTO EARLY DWARF for %s\n", filename); + print_die (comp_unit_die (), dump_file); + } return; } @@ -31965,6 +31976,11 @@ dwarf2out_early_finish (const char *filename) /* The early debug phase is now finished. */ early_dwarf_finished = true; + if (dump_file) + { + fprintf (dump_file, "EARLY DWARF for %s\n", filename); + print_die (comp_unit_die (), dump_file); + } /* Do not generate DWARF assembler now when not producing LTO bytecode. */ if ((!flag_generate_lto && !flag_generate_offload) |