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]

3 debug hooks for begin_function


This replaces the confusingly named debug begin_function routines that
were really 3 separate concepts as rth pointed out.

Two things to note:

a) in final_start_function I do an output_source_line regardless of
   debug type.  This means that xcoff and sdb get an extra line number
   compared to previously; I'm assuming this is harmless.  It seems clearer
   than the alternative of moving the output_source_line() calls into the
   hooks, which would necessarily include the do_nothing hook.

b) For the end_prologue hook call, we do an unconditional app_disable:

	  app_disable ();
	  (*debug_hooks->end_prologue) (last_linenum);

   I didn't put this into the do-something hooks, because we
   don't seem to require any other hooks to do an app_disable(), so it
   would be inconsistent.  Further, the sdb hook is used for end_prologue
   or begin_prologue depending upon MIPS_DEBUGGING_INFO, so unless we
   conditionally compiled it in the sdb hook, we'd get an app_disable for
   non-MIPS begin_prologue() hooks.  I assume the extra app_disable()
   is harmless.

I think issues like these suggest that the current debug abstraction
is not optimal, but I'm not knowledgeable enough to improve it.

Bootstrapping x86 Linux (stage2).  OK if successful?

Neil.

	* dbxout.c (dbxout_really_begin_function): Rename to
	dbxout_begin_function.
	(dbx_debug_hooks, xcoff_debug_hooks): Update.
	(dbxout_begin_function): Remove.
	(dbxout_function): Update.
	* dbxout.h (dbxout_begin_function): Remove.
	* debug.c (do_nothing_debug_hooks): Update.
	(debug_nothing_tree): Update.
	* debug.h (union tree_node): Declare.
	(gcc_debug_hooks): New hooks begin_prologue, end_prologue,
	begin_function.
	(debug_nothing_tree): New.
	(dwarf2out_begin_prologue): Moved from ...
	* tree.h: ... here.
	* dwarf2out.c (dwarf2_debug_hooks): Update.
	(dwarf2out_begin_prologue): Update prototype.
	* dwarfout.c (dwarfout_begin_function): Rename dwarfout_end_prologue.
	Change prototype, make static.
	(dwarf_debug_hooks): Update.
	* dwarfout.h (dwarfout_begin_function): Remove.
	* final.c (final_start_function, final_scan_insn): Use appropriate
	debug hooks.
	* sdbout.c (sdbout_begin_function): Rename sdbout_begin_prologue,
	make static, update prototype.
	(sdbout_mark_begin_function): Rename sdbout_begin_function, update
	prototype.
	(sdbout_debug_hooks): Update.
	* sdbout.h (sdbout_begin_function, sdbout_mark_begin_function):
	Delete.
	* varasm.c (assemble_start_function): Use begin_function debug_hook.
	* xcoffout.c (xcoffout_begin_prologue): Rename xcoffout_begin_function,
	update with prototype.
	* xcoffout.h (xcoffout_begin_prologue): Rename xcoffout_begin_function,
	update prototype.

============================================================
Index: gcc/dbxout.c
--- gcc/dbxout.c	2001/07/15 08:34:42	1.91
+++ gcc/dbxout.c	2001/07/16 19:20:55
@@ -310,7 +310,7 @@ static void dbxout_symbol_name		PARAMS (
 static void dbxout_prepare_symbol	PARAMS ((tree));
 static void dbxout_finish_symbol	PARAMS ((tree));
 static void dbxout_block		PARAMS ((tree, int, tree));
-static void dbxout_really_begin_function PARAMS ((tree));
+static void dbxout_begin_function	PARAMS ((tree));
 
 /* The debug hooks structure.  */
 #if defined (DBX_DEBUGGING_INFO)
@@ -329,8 +329,15 @@ struct gcc_debug_hooks dbx_debug_hooks =
   dbxout_begin_block,
   dbxout_end_block,
   dbxout_source_line,
+  debug_nothing_int,		/* begin_prologue */
+  debug_nothing_int,		/* end_prologue */
   debug_nothing_void,		/* end_epilogue */
-  debug_nothing_int		/* end function */
+#ifdef DBX_FUNCTION_FIRST
+  dbxout_begin_function,
+#else
+  debug_nothing_tree,		/* begin_function */
+#endif
+  debug_nothing_int		/* end_function */
 };
 #endif /* DBX_DEBUGGING_INFO  */
 
@@ -346,7 +353,10 @@ struct gcc_debug_hooks xcoff_debug_hooks
   xcoffout_begin_block,
   xcoffout_end_block,
   xcoffout_source_line,
