2010-07-26  Julian Brown  <julian@codesourcery.com>

        Merge from Sourcery G++ 4.4:

	2010-04-07  Thomas Schwinge  <thomas@codesourcery.com>
		    Daniel Jacobowitz  <dan@codesourcery.com>

	Issue #6715

	PR debug/40521

	gcc/
	* 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.


=== modified file 'gcc/config/arm/arm.h'
--- old/gcc/config/arm/arm.h	2010-08-13 10:30:35 +0000
+++ new/gcc/config/arm/arm.h	2010-08-13 11:11:15 +0000
@@ -932,9 +932,6 @@
 #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)
 

=== modified file 'gcc/config/arm/bpabi.h'
--- old/gcc/config/arm/bpabi.h	2009-11-20 17:37:30 +0000
+++ new/gcc/config/arm/bpabi.h	2010-08-13 11:11:15 +0000
@@ -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.  */

=== modified file 'gcc/dwarf2out.c'
--- old/gcc/dwarf2out.c	2010-07-01 11:31:19 +0000
+++ new/gcc/dwarf2out.c	2010-08-13 11:11:15 +0000
@@ -124,6 +124,9 @@
 # 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.  */
@@ -147,9 +150,7 @@
 	  || 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
 	  );
 }
@@ -185,7 +186,7 @@
 #ifdef TARGET_UNWIND_INFO
       return false;
 #else
-      if (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions))
+      if (!NEED_UNWIND_TABLES)
 	return false;
 #endif
     }
@@ -3906,8 +3907,7 @@
   /* ??? 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 ())
@@ -4067,7 +4067,7 @@
 
 #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
 }
@@ -20732,10 +20732,15 @@
 {
   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
     }
 }
 

