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]

Debug hooks function_decl, global_decl.


Two more hooks that simplify toplev.c further.

I'll start an x86 Linux bootstrap of this soon, and check the
non-linux debug formats compile.

Neil.

	* dbxout.c (dbxout_function): Rename dbxout_funciton_decl, move
	to conditionally compiled block.
	(dbx_debug_hooks, xcoff_debug_hooks): Update.
	* dbxout.h (dbxout_function): Remove.
	* debug.c (do_nothing_debug_hooks): Update.
	* debug.h (struct gcc_debug_hooks): New hooks function_decl,
	global_decl.
	* dwarf2out.c (dwarf2_debug_hooks): Update.
	(dwarf2out_global_decl): New.
	* dwarf2out.c (dwarfout_global_decl, dwarfout_function_decl): New.
	(dwarf_debug_hooks): Update.
	* sdbout.c (sdbout_global_decl): New.
	(sdbout_debug_hooks): Update.
	* toplev.c (check_global_declarations, rest_of_compilation): Use
	new debug hooks.

============================================================
Index: gcc/dbxout.c
--- gcc/dbxout.c	2001/07/17 19:47:57	1.92
+++ gcc/dbxout.c	2001/07/17 22:08:06
@@ -317,6 +317,7 @@ static void dbxout_begin_function	PARAMS
 
 static void dbxout_begin_block		PARAMS ((unsigned, unsigned));
 static void dbxout_end_block		PARAMS ((unsigned, unsigned));
+static void dbxout_function_decl	PARAMS ((tree));
 
 struct gcc_debug_hooks dbx_debug_hooks =
 {
@@ -337,7 +338,9 @@ struct gcc_debug_hooks dbx_debug_hooks =
 #else
   debug_nothing_tree,		/* begin_function */
 #endif
-  debug_nothing_int		/* end_function */
+  debug_nothing_int,		/* end_function */
+  dbxout_function_decl,
+  debug_nothing_tree		/* global_decl */
 };
 #endif /* DBX_DEBUGGING_INFO  */
 
@@ -357,7 +360,9 @@ struct gcc_debug_hooks xcoff_debug_hooks
   debug_nothing_int,		/* end_prologue */
   xcoffout_end_epilogue,
   debug_nothing_tree,		/* begin_function */
-  xcoffout_end_function
+  xcoffout_end_function,
+  debug_nothing_tree,		/* function_decl */
+  debug_nothing_tree		/* global_decl */
 };
 #endif /* XCOFF_DEBUGGING_INFO  */
 
@@ -608,6 +613,33 @@ dbxout_end_block (line, n)
   ASM_OUTPUT_INTERNAL_LABEL (asmfile, "LBE", n);
 }
 
+/* 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)
+   and then output the block that makes up the function's body
+   (including all the auto variables of the function).  */
+
+static void
+dbxout_function_decl (decl)
+     tree decl;
+{
+#ifndef DBX_FUNCTION_FIRST
+  dbxout_begin_function (decl);
+#endif
+  dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
+#ifdef DBX_OUTPUT_FUNCTION_END
+  DBX_OUTPUT_FUNCTION_END (asmfile, decl);
+#endif
+#if defined(ASM_OUTPUT_SECTION_NAME)
+  if (use_gnu_debug_info_extensions
+#if defined(NO_DBX_FUNCTION_END)
+      && ! NO_DBX_FUNCTION_END
+#endif
+      )
+    dbxout_function_end ();
+#endif
+}
+
 #endif /* DBX_DEBUGGING_INFO  */
 
 /* At the end of compilation, finish writing the symbol table.
@@ -2733,30 +2765,4 @@ dbxout_begin_function (decl)
     dbxout_symbol (DECL_RESULT (decl), 1);
 }
 
-/* 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)
-   and then output the block that makes up the function's body
-   (including all the auto variables of the function).  */
-
-void
-dbxout_function (decl)
-     tree decl;
-{
-#ifndef DBX_FUNCTION_FIRST
-  dbxout_begin_function (decl);
-#endif
-  dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
-#ifdef DBX_OUTPUT_FUNCTION_END
-  DBX_OUTPUT_FUNCTION_END (asmfile, decl);
-#endif
-#if defined(ASM_OUTPUT_SECTION_NAME)
-  if (use_gnu_debug_info_extensions
-#if defined(NO_DBX_FUNCTION_END)
-      && ! NO_DBX_FUNCTION_END
-#endif
-      )
-    dbxout_function_end ();
-#endif
-}
 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