+  xcoffout_begin_prologue,	/* begin_prologue */
+  debug_nothing_int,		/* end_prologue */
   xcoffout_end_epilogue,
+  debug_nothing_tree,		/* begin_function */
   xcoffout_end_function
 };
 #endif /* XCOFF_DEBUGGING_INFO  */
@@ -2716,7 +2726,7 @@ dbxout_block (block, depth, args)
    but on some systems, it comes before.  */
 
 static void
-dbxout_really_begin_function (decl)
+dbxout_begin_function (decl)
      tree decl;
 {
   dbxout_symbol (decl, 0);
@@ -2725,17 +2735,6 @@ dbxout_really_begin_function (decl)
     dbxout_symbol (DECL_RESULT (decl), 1);
 }
 
-/* Called at beginning of output of function definition.  */
-
-void
-dbxout_begin_function (decl)
-     tree decl ATTRIBUTE_UNUSED;
-{
-#ifdef DBX_FUNCTION_FIRST
-  dbxout_really_begin_function (decl);
-#endif
-}
-
 /* Output dbx data for a function definition.
    This includes a definition of the function name itself (a symbol),
    definitions of the parameters (locating them in the parameter list)
@@ -2747,7 +2746,7 @@ dbxout_function (decl)
      tree decl;
 {
 #ifndef DBX_FUNCTION_FIRST
-  dbxout_really_begin_function (decl);
+  dbxout_begin_function (decl);
 #endif
   dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
 #ifdef DBX_OUTPUT_FUNCTION_END
============================================================
Index: gcc/dbxout.h
--- gcc/dbxout.h	2001/07/15 08:34:43	1.10
+++ gcc/dbxout.h	2001/07/16 19:20:55
@@ -26,4 +26,3 @@ extern void dbxout_parms		PARAMS ((tree)
 extern void dbxout_reg_parms		PARAMS ((tree));
 extern int dbxout_syms			PARAMS ((tree));
 extern void dbxout_function		PARAMS ((tree));
-extern void dbxout_begin_function	PARAMS ((tree));
============================================================
Index: gcc/debug.c
--- gcc/debug.c	2001/07/15 08:34:43	1.4
+++ gcc/debug.c	2001/07/16 19:20:55
@@ -31,8 +31,11 @@ struct gcc_debug_hooks do_nothing_debug_
   debug_nothing_int_int,
   debug_nothing_int_int,
   debug_nothing_charstar_rtx,
-  debug_nothing_void,
-  debug_nothing_int
+  debug_nothing_int,		/* begin_prologue */
+  debug_nothing_int,		/* end_prologue */
+  debug_nothing_void,		/* end_epilogue */
+  debug_nothing_tree,		/* begin_function */
+  debug_nothing_int		/* end_function */
 };
 
 /* This file contains implementations of each debug hook that do
@@ -40,6 +43,12 @@ struct gcc_debug_hooks do_nothing_debug_
 
 void
 debug_nothing_void ()
+{
+}
+
+void
+debug_nothing_tree (decl)
+     union tree_node *decl ATTRIBUTE_UNUSED;
 {
 }
 
============================================================
Index: gcc/debug.h
--- gcc/debug.h	2001/07/15 08:34:43	1.4
+++ gcc/debug.h	2001/07/16 19:20:55
@@ -18,6 +18,7 @@ Foundation, 59 Temple Place - Suite 330,
 #ifndef GCC_DEBUG_H
 #define GCC_DEBUG_H
 
+union tree_node;
 struct rtx_def;
 
 /* This structure contains hooks for the debug information output
@@ -57,9 +58,20 @@ struct gcc_debug_hooks
      NOTE_LINE_NUMBER (note).  */
   void (* source_line) PARAMS ((const char *filename, struct rtx_def *note));
 
+  /* Called at start of prologue code.  LINE is the first line in the
+     function.  */
+  void (* begin_prologue) PARAMS ((unsigned int line));
+
+  /* Called at end of prologue code.  LINE is the first line in the
+     function.  */
+  void (* end_prologue) PARAMS ((unsigned int line));
+
   /* Record end of epilogue code.  */
   void (* end_epilogue) PARAMS ((void));
 
+  /* Called at start of function DECL, before it is declared.  */
+  void (* begin_function) PARAMS ((union tree_node *decl));
+
   /* Record end of function.  LINE is highest line number in function.  */
   void (* end_function) PARAMS ((unsigned int line));
 };
@@ -77,6 +89,8 @@ extern void debug_nothing_int
   PARAMS ((unsigned int));
 extern void debug_nothing_int_int
   PARAMS ((unsigned int, unsigned int));
