From 4ec929165e715d09b04b260c16fd58b7f3ccc1dc Mon Sep 17 00:00:00 2001
From: dpatel <dpatel@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 12 Aug 2004 21:32:56 +0000
Subject: [PATCH]         * dbxout.c (dbxout_begin_prologue): New function.    
     (dbx_debug_hooks): Use new begin prologue hook.        
 (dbxout_function_end): Emit N_ENSYM.         * stab.def (N_BNSYM, N_ENSYM):
 Define and document these two new stabs.

        testsuite:
        gcc.dg/darwin-20040809-2.c: New test.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85908 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                            |  7 +++++++
 gcc/dbxout.c                             | 18 ++++++++++++++++--
 gcc/stab.def                             | 10 ++++++++--
 gcc/testsuite/ChangeLog                  |  4 ++++
 gcc/testsuite/gcc.dg/darwin-20040809-2.c | 15 +++++++++++++++
 5 files changed, 50 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/darwin-20040809-2.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a1baa0f9384b..7ddf1acd3fc9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2004-08-12  Devang patel  <dpatel@apple.com>
+
+	* dbxout.c (dbxout_begin_prologue): New function.
+	(dbx_debug_hooks): Use new begin prologue hook.
+	(dbxout_function_end): Emit N_ENSYM.
+	* stab.def (N_BNSYM, N_ENSYM): Define and document these two new stabs.
+	
 2004-08-12  Janis Johnson  <janis187@us.ibm.com>
 
 	* config/rs6000/altivec.h (vec_dst): Fix C++ functions whose first
diff --git a/gcc/dbxout.c b/gcc/dbxout.c
index 9a9e44732d04..55f2275094f9 100644
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -372,6 +372,7 @@ static void dbxout_handle_pch (unsigned);
 #if defined (DBX_DEBUGGING_INFO)
 
 static void dbxout_source_line (unsigned int, const char *);
+static void dbxout_begin_prologue (unsigned int, const char *);
 static void dbxout_source_file (FILE *, const char *);
 static void dbxout_function_end (void);
 static void dbxout_begin_function (tree);
@@ -391,8 +392,7 @@ const struct gcc_debug_hooks dbx_debug_hooks =
   dbxout_end_block,
   debug_true_tree,		         /* ignore_block */
   dbxout_source_line,		         /* source_line */
-  dbxout_source_line,		         /* begin_prologue: just output 
-					    line info */
+  dbxout_begin_prologue,	         /* begin_prologue */
   debug_nothing_int_charstar,	         /* end_prologue */
   debug_nothing_int_charstar,	         /* end_epilogue */
 #ifdef DBX_FUNCTION_FIRST
@@ -481,6 +481,9 @@ dbxout_function_end (void)
   assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
   fprintf (asmfile, "\n");
 #endif
+
+  if (!flag_debug_only_used_symbols)
+    fprintf (asmfile, "%s%d,0,0\n", ASM_STABD_OP, N_ENSYM);
 }
 #endif /* DBX_DEBUGGING_INFO */
 
@@ -753,6 +756,17 @@ dbxout_source_file (FILE *file, const char *filename)
     }
 }
 
+/* Output N_BNSYM and line number symbol entry.  */
+
+static void
+dbxout_begin_prologue (unsigned int lineno, const char *filename)
+{
+  if (!flag_debug_only_used_symbols)
+    fprintf (asmfile, "%s%d,0,0\n", ASM_STABD_OP, N_BNSYM);
+
+  dbxout_source_line (lineno, filename);
+}
+
 /* Output a line number symbol entry for source file FILENAME and line
    number LINENO.  */
 
diff --git a/gcc/stab.def b/gcc/stab.def
index 7a0b84960b11..2d5896162359 100644
--- a/gcc/stab.def
+++ b/gcc/stab.def
@@ -39,6 +39,12 @@ __define_stab (N_STSYM, 0x26, "STSYM")
 /* BSS-segment variable with internal linkage.  Value is its address.  */
 __define_stab (N_LCSYM, 0x28, "LCSYM")
 
+/* Begin function marker.  */
+__define_stab (N_BNSYM, 0x2e, "BNSYM")
+
+/* End function marker.  */
+__define_stab (N_ENSYM, 0x4e, "ENSYM")
+
 /* Name of main routine.  Only the name is significant.
    This is not used in C.  */
 __define_stab (N_MAIN, 0x2a, "MAIN")
@@ -201,11 +207,11 @@ __define_stab (N_LENG, 0xfe, "LENG")
 	|_______________________________________________|
 	| Debug entries with bit 01 set are unused.	|
 	| 20 GSYM   | 22 FNAME	| 24 FUN    | 26 STSYM	|
-	| 28 LCSYM  | 2A MAIN	| 2C	    | 2E	|
+	| 28 LCSYM  | 2A MAIN	| 2C	    | 2E BNSYM	|
 	| 30 PC	    | 32 NSYMS	| 34 NOMAP  | 36	|
 	| 38 OBJ    | 3A	| 3C OPT    | 3E	|
 	| 40 RSYM   | 42 M2C	| 44 SLINE  | 46 DSLINE |
-	| 48 BSLINE*| 4A DEFD	| 4C        | 4E	|
+	| 48 BSLINE*| 4A DEFD	| 4C        | 4E ENSYM	|
 	| 50 EHDECL*| 52	| 54 CATCH  | 56        |
 	| 58        | 5A        | 5C        | 5E	|
 	| 60 SSYM   | 62	| 64 SO	    | 66 	|
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0233a7947023..73d9c13ab249 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2004-08-12  Devang patel  <dpatel@apple.com>
+
+	* gcc.dg/darwin-20040809-2.c: New test.
+	
 2004-08-12  Janis Johnson  <janis1872us.ibm.com>
 
 	* g++.dg/ext/altivec-12.C: New test.
diff --git a/gcc/testsuite/gcc.dg/darwin-20040809-2.c b/gcc/testsuite/gcc.dg/darwin-20040809-2.c
new file mode 100644
index 000000000000..5ed27a4363a4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/darwin-20040809-2.c
@@ -0,0 +1,15 @@
+/* Test dead code strip support.  */
+/* Contributed by Devang Patel  <dpatel@apple.com>  */
+
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-options "-g -fno-eliminate-unused-debug-symbols" } */
+
+int
+main ()
+{
+  return 0;
+}
+
+/* { dg-final { scan-assembler ".stabd.46,0,0" } } */
+/* { dg-final { scan-assembler ".stabd.78,0,0" } } */
+
-- 
GitLab