In order to accomodate the debugger's support evolution for "new" DWARF
constructs, we need to have an flag that controls the amount of GNAT
encodings/standard DWARF information that is emitted in the debug info.
Propagate this new parameter into the Ada front-end.

gcc/ChangeLog:

        * common.opt (gnat_encodings): New variable
        (dwarf_gnat_encodings): New enum type.
        (fgnat_encodings): New option.
        * flag-types.h (enum dwarf_gnat_encodings): New.

gcc/ada/ChangeLog:

        * gcc-interface/misc.c (gnat_encodings): Undefine macro and
        declare a global variable.
        (gnat_post_options): Initialize this global from options.

--
Pierre-Marie de Rodat
>From 77212283fa0ddbbf6aef4a6f16aa0e8286b811f3 Mon Sep 17 00:00:00 2001
From: Pierre-Marie de Rodat <dero...@adacore.com>
Date: Wed, 17 Sep 2014 14:54:50 +0200
Subject: [PATCH 1/8] Add a flag to control the balance between GNAT encodings
 and std. DWARF

In order to accomodate the debugger's support evolution for "new" DWARF
constructs, we need to have an flag that controls the amount of GNAT
encodings/standard DWARF information that is emitted in the debug info.
Propagate this new parameter into the Ada front-end.

gcc/ChangeLog:

	* common.opt (gnat_encodings): New variable
	(dwarf_gnat_encodings): New enum type.
	(fgnat_encodings): New option.
	* flag-types.h (enum dwarf_gnat_encodings): New.

gcc/ada/ChangeLog:

	* gcc-interface/misc.c (gnat_encodings): Undefine macro and
	declare a global variable.
	(gnat_post_options): Initialize this global from options.
---
 gcc/ada/gcc-interface/misc.c |  4 +++-
 gcc/common.opt               | 21 +++++++++++++++++++++
 gcc/defaults.h               |  4 ++++
 gcc/flag-types.h             | 15 +++++++++++++++
 4 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index 5b2d8b3..2b7bd1b 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -236,12 +236,13 @@ gnat_init_options (unsigned int decoded_options_count,
 
 /* Ada code requires variables for these settings rather than elements
    of the global_options structure.  */
+#undef gnat_encodings
 #undef optimize
 #undef optimize_size
 #undef flag_compare_debug
 #undef flag_short_enums
 #undef flag_stack_check
-int gnat_encodings = 0;
+enum dwarf_gnat_encodings gnat_encodings = DWARF_GNAT_ENCODINGS_DEFAULT;
 int optimize;
 int optimize_size;
 int flag_compare_debug;
@@ -268,6 +269,7 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
   if (!global_options_set.x_flag_diagnostics_show_caret)
     global_dc->show_caret = false;
 
+  gnat_encodings = global_options.x_gnat_encodings;
   optimize = global_options.x_optimize;
   optimize_size = global_options.x_optimize_size;
   flag_compare_debug = global_options.x_flag_compare_debug;
diff --git a/gcc/common.opt b/gcc/common.opt
index 6b2ccbc..d921b4b 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -161,6 +161,11 @@ bool flag_stack_usage_info = false
 Variable
 int flag_debug_asm
 
+
+; Balance between GNAT encodings and standard DWARF to emit.
+Variable
+enum dwarf_gnat_encodings gnat_encodings = DWARF_GNAT_ENCODINGS_DEFAULT
+
 ; -dP causes the rtl to be emitted as a comment in assembly.
 Variable
 int flag_dump_rtl_in_asm
@@ -1318,6 +1323,22 @@ Common Report Var(flag_gcse_after_reload) Optimization
 Perform global common subexpression elimination after register allocation
 has finished
 
+Enum
+Name(dwarf_gnat_encodings) Type(int)
+
+EnumValue
+Enum(dwarf_gnat_encodings) String(all) Value(DWARF_GNAT_ENCODINGS_ALL)
+
+EnumValue
+Enum(dwarf_gnat_encodings) String(gdb) Value(DWARF_GNAT_ENCODINGS_GDB)
+
+EnumValue
+Enum(dwarf_gnat_encodings) String(minimal) Value(DWARF_GNAT_ENCODINGS_MINIMAL)
+
+fgnat-encodings=
+Common Enum(dwarf_gnat_encodings) Joined RejectNegative Report Undocumented Var(gnat_encodings)
+-fgnat-encodings=[all|gdb|minimal]	Select the balance between GNAT encodings and standard DWARF emitted in the debug information
+
 ; This option is not documented yet as its semantics will change.
 fgraphite
 Common Report Var(flag_graphite) Optimization
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 9d38ba1..d0b0080 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -1436,4 +1436,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #endif /* GCC_INSN_FLAGS_H  */
 
+#ifndef DWARF_GNAT_ENCODINGS_DEFAULT
+#define DWARF_GNAT_ENCODINGS_DEFAULT DWARF_GNAT_ENCODINGS_GDB
+#endif
+
 #endif  /* ! GCC_DEFAULTS_H */
diff --git a/gcc/flag-types.h b/gcc/flag-types.h
index 2f820a5..2e6eb41 100644
--- a/gcc/flag-types.h
+++ b/gcc/flag-types.h
@@ -91,6 +91,21 @@ enum debug_struct_file
   DINFO_STRUCT_FILE_ANY     /* Debug structs defined in all files. */
 };
 
+/* Balance between GNAT encodings and standard DWARF to emit.  */
+
+enum dwarf_gnat_encodings
+{
+  DWARF_GNAT_ENCODINGS_ALL = 0,	    /* Emit all GNAT encodings, then emit as
+				       much standard DWARF as possible so it
+				       does not conflict with GNAT
+				       encodings.  */
+  DWARF_GNAT_ENCODINGS_GDB = 1,	    /* Emit as much standard DWARF as possible
+				       as long as GDB handles them.  Emit GNAT
+				       encodings for the rest.  */
+  DWARF_GNAT_ENCODINGS_MINIMAL = 2  /* Emit all the standard DWARF we can.
+				       Emit GNAT encodings for the rest.  */
+};
+
 /* Enumerate visibility settings.  This is deliberately ordered from most
    to least visibility.  */
 #ifndef SYMBOL_VISIBILITY_DEFINED
-- 
2.4.5

Reply via email to