+extern void debug_nothing_tree
+  PARAMS ((union tree_node *));
 extern void debug_nothing_charstar_rtx
   PARAMS ((const char *, struct rtx_def *));
 
@@ -90,6 +104,8 @@ extern struct gcc_debug_hooks dwarf2_deb
 
 /* Dwarf2 frame information.  */
 
+extern void dwarf2out_begin_prologue
+  PARAMS ((unsigned int));
 extern void dwarf2out_end_epilogue
   PARAMS ((void));
 
============================================================
Index: gcc/dwarf2out.c
--- gcc/dwarf2out.c	2001/07/15 08:34:43	1.290
+++ gcc/dwarf2out.c	2001/07/16 19:21:19
@@ -1999,7 +1999,8 @@ output_call_frame_info (for_eh)
    the prologue.  */
 
 void
-dwarf2out_begin_prologue ()
+dwarf2out_begin_prologue (line)
+     unsigned int line ATTRIBUTE_UNUSED;
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
   register dw_fde_ref fde;
@@ -3024,7 +3025,10 @@ struct gcc_debug_hooks dwarf2_debug_hook
   dwarf2out_begin_block,
   dwarf2out_end_block,
   dwarf2out_source_line,
+  dwarf2out_begin_prologue,
+  debug_nothing_int,		/* end_prologue */
   dwarf2out_end_epilogue,
+  debug_nothing_tree,		/* begin_function */
   debug_nothing_int		/* end_function */
 };
 
============================================================
Index: gcc/dwarfout.c
--- gcc/dwarfout.c	2001/07/15 08:34:44	1.90
+++ gcc/dwarfout.c	2001/07/16 19:21:36
@@ -799,6 +799,7 @@ static void dwarfout_begin_block	PARAMS 
 static void dwarfout_end_block		PARAMS ((unsigned, unsigned));
 static void dwarfout_end_epilogue	PARAMS ((void));
 static void dwarfout_source_line	PARAMS (( const char *, rtx));
+static void dwarfout_end_prologue	PARAMS ((unsigned int));
 static void dwarfout_end_function	PARAMS ((unsigned int));
 static const char *dwarf_tag_name	PARAMS ((unsigned));
 static const char *dwarf_attr_name	PARAMS ((unsigned));
@@ -1384,7 +1385,10 @@ struct gcc_debug_hooks dwarf_debug_hooks
   dwarfout_begin_block,
   dwarfout_end_block,
   dwarfout_source_line,
+  debug_nothing_int,		/* begin_prologue */
+  dwarfout_end_prologue,
   dwarfout_end_epilogue,
+  debug_nothing_tree,		/* begin_function */
   dwarfout_end_function
 };
 
@@ -5874,13 +5878,15 @@ dwarfout_end_block (line, blocknum)
    the real body of the function begins (after parameters have been moved
    to their home locations).  */
 
-void
-dwarfout_begin_function ()
+static void
+dwarfout_end_prologue (line)
+     unsigned int line ATTRIBUTE_UNUSED;
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
   if (! use_gnu_debug_info_extensions)
     return;
+
   function_section (current_function_decl);
   sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
   ASM_OUTPUT_LABEL (asm_out_file, label);
============================================================
Index: gcc/dwarfout.h
--- gcc/dwarfout.h	2001/07/15 08:34:44	1.11
+++ gcc/dwarfout.h	2001/07/16 19:21:37
@@ -19,5 +19,3 @@ the Free Software Foundation, 59 Temple 
 Boston, MA 02111-1307, USA.  */
 
 extern void dwarfout_file_scope_decl 	PARAMS ((tree , int));
