diff mbox

[Darwin] be more friendly to gdb

Message ID 84C8CD72-3333-49FE-8E2E-78C591321627@sandoe-acoustics.co.uk
State New
Headers show

Commit Message

Iain Sandoe Nov. 17, 2011, 4:24 p.m. UTC
As things stand, Darwin's 'as' cannot produce dwarf debug.

Unfortunately, if  "-g" is given to -x assembler-with-cpp ... this  
results in 'as' being called with --stabs.

So, it can be the case that an exe ends up with some stabs debug in it  
- usually with a source file of "{standard input}" (and without an OSO  
entry).

This upsets the OSO parser in machoread.c (in gdb) causing gdb to fail  
with an OSO != NULL assert.

===

This patch prevents  "as" being asked to give debug output unless  
stabs is the chosen debug scheme (so for the default on Darwin >= 9  
asm files will not get any debug data).

It doesn't prevent the scenario completely - the user could still  
produce the situation manually  (I have a gdb patch to work around  
it) ...

===

However, this does mean that a standard (ppc) build of gcc doesn't  
abort gdb (because the .S files in libgcc_s are causing this on ppc).

OK for trunk?
Iain

Comments

Mike Stump Nov. 18, 2011, 10:20 p.m. UTC | #1
On Nov 17, 2011, at 8:24 AM, Iain Sandoe wrote:
> As things stand, Darwin's 'as' cannot produce dwarf debug.

> OK for trunk?

Ok.
diff mbox

Patch

Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h	(revision 181436)
+++ gcc/config/darwin.h	(working copy)
@@ -395,6 +395,11 @@  extern GTY(()) int darwin_ms_struct;
   %{Zforce_cpusubtype_ALL:-force_cpusubtype_ALL} \
   %{static}"
 
+/* Default ASM_DEBUG_SPEC.  Darwin's as cannot currently produce dwarf
+   debugging data.  */
+
+#define ASM_DEBUG_SPEC  "%{g*:%{!g0:%{!gdwarf*:--gstabs}}}"
+
 /* We still allow output of STABS.  */
 
 #define DBX_DEBUGGING_INFO 1
Index: gcc/config/darwin9.h
===================================================================
--- gcc/config/darwin9.h	(revision 181436)
+++ gcc/config/darwin9.h	(working copy)
@@ -41,6 +41,12 @@  along with GCC; see the file COPYING3.  If not see
      %{mdynamic-no-pic: %n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \
       :-pie}}"
 
+/* Only ask as for debug data if the debug style is stabs (since as doesn't
+   yet generate dwarf.)  */
+
+#undef  ASM_DEBUG_SPEC
+#define ASM_DEBUG_SPEC  "%{g*:%{!g0:%{gstabs:--gstabs}}}"
+
 #undef  ASM_OUTPUT_ALIGNED_COMMON
 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
   do {									\