This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Sequel to PR40521 -- -g causes GCC to generate .eh_frame


Hello!

On 2010-04-02 09:03, Richard Earnshaw wrote:
> Hmm, so the text for DWARF2_UNWIND_INFO reads:
>
>   Define this macro to 0 if your target supports DWARF 2 frame unwind
>   information, but it does not yet work with exception handling.
>   Otherwise, if your target supports this information (if it defines
>   @samp{INCOMING_RETURN_ADDR_RTX}) and @code{TARGET_UNWIND_INFO} is not
> defined,
>   GCC will provide a default definition of 1.
>  
>   If @code{TARGET_UNWIND_INFO} is not defined, and this macro is defined to
> 1,
>   the DWARF 2 unwinder will be the default exception handling mechanism;
>   otherwise, the @code{setjmp}/@code{longjmp}-based scheme will be used by
> [...]
>
> but with your proposed change it now doesn't say what happens if both
> DWARF2_UNWIND_INFO and TARGET_UNWIND_INFO are defined.  If this isn't a
> legal combination, then it should say so; if it is legal, then it needs to
> describe what the combination does.

As I understand this matter, it doesn't make sense.  I have now reflected
that in the documentation.

Here is the complete patch again:

gcc/
2010-03-31  Thomas Schwinge  <thomas@codesourcery.com>
	    Daniel Jacobowitz  <dan@codesourcery.com>

	PR debug/40521
	* doc/tm.texi (DWARF2_UNWIND_INFO, TARGET_UNWIND_INFO): Improve.
	* dwarf2out.c (NEED_UNWIND_TABLES): Define.
	(dwarf2out_do_frame, dwarf2out_do_cfi_asm, dwarf2out_begin_prologue)
	(dwarf2out_frame_finish, dwarf2out_assembly_start): Use it.
	(dwarf2out_assembly_start): Correct logic for TARGET_UNWIND_INFO.
	* config/arm/arm.h (DWARF2_UNWIND_INFO): Remove definition.
	* config/arm/bpabi.h (DWARF2_UNWIND_INFO): Define to zero.

---
 gcc-trunk-4.4/gcc/config/arm/arm.h   |    3 ---
 gcc-trunk-4.4/gcc/config/arm/bpabi.h |    1 +
 gcc-trunk-4.4/gcc/doc/tm.texi        |   12 +++++++-----
 gcc-trunk-4.4/gcc/dwarf2out.c        |   25 +++++++++++++++----------
 4 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/gcc-trunk-4.4/gcc/config/arm/arm.h b/gcc-trunk-4.4/gcc/config/arm/arm.h
index 70ae847..2c106f8 100644
--- a/gcc-trunk-4.4/gcc/config/arm/arm.h
+++ b/gcc-trunk-4.4/gcc/config/arm/arm.h
@@ -947,9 +947,6 @@ extern int arm_structure_size_boundary;
 #define MUST_USE_SJLJ_EXCEPTIONS 1
 #endif
 
-/* We can generate DWARF2 Unwind info, even though we don't use it.  */
-#define DWARF2_UNWIND_INFO 1
-
 /* Use r0 and r1 to pass exception handling information.  */
 #define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? N : INVALID_REGNUM)
 
diff --git a/gcc-trunk-4.4/gcc/config/arm/bpabi.h b/gcc-trunk-4.4/gcc/config/arm/bpabi.h
index 8ab9346..8411b4b 100644
--- a/gcc-trunk-4.4/gcc/config/arm/bpabi.h
+++ b/gcc-trunk-4.4/gcc/config/arm/bpabi.h
@@ -26,6 +26,7 @@
 #define TARGET_BPABI (TARGET_AAPCS_BASED)
 
 /* BPABI targets use EABI frame unwinding tables.  */
+#define DWARF2_UNWIND_INFO 0
 #define TARGET_UNWIND_INFO 1
 
 /* Section 4.1 of the AAPCS requires the use of VFP format.  */
diff --git a/gcc-trunk-4.4/gcc/doc/tm.texi b/gcc-trunk-4.4/gcc/doc/tm.texi
index f77a2d8..291ea36 100644
--- a/gcc-trunk-4.4/gcc/doc/tm.texi
+++ b/gcc-trunk-4.4/gcc/doc/tm.texi
@@ -8481,12 +8481,11 @@ that it does not contain any extraneous set bits in it.
 Define this macro to 0 if your target supports DWARF 2 frame unwind
 information, but it does not yet work with exception handling.
 Otherwise, if your target supports this information (if it defines
-@samp{INCOMING_RETURN_ADDR_RTX} and either @samp{UNALIGNED_INT_ASM_OP}
-or @samp{OBJECT_FORMAT_ELF}), GCC will provide a default definition of 1.
+@samp{INCOMING_RETURN_ADDR_RTX}) and @code{TARGET_UNWIND_INFO} is not defined,
+GCC will provide a default definition of 1.
 