============================================================
Index: gcc/dbxout.h
--- gcc/dbxout.h	2001/07/17 19:47:57	1.11
+++ gcc/dbxout.h	2001/07/17 22:08:06
@@ -25,4 +25,3 @@ extern int dbxout_symbol		PARAMS ((tree,
 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));
============================================================
Index: gcc/debug.c
--- gcc/debug.c	2001/07/17 19:47:57	1.5
+++ gcc/debug.c	2001/07/17 22:08:06
@@ -35,7 +35,9 @@ struct gcc_debug_hooks do_nothing_debug_
   debug_nothing_int,		/* end_prologue */
   debug_nothing_void,		/* end_epilogue */
   debug_nothing_tree,		/* begin_function */
-  debug_nothing_int		/* end_function */
+  debug_nothing_int,		/* end_function */
+  debug_nothing_tree,		/* function_decl */
+  debug_nothing_tree		/* global_decl */
 };
 
 /* This file contains implementations of each debug hook that do
============================================================
Index: gcc/debug.h
--- gcc/debug.h	2001/07/17 19:47:57	1.5
+++ gcc/debug.h	2001/07/17 22:08:06
@@ -73,6 +73,16 @@ struct gcc_debug_hooks
 
   /* Record end of function.  LINE is highest line number in function.  */
   void (* end_function) PARAMS ((unsigned int line));
+
+  /* Debug information for a function DECL.  This might include the
+     function name (a symbol), its parameters, and the block that
+     makes up the function's body, and the local variables of the
+     function.  */
+  void (* function_decl) PARAMS ((union tree_node *decl));
+
+  /* Debug information for a global DECL.  Called from toplev.c after
+     compilation proper has finished.  */
+  void (* global_decl) PARAMS ((union tree_node *decl));
 };
 
 extern struct gcc_debug_hooks *debug_hooks;
============================================================
Index: gcc/dwarf2out.c
--- gcc/dwarf2out.c	2001/07/17 19:47:57	1.291
+++ gcc/dwarf2out.c	2001/07/17 22:08:40
@@ -3022,6 +3022,7 @@ static void dwarf2out_start_source_file	
 static void dwarf2out_end_source_file	PARAMS ((unsigned));
 static void dwarf2out_begin_block	PARAMS ((unsigned, unsigned));
 static void dwarf2out_end_block		PARAMS ((unsigned, unsigned));
+static void dwarf2out_global_decl	PARAMS ((tree));
 
 /* The debug hooks structure.  */
 
@@ -3040,7 +3041,9 @@ struct gcc_debug_hooks dwarf2_debug_hook
   debug_nothing_int,		/* end_prologue */
   dwarf2out_end_epilogue,
   debug_nothing_tree,		/* begin_function */
-  debug_nothing_int		/* end_function */
+  debug_nothing_int,		/* end_function */
+  dwarf2out_decl,		/* function_decl */
+  dwarf2out_global_decl
 };
 
 /* NOTE: In the comments in this file, many references are made to
@@ -11006,6 +11009,21 @@ dwarf2out_add_library_unit_info (filenam
       add_AT_unsigned (unit_die, DW_AT_decl_file, file_index);
       add_pubname (context_list_decl, unit_die);
     }
+}
+
+/* Debug information for a global DECL.  Called from toplev.c after
+   compilation proper has finished.  */
+static void
+dwarf2out_global_decl (decl)
+     tree decl;
+{
+  /* Output DWARF2 information for file-scope tentative data object
+     declarations, file-scope (extern) function declarations (which
+     had no corresponding body) and file-scope tagged type
+     declarations and definitions which have not yet been forced out.  */
+
+  if (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))
+    dwarf2out_decl (decl);
 }
 
 /* Write the debugging output for DECL.  */
