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]

begin_function debug hook.


The remaining hooks are more tricky than those so far.

This does begin_function.  There remain 2 functions,
sdbout_mark_begin_function() and dbxout_begin_function() that don't
fit despite their names.  I don't know enough about varasm.c and the
code in final.c to know whether there is scope for rationalisation of
these or not.  Certainly there doesn't seem to be an easy way to
integrate the two, so another hook will be needed for those.

I'd like someone to look at the dwarf2 bit of final_start_function.
I've retained the semantics, but they look a little odd.  xcoff and
sdb debug info is output, and for other debug types the source line is
output instead.  However, in the case of dwarf2, debug info is output
AND a source line is output.

Bootstrapping x86 Linux.  OK to commit?

Neil.

	* dbxout.c (dbx_debug_hooks, xcoff_debug_hooks): Update.
	* debug.c (do_nothing_debug_hooks): Update.
	* debug.h (gcc_debug_hooks): New hook begin_function.
	(dwarf2out_begin_prologue): Moved from ...
	* tree.h: ... here.
	* dwarf2out.c (dwarf2_debug_hooks): Update.
	* dwarfout.c (dwarfout_begin_function): Change prototype, make
	static.
	* dwarfout.h (dwarfout_begin_function): Remove.
	* final.c (final_start_function, final_scan_insn): Use
	begin_function() debug hook.
	* sdbout.c (sdbout_begin_function): Make static, update prototype.
	(sdbout_debug_hooks): Update.
	* sdbout.h (sdbout_begin_function): Delete.
	* xcoffout.c (xcoffout_begin_function): Update with prototype.
	* xcoffout.h (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/15 13:59:48
@@ -330,6 +330,7 @@ struct gcc_debug_hooks dbx_debug_hooks =
   dbxout_end_block,
   dbxout_source_line,
   debug_nothing_void,		/* end_epilogue */
+  debug_nothing_int, 1,		/* begin function */
   debug_nothing_int		/* end function */
 };
 #endif /* DBX_DEBUGGING_INFO  */
@@ -347,6 +348,7 @@ struct gcc_debug_hooks xcoff_debug_hooks
   xcoffout_end_block,
   xcoffout_source_line,
   xcoffout_end_epilogue,
+  xcoffout_begin_function, 1,
   xcoffout_end_function
 };
 #endif /* XCOFF_DEBUGGING_INFO  */
============================================================
Index: gcc/debug.c
--- gcc/debug.c	2001/07/15 08:34:43	1.4
+++ gcc/debug.c	2001/07/15 13:59:48
@@ -32,6 +32,7 @@ struct gcc_debug_hooks do_nothing_debug_
   debug_nothing_int_int,
   debug_nothing_charstar_rtx,
   debug_nothing_void,
+  debug_nothing_int, 1,
   debug_nothing_int
 };
 
============================================================
Index: gcc/debug.h
--- gcc/debug.h	2001/07/15 08:34:43	1.4
+++ gcc/debug.h	2001/07/15 13:59:48
@@ -60,6 +60,13 @@ struct gcc_debug_hooks
   /* Record end of epilogue code.  */
   void (* end_epilogue) PARAMS ((void));
 
+  /* Record start of function.  LINE is the first line in the
+     function.  BEGIN_FUNCTION_BEFORE_PROLOGUE is a boolean indicating
+     whether begin_function () should be called before or after the
+     assembler of the function prologue is emitted.  */
+  void (* begin_function) PARAMS ((unsigned int line));
+  int begin_function_before_prologue;
+
   /* Record end of function.  LINE is highest line number in function.  */
   void (* end_function) PARAMS ((unsigned int line));
 };
@@ -90,6 +97,8 @@ extern struct gcc_debug_hooks dwarf2_deb
 
 /* Dwarf2 frame information.  */
 
+extern void dwarf2out_begin_prologue
+  PARAMS ((void));
 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/15 14:00:59
@@ -3025,6 +3025,7 @@ struct gcc_debug_hooks dwarf2_debug_hook
   dwarf2out_end_block,
   dwarf2out_source_line,
   dwarf2out_end_epilogue,
+  debug_nothing_int, 0,		/* 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/15 14:01:18
@@ -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_begin_function	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));
@@ -1385,6 +1386,7 @@ struct gcc_debug_hooks dwarf_debug_hooks
   dwarfout_end_block,
   dwarfout_source_line,
   dwarfout_end_epilogue,
+  dwarfout_begin_function, 0,
   dwarfout_end_function
 };
 
@@ -5874,8 +5876,9 @@ 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_begin_function (line)
+     unsigned int line ATTRIBUTE_UNUSED;
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
============================================================
Index: gcc/dwarfout.h
--- gcc/dwarfout.h	2001/07/15 08:34:44	1.11
+++ gcc/dwarfout.h	2001/07/15 14:01:18
@@ -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/15 14:01:31
@@ -1589,24 +1589,10 @@ final_start_function (first, file, optim
   dwarf2out_begin_prologue ();
 #endif
 
-  /* 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
-#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 (debug_hooks->begin_function_before_prologue)
+    (*debug_hooks->begin_function) (last_linenum);
+  else if (NOTE_LINE_NUMBER (first) != NOTE_INSN_DELETED)
+    output_source_line (first);
 
 #ifdef LEAF_REG_REMAP
   if (current_function_uses_only_leaf_regs)
@@ -2079,24 +2065,11 @@ 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)
+	  if (!debug_hooks->begin_function_before_prologue)
 	    {
 	      app_disable ();
-	      dwarfout_begin_function ();
+	      (*debug_hooks->begin_function) (last_linenum);
 	    }
-#endif
 	  break;
 
 	case NOTE_INSN_BLOCK_BEG:
============================================================
Index: gcc/sdbout.c
--- gcc/sdbout.c	2001/07/15 08:34:44	1.47
+++ gcc/sdbout.c	2001/07/15 14:01:33
@@ -99,6 +99,7 @@ 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_function	PARAMS ((unsigned int));
 static void sdbout_end_function		PARAMS ((unsigned int));
 static char *gen_fake_label		PARAMS ((void));
 static int plain_type			PARAMS ((tree));
@@ -300,6 +301,13 @@ 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.  */
+  sdbout_begin_function, 0,
+#else
+  sdbout_begin_function, 1,
+#endif
   sdbout_end_function
 };
 
@@ -1555,9 +1563,9 @@ sdbout_mark_begin_function ()
    Describe beginning of outermost block.
    Also describe the parameter list.  */
 
-void
+static void
 sdbout_begin_function (line)
-     int 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/15 14:01:33
@@ -18,8 +18,6 @@ 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));
============================================================
Index: gcc/tree.h
--- gcc/tree.h	2001/07/15 08:34:45	1.255
+++ gcc/tree.h	2001/07/15 14:01:44
@@ -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/xcoffout.c
--- gcc/xcoffout.c	2001/07/15 08:34:45	1.24
+++ gcc/xcoffout.c	2001/07/15 14:01:45
@@ -437,11 +437,10 @@ xcoffout_declare_function (file, decl, n
    Record the file name that this function is contained in.  */
 
 void
-xcoffout_begin_function (file, last_linenum)
-     FILE *file;
-     int last_linenum;
+xcoffout_begin_function (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/15 14:01:45
@@ -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_function		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]