-If @code{TARGET_UNWIND_INFO} is defined, the target specific unwinder
-will be used in all cases.  Defining this macro will enable the generation
-of DWARF 2 frame debugging information.
+If @code{TARGET_UNWIND_INFO} is defined, it doesn't make sense to define this
+macro to 1.
 
 If @code{TARGET_UNWIND_INFO} is not defined, and this macro is defined to 1,
 the DWARF 2 unwinder will be the default exception handling mechanism;
@@ -8497,6 +8496,9 @@ default.
 @defmac TARGET_UNWIND_INFO
 Define this macro if your target has ABI specified unwind tables.  Usually
 these will be output by @code{TARGET_UNWIND_EMIT}.
+
+Defining this macro will affect the default value that is chosen for
+@code{DWARF2_UNWIND_INFO}.
 @end defmac
 
 @deftypevar {Target Hook} bool TARGET_UNWIND_TABLES_DEFAULT
diff --git a/gcc-trunk-4.4/gcc/dwarf2out.c b/gcc-trunk-4.4/gcc/dwarf2out.c
index f977b4e..9436264 100644
--- a/gcc-trunk-4.4/gcc/dwarf2out.c
+++ b/gcc-trunk-4.4/gcc/dwarf2out.c
@@ -103,6 +103,9 @@ static void dwarf2out_source_line (unsigned int, const char *);
 # endif
 #endif
 
+#define NEED_UNWIND_TABLES \
+  (flag_unwind_tables || (flag_exceptions && ! USING_SJLJ_EXCEPTIONS))
+
 /* Map register numbers held in the call frame info that gcc has
    collected using DWARF_FRAME_REGNUM to those that should be output in
    .debug_frame and .eh_frame.  */
@@ -126,9 +129,7 @@ dwarf2out_do_frame (void)
 	  || write_symbols == VMS_AND_DWARF2_DEBUG
 	  || DWARF2_FRAME_INFO || saved_do_cfi_asm
 #ifdef DWARF2_UNWIND_INFO
-	  || (DWARF2_UNWIND_INFO
-	      && (flag_unwind_tables
-		  || (flag_exceptions && ! USING_SJLJ_EXCEPTIONS)))
+	  || (DWARF2_UNWIND_INFO && NEED_UNWIND_TABLES)
 #endif
 	  );
 }
@@ -152,7 +153,7 @@ dwarf2out_do_cfi_asm (void)
 #ifdef TARGET_UNWIND_INFO
       return false;
 #else
-      if (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions))
+      if (!NEED_UNWIND_TABLES)
 	return false;
 #endif
     }
@@ -3250,8 +3251,7 @@ dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED,
   /* ??? current_function_func_begin_label is also used by except.c
      for call-site information.  We must emit this label if it might
      be used.  */
-  if ((! flag_exceptions || USING_SJLJ_EXCEPTIONS)
-      && ! dwarf2out_do_frame ())
+  if (! NEED_UNWIND_TABLES && ! dwarf2out_do_frame ())
     return;
 #else
   if (! dwarf2out_do_frame ())
@@ -3409,7 +3409,7 @@ dwarf2out_frame_finish (void)
 
 #ifndef TARGET_UNWIND_INFO
   /* Output another copy for the unwinder.  */
-  if (! USING_SJLJ_EXCEPTIONS && (flag_unwind_tables || flag_exceptions))
+  if (NEED_UNWIND_TABLES)
     output_call_frame_info (1);
 #endif
 }
@@ -16209,10 +16209,15 @@ dwarf2out_assembly_start (void)
 {
   if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE && dwarf2out_do_cfi_asm ())
     {
-#ifndef TARGET_UNWIND_INFO
-      if (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions))
-#endif
+#ifdef TARGET_UNWIND_INFO
+      /* We're only ever interested in .debug_frame.  */
+      fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");
+#else
+      /* GAS defaults to emitting .eh_frame only, and .debug_frame is not
+	 wanted in case that the former one is present.  */
+      if (! NEED_UNWIND_TABLES)
 	fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");
+#endif
     }
 }
 
-- 
tg: (575e49e..) t/gcc/too_much_CFI (depends on: baseline)


Regards,
 Thomas

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]