============================================================
Index: gcc/dwarfout.c
--- gcc/dwarfout.c	2001/07/17 19:47:57	1.91
+++ gcc/dwarfout.c	2001/07/17 22:08:59
@@ -801,6 +801,8 @@ static void dwarfout_end_epilogue	PARAMS
 static void dwarfout_source_line	PARAMS ((unsigned int, const char *));
 static void dwarfout_end_prologue	PARAMS ((unsigned int));
 static void dwarfout_end_function	PARAMS ((unsigned int));
+static void dwarfout_function_decl	PARAMS ((tree));
+static void dwarfout_global_decl	PARAMS ((tree));
 static const char *dwarf_tag_name	PARAMS ((unsigned));
 static const char *dwarf_attr_name	PARAMS ((unsigned));
 static const char *dwarf_stack_op_name	PARAMS ((unsigned));
@@ -1389,7 +1391,9 @@ struct gcc_debug_hooks dwarf_debug_hooks
   dwarfout_end_prologue,
   dwarfout_end_epilogue,
   debug_nothing_tree,		/* begin_function */
-  dwarfout_end_function
+  dwarfout_end_function,
+  dwarfout_function_decl,
+  dwarfout_global_decl
 };
 
 /************************ general utility functions **************************/
@@ -5631,6 +5635,29 @@ output_decl (decl, containing_scope)
     }
 }
 
+/* Output debug information for a function.  */
+static void
+dwarfout_function_decl (decl)
+     tree decl;
+{
+  dwarfout_file_scope_decl (decl, 0);
+}
+
+/* Debug information for a global DECL.  Called from toplev.c after
+   compilation proper has finished.  */
+static void
+dwarfout_global_decl (decl)
+     tree decl;
+{
+  /* Output DWARF information for file-scope tentative data object
+     declarations, file-scope (extern) function declarations (which
+     had no corresponding body) and file-scope tagged type
+     declarations and definitions which have not yet been forced out.  */
+
+  if (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))
+    dwarfout_file_scope_decl (decl, 1);
+}
+
 void
 dwarfout_file_scope_decl (decl, set_finalizing)
      register tree decl;
============================================================
Index: gcc/sdbout.c
--- gcc/sdbout.c	2001/07/17 19:47:57	1.49
+++ gcc/sdbout.c	2001/07/17 22:09:06
@@ -99,6 +99,7 @@ static void sdbout_begin_block		PARAMS (
 static void sdbout_end_block		PARAMS ((unsigned, unsigned));
 static void sdbout_source_line		PARAMS ((unsigned int, const char *));
 static void sdbout_end_epilogue		PARAMS ((void));
+static void sdbout_global_decl		PARAMS ((tree));
 #ifndef MIPS_DEBUGGING_INFO
 static void sdbout_begin_prologue	PARAMS ((unsigned int, const char *));
 #endif
@@ -315,7 +316,9 @@ struct gcc_debug_hooks sdb_debug_hooks =
 #endif
   sdbout_end_epilogue,
   sdbout_begin_function,
-  sdbout_end_function
+  sdbout_end_function,
+  debug_nothing_tree,		/* function_decl */
+  sdbout_global_decl
 };
 
 #if 0
@@ -1470,6 +1473,32 @@ sdbout_reg_parms (parms)
 	      }
 	  }
       }
