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: [PATCH] Fix stabs debug output for ARM.


On Fri, Jul 07, 2006 at 09:30:03AM -0700, Mark Mitchell wrote:
> Ian Lance Taylor wrote:
> 
> > Carlos, do you want to take a look at that?  If the new code does work
> > for PowerPC, it is probably worth implementing generally.
> 
> I agree.
> 
> > I'm not super excited about adding new symbols to every port, but on
> > the other hand this is only for stabs so it's not too important.
> 
> I would see having fully generic code here as a win: eliminate
> port-specific code and attendant hooks.  The new symbols are local
> labels, so they take up no space in object files.
> 
> In any case, let's see what Carlos reports.

The hooks for DBX_OUTPUT_LBRAC, DBX_OUTPUT_NBRAC, and DBX_OUTPUT_NFUN
appear to be used only by the rs6000 backend. With this patch they can
be removed.

I tested on a native powerpc64-linux system without regressions.

As smoke-test I also compiled a small "hello world" with stabs, verified
the stab data by hand, and then ran it under gdb without a problem.

This patch fixes stabs for ARM, simplifies the rs6000 backend, and
simplifies the stabs code.

OK?

Cheers,
Carlos.
-- 
Carlos O'Donell
CodeSourcery
carlos@codesourcery.com
(650) 331-3385 x716

2006-07-10  Carlos O'Donell  <carlos@codesoucery.com>

	* dbxout.c (dbxout_begin_prologue): Emit LFBB label at function start.
	(dbxout_function_end): Use local label LFBB. Remove hook DBX_OUTPUT_NFUN.
	(dbxout_source_line): Use local label LFBB.
	(dbxout_block): Likewise.
	(dbx_output_lbrac): Remove hook DBX_OUTPUT_LBRAC.
	(dbx_output_rbrac): Remove hook DBX_OUTPUT_RBRAC.
	* config/rs6000/linux64.h: Remove DBX_OUTPUT_LBRAC, DBX_OUTPUT_RBRAC,
	and DBX_OUTPUT_NFUN.

Index: gcc/dbxout.c
===================================================================
--- gcc/dbxout.c	(revision 115286)
+++ gcc/dbxout.c	(working copy)
@@ -905,6 +905,7 @@ static void
 dbxout_function_end (tree decl)
 {
   char lscope_label_name[100];
+  int lscope_labelno = scope_labelno++;
 
   /* The Lscope label must be emitted even if we aren't doing anything
      else; dbxout_block needs it.  */
@@ -913,9 +914,8 @@ dbxout_function_end (tree decl)
   /* Convert Lscope into the appropriate format for local labels in case
      the system doesn't insert underscores in front of user generated
      labels.  */
-  ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
-  targetm.asm_out.internal_label (asm_out_file, "Lscope", scope_labelno);
-  scope_labelno++;
+  ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", lscope_labelno);
+  targetm.asm_out.internal_label (asm_out_file, "Lscope", lscope_labelno);
 
   /* The N_FUN tag at the end of the function is a GNU extension,
      which may be undesirable, and is unnecessary if we do not have
@@ -928,9 +928,6 @@ dbxout_function_end (tree decl)
 
   /* By convention, GCC will mark the end of a function with an N_FUN
      symbol and an empty string.  */
-#ifdef DBX_OUTPUT_NFUN
-  DBX_OUTPUT_NFUN (asm_out_file, lscope_label_name, current_function_decl);
-#else
   if (flag_reorder_blocks_and_partition)
     {
       dbxout_begin_empty_stabs (N_FUN);
@@ -942,13 +939,12 @@ dbxout_function_end (tree decl)
     }
   else
     {
+      char begin_label[20];
+      /* Reference current function start using LFBB.  */
+      ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", lscope_labelno);
       dbxout_begin_empty_stabs (N_FUN);
-      dbxout_stab_value_label_diff (lscope_label_name,
-				    XSTR (XEXP (DECL_RTL (current_function_decl), 
-						0), 0));
+      dbxout_stab_value_label_diff (lscope_label_name, begin_label);
     }
-				
-#endif
 
   if (!NO_DBX_BNSYM_ENSYM && !flag_debug_only_used_symbols)
     dbxout_stabd (N_ENSYM, 0);
@@ -1241,7 +1237,8 @@ dbxout_source_file (const char *filename
     }
 }
 
-/* Output N_BNSYM and line number symbol entry.  */
+/* Output N_BNSYM, line number symbol entry, and local symbol at 
+   function scope  */
 
 static void
 dbxout_begin_prologue (unsigned int lineno, const char *filename)
@@ -1253,6 +1250,10 @@ dbxout_begin_prologue (unsigned int line
     dbxout_stabd (N_BNSYM, 0);
 
   dbxout_source_line (lineno, filename);
+  /* Output function begin block at function scope, referenced 
+     by dbxout_block, dbxout_source_line and dbxout_function_end.  */
+  emit_pending_bincls_if_required ();
+  targetm.asm_out.internal_label (asm_out_file, "LFBB", scope_labelno);
 }
 
 /* Output a line number symbol entry for source file FILENAME and line
@@ -1268,11 +1269,12 @@ dbxout_source_line (unsigned int lineno,
 #else
   if (DBX_LINES_FUNCTION_RELATIVE)
     {
-      rtx begin_label = XEXP (DECL_RTL (current_function_decl), 0);
+      char begin_label[20];
       dbxout_begin_stabn_sline (lineno);
+      /* Reference current function start using LFBB.  */
+      ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", scope_labelno); 
       dbxout_stab_value_internal_label_diff ("LM", &dbxout_source_line_counter,
-					     XSTR (begin_label, 0));
-
+					     begin_label);
     }
   else
     dbxout_stabd (N_SLINE, lineno);
