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/cgraphunit.c | |
parent | 916f27adfdf0a2aa8a8d30fa68f86d5eab226ff9 (diff) |
[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/cgraphunit.c')
-rw-r--r-- | gcc/cgraphunit.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 208798f0dc7..ec490d75bd1 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2641,6 +2641,89 @@ symbol_table::compile (void) } } +/* Earlydebug dump file, flags, and number. */ + +static int debuginfo_early_dump_nr; +static FILE *debuginfo_early_dump_file; +static dump_flags_t debuginfo_early_dump_flags; + +/* Debug dump file, flags, and number. */ + +static int debuginfo_dump_nr; +static FILE *debuginfo_dump_file; +static dump_flags_t debuginfo_dump_flags; + +/* Register the debug and earlydebug dump files. */ + +void +debuginfo_early_init (void) +{ + gcc::dump_manager *dumps = g->get_dumps (); + debuginfo_early_dump_nr = dumps->dump_register (".earlydebug", "earlydebug", + "earlydebug", DK_tree, + OPTGROUP_NONE, + false); + debuginfo_dump_nr = dumps->dump_register (".debug", "debug", + "debug", DK_tree, + OPTGROUP_NONE, + false); +} + +/* Initialize the debug and earlydebug dump files. */ + +void +debuginfo_init (void) +{ + gcc::dump_manager *dumps = g->get_dumps (); + debuginfo_dump_file = dump_begin (debuginfo_dump_nr, NULL); + debuginfo_dump_flags = dumps->get_dump_file_info (debuginfo_dump_nr)->pflags; + debuginfo_early_dump_file = dump_begin (debuginfo_early_dump_nr, NULL); + debuginfo_early_dump_flags + = dumps->get_dump_file_info (debuginfo_early_dump_nr)->pflags; +} + +/* Finalize the debug and earlydebug dump files. */ + +void +debuginfo_fini (void) +{ + if (debuginfo_dump_file) + dump_end (debuginfo_dump_nr, debuginfo_dump_file); + if (debuginfo_early_dump_file) + dump_end (debuginfo_early_dump_nr, debuginfo_early_dump_file); +} + +/* Set dump_file to the debug dump file. */ + +void +debuginfo_start (void) +{ + set_dump_file (debuginfo_dump_file); +} + +/* Undo setting dump_file to the debug dump file. */ + +void +debuginfo_stop (void) +{ + set_dump_file (NULL); +} + +/* Set dump_file to the earlydebug dump file. */ + +void +debuginfo_early_start (void) +{ + set_dump_file (debuginfo_early_dump_file); +} + +/* Undo setting dump_file to the earlydebug dump file. */ + +void +debuginfo_early_stop (void) +{ + set_dump_file (NULL); +} /* Analyze the whole compilation unit once it is parsed completely. */ @@ -2696,7 +2779,9 @@ symbol_table::finalize_compilation_unit (void) /* Clean up anything that needs cleaning up after initial debug generation. */ + debuginfo_early_start (); (*debug_hooks->early_finish) (main_input_filename); + debuginfo_early_stop (); } /* Finally drive the pass manager. */ |