diff options
author | Richard Biener <rguenther@suse.de> | 2020-07-30 11:46:43 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-07-31 15:19:13 +0200 |
commit | c6ef9d8d3f11221df1ea6358b8d4e79e42f074fb (patch) | |
tree | 1395c4090dc0f0cea95303eceb8e922f4dcc45a6 /gcc/c-family/c-common.c | |
parent | 14c35be3bf493859b92c3c6ca7893075212169ab (diff) | |
download | gcc-c6ef9d8d3f11221df1ea6358b8d4e79e42f074fb.zip gcc-c6ef9d8d3f11221df1ea6358b8d4e79e42f074fb.tar.gz gcc-c6ef9d8d3f11221df1ea6358b8d4e79e42f074fb.tar.bz2 |
debug/96383 - emit debug info for used external functions
This makes sure to emit full declaration DIEs including
formal parameters for used external functions. This helps
debugging when debug information of the external entity is
not available and also helps external tools cross-checking
ABI compatibility which was the bug reporters use case.
For cc1 this affects debug information size as follows:
VM SIZE FILE SIZE
++++++++++++++ GROWING ++++++++++++++
[ = ] 0 .debug_info +1.63Mi +1.3%
[ = ] 0 .debug_str +263Ki +3.4%
[ = ] 0 .debug_abbrev +101Ki +4.9%
[ = ] 0 .debug_line +5.71Ki +0.0%
+44% +16 [Unmapped] +48 +1.2%
-------------- SHRINKING --------------
[ = ] 0 .debug_loc -213 -0.0%
-0.0% -48 .text -48 -0.0%
[ = ] 0 .debug_ranges -16 -0.0%
-0.0% -32 TOTAL +1.99Mi +0.6%
and DWARF compression via DWZ can only shave off minor bits
here.
Previously we emitted no DIEs for external functions at all
unless they were referenced via DW_TAG_GNU_call_site which
for some GCC revs caused a regular DIE to appear and since
GCC 4.9 only a stub without formal parameters. This means
at -O0 we did not emit any DIE for external functions
but with optimization we emitted stubs.
2020-07-30 Richard Biener <rguenther@suse.de>
PR debug/96383
* langhooks-def.h (lhd_finalize_early_debug): Declare.
(LANG_HOOKS_FINALIZE_EARLY_DEBUG): Define.
(LANG_HOOKS_INITIALIZER): Amend.
* langhooks.c: Include cgraph.h and debug.h.
(lhd_finalize_early_debug): Default implementation from
former code in finalize_compilation_unit.
* langhooks.h (lang_hooks::finalize_early_debug): Add.
* cgraphunit.c (symbol_table::finalize_compilation_unit):
Call the finalize_early_debug langhook.
gcc/c-family/
* c-common.h (c_common_finalize_early_debug): Declare.
* c-common.c: Include debug.h.
(c_common_finalize_early_debug): finalize_early_debug langhook
implementation generating debug for extern declarations.
gcc/c/
* c-objc-common.h (LANG_HOOKS_FINALIZE_EARLY_DEBUG):
Define to c_common_finalize_early_debug.
gcc/cp/
* cp-objcp-common.h (LANG_HOOKS_FINALIZE_EARLY_DEBUG):
Define to c_common_finalize_early_debug.
gcc/testsuite/
* gcc.dg/debug/dwarf2/pr96383-1.c: New testcase.
* gcc.dg/debug/dwarf2/pr96383-2.c: Likewise.
libstdc++-v3/
* testsuite/20_util/assume_aligned/3.cc: Use -g0.
Diffstat (limited to 'gcc/c-family/c-common.c')
-rw-r--r-- | gcc/c-family/c-common.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 116867a..b97539c 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "spellcheck.h" #include "c-spellcheck.h" #include "selftest.h" +#include "debug.h" cpp_reader *parse_in; /* Declared in c-pragma.h. */ @@ -9086,4 +9087,20 @@ braced_lists_to_strings (tree type, tree ctor) return braced_lists_to_strings (type, ctor, false); } + +/* Emit debug for functions before finalizing early debug. */ + +void +c_common_finalize_early_debug (void) +{ + /* Emit early debug for reachable functions, and by consequence, + locally scoped symbols. Also emit debug for extern declared + functions that are still reachable at this point. */ + struct cgraph_node *cnode; + FOR_EACH_FUNCTION (cnode) + if (!cnode->alias && !cnode->thunk.thunk_p + && (cnode->has_gimple_body_p () || !DECL_IS_BUILTIN (cnode->decl))) + (*debug_hooks->early_global_decl) (cnode->decl); +} + #include "gt-c-family-c-common.h" |