@@ -3263,15 +3265,11 @@ static void
 dbx_output_lbrac (const char *label,
 		  const char *begin_label ATTRIBUTE_UNUSED)
 {
-#ifdef DBX_OUTPUT_LBRAC
-  DBX_OUTPUT_LBRAC (asm_out_file, label);
-#else
   dbxout_begin_stabn (N_LBRAC);
   if (DBX_BLOCKS_FUNCTION_RELATIVE)
     dbxout_stab_value_label_diff (label, begin_label);
   else
     dbxout_stab_value_label (label);
-#endif
 }
 
 /* Subroutine of dbxout_block.  Emit an N_RBRAC stab referencing LABEL.
@@ -3281,15 +3279,11 @@ static void
 dbx_output_rbrac (const char *label,
 		  const char *begin_label ATTRIBUTE_UNUSED)
 {
-#ifdef DBX_OUTPUT_RBRAC
-  DBX_OUTPUT_RBRAC (asm_out_file, label);
-#else
   dbxout_begin_stabn (N_RBRAC);
   if (DBX_BLOCKS_FUNCTION_RELATIVE)
     dbxout_stab_value_label_diff (label, begin_label);
   else
     dbxout_stab_value_label (label);
-#endif
 }
 
 /* Output everything about a symbol block (a BLOCK node
@@ -3312,8 +3306,9 @@ dbx_output_rbrac (const char *label,
 static void
 dbxout_block (tree block, int depth, tree args)
 {
-  const char *begin_label
-    = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
+  char begin_label[20];
+  /* Reference current function start using LFBB.  */
+  ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", scope_labelno);
 
   while (block)
     {
@@ -3342,7 +3337,7 @@ dbxout_block (tree block, int depth, tre
 
 	      if (depth == 0)
 		/* The outermost block doesn't get LBB labels; use
-		   the function symbol.  */
+		   the LFBB local symbol emitted by dbxout_begin_prologue.  */
 		scope_start = begin_label;
 	      else
 		{
Index: gcc/config/rs6000/linux64.h
===================================================================
--- gcc/config/rs6000/linux64.h	(revision 115286)
+++ gcc/config/rs6000/linux64.h	(working copy)
@@ -486,68 +486,6 @@ extern int dot_symbols;
 		   && SCALAR_FLOAT_MODE_P (GET_MODE (X))		\
 		   && BITS_PER_WORD == HOST_BITS_PER_INT)))))
 
-/* This ABI cannot use DBX_LINES_FUNCTION_RELATIVE, nor can it use
-   dbxout_stab_value_internal_label_diff, because we must
-   use the function code label, not the function descriptor label.  */
-#define	DBX_OUTPUT_SOURCE_LINE(FILE, LINE, COUNTER)			\
-do									\
-  {									\
-    char temp[256];							\
-    const char *s;							\
-    ASM_GENERATE_INTERNAL_LABEL (temp, "LM", COUNTER);			\
-    dbxout_begin_stabn_sline (LINE);					\
-    assemble_name (FILE, temp);						\
-    putc ('-', FILE);							\
-    s = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);		\
-    rs6000_output_function_entry (FILE, s);				\
-    putc ('\n', FILE);							\
-    targetm.asm_out.internal_label (FILE, "LM", COUNTER);		\
-    COUNTER += 1;							\
-  }									\
-while (0)
-
-/* Similarly, we want the function code label here.  Cannot use
-   dbxout_stab_value_label_diff, as we have to use
-   rs6000_output_function_entry.  FIXME.  */
-#define DBX_OUTPUT_BRAC(FILE, NAME, BRAC)				\
-  do									\
-    {									\
-      const char *s;							\
-      dbxout_begin_stabn (BRAC);					\
-      s = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);		\
-      /* dbxout_block passes this macro the function name as NAME,	\
-	 assuming that it is the function code start label.  In our	\
-	 case, the function name is the OPD entry.  dbxout_block is	\
-	 broken, hack around it here.  */				\
-      if (NAME == s)							\
-	putc ('0', FILE);						\
-      else								\
-	{								\
-	  assemble_name (FILE, NAME);					\
-	  putc ('-', FILE);						\
-	  rs6000_output_function_entry (FILE, s);			\
-	}								\
-      putc ('\n', FILE);						\
-    }									\
-  while (0)
-
-#define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC)
-#define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC)
-
-/* Another case where we want the dot name.  */
-#define	DBX_OUTPUT_NFUN(FILE, LSCOPE, DECL)				\
-  do									\
-    {									\
-      const char *s;							\
-      dbxout_begin_empty_stabs (N_FUN);					\
-      assemble_name (FILE, LSCOPE);					\
-      putc ('-', FILE);							\
-      s = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);		\
-      rs6000_output_function_entry (FILE, s);				\
-      putc ('\n', FILE);						\
-    }									\
-  while (0)
-
 /* Select a format to encode pointers in exception handling data.  CODE
    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
    true if the symbol may be affected by dynamic relocations.  */


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