-
-extern void dwarfout_begin_function	PARAMS ((void));
============================================================
Index: gcc/final.c
--- gcc/final.c	2001/07/15 08:34:44	1.184
+++ gcc/final.c	2001/07/16 19:21:49
@@ -1584,30 +1584,16 @@ final_start_function (first, file, optim
     last_linenum = high_block_linenum = high_function_linenum
       = NOTE_LINE_NUMBER (first);
 
-#if defined (DWARF2_UNWIND_INFO) || defined (IA64_UNWIND_INFO) \
-    || defined (DWARF2_DEBUGGING_INFO)
-  dwarf2out_begin_prologue ();
-#endif
+  (*debug_hooks->begin_prologue) (last_linenum);
 
-  /* For SDB and XCOFF, the function beginning must be marked between
-     the function label and the prologue.  We always need this, even when
-     -g1 was used.  Defer on MIPS systems so that parameter descriptions
-     follow function entry.  */
-#if defined(SDB_DEBUGGING_INFO) && !defined(MIPS_DEBUGGING_INFO)
-  if (write_symbols == SDB_DEBUG)
-    sdbout_begin_function (last_linenum);
-  else
+#if defined (DWARF2_UNWIND_INFO) || defined (IA64_UNWIND_INFO)
+  if (write_symbols != DWARF2_DEBUG)
+    dwarf2out_begin_prologue (last_linenum);
 #endif
-#ifdef XCOFF_DEBUGGING_INFO
-    if (write_symbols == XCOFF_DEBUG)
-      xcoffout_begin_function (file, last_linenum);
-    else
-#endif
-      /* But only output line number for other debug info types if -g2
-	 or better.  */
-      if (NOTE_LINE_NUMBER (first) != NOTE_INSN_DELETED)
-	output_source_line (first);
 
+  if (NOTE_LINE_NUMBER (first) != NOTE_INSN_DELETED)
+    output_source_line (first);
+
 #ifdef LEAF_REG_REMAP
   if (current_function_uses_only_leaf_regs)
     leaf_renumber_regs (first);
@@ -2079,24 +2065,8 @@ final_scan_insn (insn, file, optimize, p
 	  break;
 
 	case NOTE_INSN_FUNCTION_BEG:
-#if defined(SDB_DEBUGGING_INFO) && defined(MIPS_DEBUGGING_INFO)
-	  /* MIPS stabs require the parameter descriptions to be after the
-	     function entry point rather than before.  */
-	  if (write_symbols == SDB_DEBUG)
-	    {
-	      app_disable ();
-	      sdbout_begin_function (last_linenum);
-	    }
-#endif
-#ifdef DWARF_DEBUGGING_INFO
-	  /* This outputs a marker where the function body starts, so it
-	     must be after the prologue.  */
-	  if (write_symbols == DWARF_DEBUG)
-	    {
-	      app_disable ();
-	      dwarfout_begin_function ();
-	    }
-#endif
+	  app_disable ();
+	  (*debug_hooks->end_prologue) (last_linenum);
 	  break;
 
 	case NOTE_INSN_BLOCK_BEG:
============================================================
Index: gcc/sdbout.c
--- gcc/sdbout.c	2001/07/16 06:01:40	1.48
+++ gcc/sdbout.c	2001/07/16 19:21:57
@@ -99,6 +99,8 @@ static void sdbout_begin_block		PARAMS (
 static void sdbout_end_block		PARAMS ((unsigned, unsigned));
 static void sdbout_source_line		PARAMS ((const char *, rtx));
 static void sdbout_end_epilogue		PARAMS ((void));
+static void sdbout_begin_prologue	PARAMS ((unsigned int));
+static void sdbout_begin_function	PARAMS ((tree));
 static void sdbout_end_function		PARAMS ((unsigned int));
 static char *gen_fake_label		PARAMS ((void));
 static int plain_type			PARAMS ((tree));
@@ -300,6 +302,16 @@ struct gcc_debug_hooks sdb_debug_hooks =
   sdbout_end_block,
   sdbout_source_line,
   sdbout_end_epilogue,
+#ifdef MIPS_DEBUGGING_INFO
+  /* Defer on MIPS systems so that parameter descriptions follow
+     function entry.  */
+  debug_nothing_int,		/* begin_prologue */
+  sdbout_begin_prologue,	/* end_prologue hook */
+#else
+  sdbout_begin_prologue,	/* begin_prologue */
+  debug_nothing_int,		/* end_prologue */
+#endif
+  sdbout_begin_function,
   sdbout_end_function
 };
 
@@ -1543,21 +1555,22 @@ sdbout_source_line (filename, note)
 /* Output sdb info for the current function name.
    Called from assemble_start_function.  */
 
-void
-sdbout_mark_begin_function ()
+static void
+sdbout_begin_function (decl)
+     tree decl ATTRIBUTE_UNUSED;
 {
   sdbout_symbol (current_function_decl, 0);
 }
 
-/* Called at beginning of function body (after prologue).
-   Record the function's starting line number, so we can output
-   relative line numbers for the other lines.
-   Describe beginning of outermost block.
-   Also describe the parameter list.  */
+/* Called at beginning of function body (before or after prologue,
+   depending on MIPS_DEBUGGING_INFO).  Record the function's starting
+   line number, so we can output relative line numbers for the other
+   lines.  Describe beginning of outermost block.  Also describe the
+   parameter list.  */
 
-void
-sdbout_begin_function (line)
-     int line;
+static void
+sdbout_begin_prologue (line)
+     unsigned int line;
 {
   sdb_begin_function_line = line - 1;
   PUT_SDB_FUNCTION_START (line);
============================================================
Index: gcc/sdbout.h
--- gcc/sdbout.h	2001/07/15 08:34:45	1.10
+++ gcc/sdbout.h	2001/07/16 19:21:57
@@ -18,12 +18,7 @@ along with GNU CC; see the file COPYING.
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-extern void sdbout_begin_function	PARAMS ((int));
-
 extern void sdbout_label		PARAMS ((rtx));
 extern void sdbout_symbol		PARAMS ((tree, int));
 extern void sdbout_toplevel_data	PARAMS ((tree));
 extern void sdbout_types		PARAMS ((tree));
-
-extern void sdbout_mark_begin_function	PARAMS ((void));
-
============================================================
Index: gcc/tree.h
--- gcc/tree.h	2001/07/15 08:34:45	1.255
+++ gcc/tree.h	2001/07/16 19:22:04
@@ -2919,11 +2919,6 @@ extern void dwarf2out_return_save	PARAMS
 
 extern void dwarf2out_return_reg	PARAMS ((const char *, unsigned));
 
-/* Output a marker (i.e. a label) for the beginning of a function, before
-   the prologue.  */
-
-extern void dwarf2out_begin_prologue	PARAMS ((void));
-
 
 /* Redefine abort to report an internal error w/o coredump, and
    reporting the location of the error in the source file.  This logic
============================================================
Index: gcc/varasm.c
--- gcc/varasm.c	2001/06/04 13:21:38	1.176
+++ gcc/varasm.c	2001/07/16 19:22:26
@@ -47,6 +47,7 @@ Boston, MA 02111-1307, USA.  */
 #include "c-pragma.h"
 #include "ggc.h"
 #include "tm_p.h"
+#include "debug.h"
 
 #ifdef XCOFF_DEBUGGING_INFO
 #include "xcoffout.h"
@@ -947,17 +948,7 @@ assemble_start_function (decl, fnname)
   ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
 #endif
 
-#ifdef SDB_DEBUGGING_INFO
-  /* Output SDB definition of the function.  */
-  if (write_symbols == SDB_DEBUG)
-    sdbout_mark_begin_function ();
-#endif
-
-#ifdef DBX_DEBUGGING_INFO
-  /* Output DBX definition of the function.  */
-  if (write_symbols == DBX_DEBUG)
-    dbxout_begin_function (decl);
-#endif
+  (*debug_hooks->begin_function) (decl);
 
   /* Make function name accessible from other files, if appropriate.  */
 
============================================================
Index: gcc/xcoffout.c
--- gcc/xcoffout.c	2001/07/15 08:34:45	1.24
+++ gcc/xcoffout.c	2001/07/16 19:22:26
@@ -431,17 +431,16 @@ xcoffout_declare_function (file, decl, n
 	   name, name, name, name);
 }
 
-/* Called at beginning of function body (after prologue).
+/* Called at beginning of function body (at start of prologue).
    Record the function's starting line number, so we can output
    relative line numbers for the other lines.
    Record the file name that this function is contained in.  */
 
 void
-xcoffout_begin_function (file, last_linenum)
-     FILE *file;
-     int last_linenum;
+xcoffout_begin_prologue (last_linenum)
+     unsigned int last_linenum;
 {
-  ASM_OUTPUT_LFB (file, last_linenum);
+  ASM_OUTPUT_LFB (asm_out_file, last_linenum);
   dbxout_parms (DECL_ARGUMENTS (current_function_decl));
 
   /* Emit the symbols for the outermost BLOCK's variables.  sdbout.c does this
@@ -452,7 +451,7 @@ xcoffout_begin_function (file, last_line
   xcoffout_block (DECL_INITIAL (current_function_decl), 0,
 		  DECL_ARGUMENTS (current_function_decl));
 
-  ASM_OUTPUT_SOURCE_LINE (file, last_linenum);
+  ASM_OUTPUT_SOURCE_LINE (asm_out_file, last_linenum);
 }
 
 /* Called at end of function (before epilogue).
============================================================
Index: gcc/xcoffout.h
--- gcc/xcoffout.h	2001/07/15 08:34:46	1.13
+++ gcc/xcoffout.h	2001/07/16 19:22:26
@@ -199,7 +199,7 @@ extern const char *xcoff_lastfile;
 
 extern int stab_to_sclass			PARAMS ((int));
 #ifdef BUFSIZ
-extern void xcoffout_begin_function		PARAMS ((FILE *, int));
+extern void xcoffout_begin_prologue		PARAMS ((unsigned int));
 extern void xcoffout_begin_block		PARAMS ((unsigned, unsigned));
 extern void xcoffout_end_epilogue		PARAMS ((void));
 extern void xcoffout_end_function		PARAMS ((unsigned int));


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