+}
+
+/* Output debug information for a global DECL.  Called from toplev.c
+   after compilation proper has finished.  */
+
+static void
+sdbout_global_decl (decl)
+     tree decl;
+{
+  if (TREE_CODE (decl) == VAR_DECL
+      && DECL_INITIAL (decl)
+      && ! DECL_EXTERNAL (decl)
+      && DECL_RTL (decl) != 0)
+    {
+      /* The COFF linker can move initialized global vars to the end.
+	 And that can screw up the symbol ordering.  By putting the
+	 symbols in that order to begin with, we avoid a problem.
+	 mcsun!unido!fauern!tumuc!pes@uunet.uu.net.  */
+      if (TREE_PUBLIC (decl))
+	sdbout_symbol (decl, 0);
+
+      /* Output COFF information for non-global file-scope initialized
+	 variables.  */
+      if (GET_CODE (DECL_RTL (decl)) == MEM)
+	sdbout_toplevel_data (decl);
+    }
 }
 
 /* Describe the beginning of an internal block within a function.
============================================================
Index: gcc/toplev.c
--- gcc/toplev.c	2001/07/16 20:54:44	1.492
+++ gcc/toplev.c	2001/07/17 22:09:21
@@ -2059,47 +2059,7 @@ check_global_declarations (vec, len)
 	warning_with_decl (decl, "`%s' defined but not used");
 
       timevar_push (TV_SYMOUT);
-#ifdef SDB_DEBUGGING_INFO
-      /* The COFF linker can move initialized global vars to the end.
-	 And that can screw up the symbol ordering.
-	 By putting the symbols in that order to begin with,
-	 we avoid a problem.  mcsun!unido!fauern!tumuc!pes@uunet.uu.net.  */
-      if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
-	  && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
-	  && ! DECL_EXTERNAL (decl)
-	  && DECL_RTL (decl) != 0)
-	sdbout_symbol (decl, 0);
-
-      /* Output COFF information for non-global
-	 file-scope initialized variables.  */
-      if (write_symbols == SDB_DEBUG
-	  && TREE_CODE (decl) == VAR_DECL
-	  && DECL_INITIAL (decl)
-	  && ! DECL_EXTERNAL (decl)
-	  && DECL_RTL (decl) != 0
-	  && GET_CODE (DECL_RTL (decl)) == MEM)
-	sdbout_toplevel_data (decl);
-#endif /* SDB_DEBUGGING_INFO  */
-#ifdef DWARF_DEBUGGING_INFO
-      /* Output DWARF information for file-scope tentative data object
-	 declarations, file-scope (extern) function declarations (which
-	 had no corresponding body) and file-scope tagged type declarations
-	 and definitions which have not yet been forced out.  */
-
-      if (write_symbols == DWARF_DEBUG
-	  && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
-	dwarfout_file_scope_decl (decl, 1);
-#endif
-#ifdef DWARF2_DEBUGGING_INFO
-      /* Output DWARF2 information for file-scope tentative data object
-	 declarations, file-scope (extern) function declarations (which
-	 had no corresponding body) and file-scope tagged type declarations
-	 and definitions which have not yet been forced out.  */
-
-      if (write_symbols == DWARF2_DEBUG
-	  && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
-	dwarf2out_decl (decl);
-#endif
+      (*debug_hooks->global_decl) (decl);
       timevar_pop (TV_SYMOUT);
     }
 }
@@ -3802,20 +3762,7 @@ rest_of_compilation (decl)
      generated.  During that call, we *will* be routed past here.  */
 
   timevar_push (TV_SYMOUT);
-#ifdef DBX_DEBUGGING_INFO
-  if (write_symbols == DBX_DEBUG)
-    dbxout_function (decl);
-#endif
-
-#ifdef DWARF_DEBUGGING_INFO
-  if (write_symbols == DWARF_DEBUG)
-    dwarfout_file_scope_decl (decl, 0);
-#endif
-
-#ifdef DWARF2_DEBUGGING_INFO
-  if (write_symbols == DWARF2_DEBUG)
-    dwarf2out_decl (decl);
-#endif
+  (*debug_hooks->function_decl) (decl);
   timevar_pop (TV_SYMOUT);
 
  exit_rest_of_compilation:


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