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]

stabs and #define/#undef


Support for recording, in dwarf2, the macro define and undefine lines
found in a source file was added in 2001.  At EMC there was desire to
have this same functionality, but we use STABS not DWARF2.

Here's an implementation for STABS.  We've been using this with 3.3.2
and now 3.4.6 for quite some time with no problems whatsoever.

A full build of target i686-pc-linux-gnu native passes the testsuite
with no regressions.

Here's a ChangeLog and a patch:

2006-10-06  David Taylor  <dtaylor@emc.com>

	* c-lex.c (init_c_lex):  Set debug callbacks for DBX_DEBUG also,
	as it's now implemented.
	* dbxout.c (dbxout_define, dbxout_undef):  New functions.
	(dbx_debug_hooks):  Add initializations for dbxout_define and
	dbxout_undef.
	* stab.def (N_MAC_DEFINE, N_MAC_UNDEF):  Define.

Index: gcc/c-lex.c
===================================================================
--- gcc/c-lex.c	(revision 117374)
+++ gcc/c-lex.c	(working copy)
@@ -102,6 +102,7 @@
   /* Set the debug callbacks if we can use them.  */
   if (debug_info_level == DINFO_LEVEL_VERBOSE
       && (write_symbols == DWARF2_DEBUG
+          || write_symbols == DBX_DEBUG
 	  || write_symbols == VMS_AND_DWARF2_DEBUG))
     {
       cb->define = cb_define;
Index: gcc/dbxout.c
===================================================================
--- gcc/dbxout.c	(revision 117374)
+++ gcc/dbxout.c	(working copy)
@@ -312,6 +312,8 @@
 static void dbxout_init (const char *);
  
 static void dbxout_finish (const char *);
+static void dbxout_define (unsigned, const char *);
+static void dbxout_undef (unsigned, const char *);
 static void dbxout_start_source_file (unsigned, const char *);
 static void dbxout_end_source_file (unsigned);
 static void dbxout_typedefs (tree);
@@ -348,8 +350,8 @@
 {
   dbxout_init,
   dbxout_finish,
-  debug_nothing_int_charstar,
-  debug_nothing_int_charstar,
+  dbxout_define,
+  dbxout_undef,
   dbxout_start_source_file,
   dbxout_end_source_file,
   dbxout_begin_block,
@@ -1147,6 +1149,34 @@
 emit_pending_bincls_if_required (void) {}
 #endif
 
+/* Called from debug_define in toplev.c.  The `buffer' parameter contains
+   the tail part of the directive line, i.e. the part which is past the
+   initial whitespace, #, whitespace, directive-name, whitespace part.  */
+
+static void
+dbxout_define (unsigned lineno, const char *buffer)
+{
+  if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+    {
+      dbxout_begin_simple_stabs_desc (buffer, N_MAC_DEFINE, lineno);
+      dbxout_stab_value_zero ();
+    }
+}
+
+/* Called from debug_undef in toplev.c.  The `buffer' parameter contains
+   the tail part of the directive line, i.e. the part which is past the
+   initial whitespace, #, whitespace, directive-name, whitespace part.  */
+
+static void
+dbxout_undef (unsigned lineno, const char *buffer)
+{
+  if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+    {
+      dbxout_begin_simple_stabs_desc (buffer, N_MAC_UNDEF, lineno);
+      dbxout_stab_value_zero ();
+    }
+}
+
 /* Change to reading from a new source file.  Generate a N_BINCL stab.  */
 
 static void
Index: gcc/stab.def
===================================================================
--- gcc/stab.def	(revision 117374)
+++ gcc/stab.def	(working copy)
@@ -59,10 +59,16 @@
 /* "No DST map for sym: name, ,0,type,ignored"  according to Ultrix V4.0.  */
 __define_stab (N_NOMAP, 0x34, "NOMAP")
 
+/* GNU extension.  Macro define.  */
+__define_stab(N_MAC_DEFINE, 0x36, "MAC_DEFINE")
+
 /* New stab from Solaris.  I don't know what it means, but it
    don't seem to contain useful information.  */
 __define_stab (N_OBJ, 0x38, "OBJ")
 
+/* GNU extension.  Macro undefine.  */
+__define_stab(N_MAC_UNDEF, 0x3a, "MAC_UNDEF")
+
 /* New stab from Solaris.  I don't know what it means, but it
    don't seem to contain useful information.  Possibly related to the
    optimization flags used in this module.  */

David

p.s. as of middle of last month, there's now a copyright assignment on
file for EMC.  And it only took 3 years, 8 months, and 28 days to
accomplish, but who's counting?

--
David Taylor
dtaylor@emc.com


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