diff options
author | Pierre-Marie de Rodat <derodat@adacore.com> | 2017-06-21 11:24:51 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2017-06-21 11:24:51 +0000 |
commit | ff9baa5f1c532a43d7d14a800f5a4a5c5757dca6 (patch) | |
tree | 7395ae997bed267b7d956093500e639f090e9fc8 /gcc/ada/gcc-interface/decl.c | |
parent | a23ba8ccd0d3e16de01dfccf6304b9014e84f64f (diff) | |
download | gcc-ff9baa5f1c532a43d7d14a800f5a4a5c5757dca6.zip gcc-ff9baa5f1c532a43d7d14a800f5a4a5c5757dca6.tar.gz gcc-ff9baa5f1c532a43d7d14a800f5a4a5c5757dca6.tar.bz2 |
DWARF: make it possible to emit debug info for declarations only
The DWARF back-end used to systematically ignore file-scope function and
variable declarations. While this is justified in language like C/C++,
where such declarations can appear in several translation units and thus
bloat uselessly the debug info, this behavior is counter-productive in
languages with a well-defined module system. Specifically, it prevents
the description of imported entities, that belong to foreign languages,
making them unavailable from debuggers.
Take for instance:
package C_Binding is
function My_C_Function (I : Integer) return Integer;
pragma Import (C, My_C_Function, "my_c_function");
end C_Binding;
This makes available for Ada programs the C function "my_c_function"
under the following name: C_Binding.My_C_Function. When GCC compiles
it, though, it is represented as a FUNCTION_DECL node with DECL_EXTERNAL
set and a null DECL_INITIAL, which used to be discarded unconditionally
in the DWARF back-end.
This patch moves such filter from the DWARF back-end to the relevant
callers: passes.c:rest_of_decl_compilation and
godump.c:go_early_global_decl. It also This patch also updates the Ada
front-end to call debug hooks for functions such as in the above
example, so that we do generate debugging information for them.
gcc/
* dwarf2out.c (gen_decl_die): Remove the guard to skip file-scope
FUNCTION_DECL declarations.
(dwarf2out_early_global_decl): Remove the guard to skip FUNCTION_DECL
declarations.
(dwaf2out_decl): Likewise.
* godump.c (go_early_global_decl): Skip call to the real debug hook
for FUNCTION_DECL declarations.
* passes.c (rest_of_decl_compilation): Skip call to the
early_global_decl debug hook for FUNCTION_DECL declarations, unless
-fdump-go-spec is passed.
gcc/ada/
* gcc-interface/ada-tree.h (DECL_FUNCTION_IS_DEF): Update copyright
notice. New macro.
* gcc-interface/trans.c (Subprogram_Body_to_gnu): Tag the subprogram
as a definition.
(Compilation_Unit_to_gnu): Tag the elaboration procedure as a
definition.
* gcc-interface/decl.c (gnat_to_gnu_entity): Tag declarations of
imported subprograms for the current compilation unit as
definitions. Disable debug info for references to variables.
* gcc-interface/gigi.h (create_subprog_decl): Update declaration.
* gcc-interface/utils.c (gnat_pushdecl): Add external DECLs that are
not built-in functions to their binding scope.
(create_subprog_decl): Add a DEFINITION parameter. If it is true, tag
the function as a definition. Update all callers.
(gnat_write_global_declarations): Emit debug info for imported
functions. Filter out external variables for which debug info
is disabled.
gcc/testsuite/
* gnat.dg/debug11_pkg.adb, gnat.dg/debug11_pkg.ads,
gnat.dg/debug11_pkg2.ads: New testcase.
From-SVN: r249449
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index eab244e..83b9d07 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1392,7 +1392,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) = create_var_decl (create_concat_name (gnat_entity, "ALIGN"), NULL_TREE, gnu_new_type, NULL_TREE, false, false, false, false, false, - true, debug_info_p, NULL, gnat_entity); + true, debug_info_p && definition, NULL, + gnat_entity); /* Initialize the aligned field if we have an initializer. */ if (gnu_expr) @@ -1441,7 +1442,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) NULL_TREE, gnu_type, gnu_expr, const_flag, Is_Public (gnat_entity), imported_p || !definition, static_flag, - volatile_flag, true, debug_info_p, + volatile_flag, true, + debug_info_p && definition, NULL, gnat_entity); gnu_expr = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_unc_var); TREE_CONSTANT (gnu_expr) = 1; @@ -1492,8 +1494,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) = create_var_decl (gnu_entity_name, gnu_ext_name, gnu_type, gnu_expr, const_flag, Is_Public (gnat_entity), imported_p || !definition, static_flag, - volatile_flag, artificial_p, debug_info_p, - attr_list, gnat_entity, !renamed_obj); + volatile_flag, artificial_p, + debug_info_p && definition, attr_list, + gnat_entity, !renamed_obj); DECL_BY_REF_P (gnu_decl) = used_by_ref; DECL_POINTS_TO_READONLY_P (gnu_decl) = used_by_ref && inner_const_flag; DECL_CAN_NEVER_BE_NULL_P (gnu_decl) = Can_Never_Be_Null (gnat_entity); @@ -1545,8 +1548,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) = create_var_decl (gnu_entity_name, gnu_ext_name, gnu_type, gnu_expr, true, Is_Public (gnat_entity), !definition, static_flag, volatile_flag, - artificial_p, debug_info_p, attr_list, - gnat_entity, false); + artificial_p, debug_info_p && definition, + attr_list, gnat_entity, false); SET_DECL_CONST_CORRESPONDING_VAR (gnu_decl, gnu_corr_var); } @@ -4083,7 +4086,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) gnu_type, gnu_param_list, inline_status, public_flag, extern_flag, artificial_p, - debug_info_p, attr_list, gnat_entity); + debug_info_p, + definition && imported_p, attr_list, + gnat_entity); DECL_STUBBED_P (gnu_decl) = (Convention (gnat_entity) == Convention_Stubbed); |