Partial fix for 11654

Geoffrey Keating gkeating@apple.com
Fri Nov 7 22:12:00 GMT 2003


The attached patch is a partial fix for PR 11654.  It's 'partial'
because although it avoids the crash, the resulting debug output is
not correct.  I think this is an improvement.

I am not sure if it's possible to easily fix the remainder of the
problem.  It works on simple examples in the Apple compiler with
-gused, but doesn't work in FSF HEAD with the testcase I gave in PR
11654 (you get assembly miscompares).  Thus, I'm not committing the
testcase :-).

Bootstrapped & tested on powerpc-darwin.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-11654-A.patch=========================
2003-11-07  Geoffrey Keating  <geoffk@apple.com>

	PR 11654
	* dbxout.c (struct dbx_file): Do not save for PCH.
	(current_file): Likewise.
	(dbxout_init): Don't allocate struct dbx_file using GC.
	(dbxout_start_source_file): Likewise.

Index: dbxout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dbxout.c,v
retrieving revision 1.164
diff -u -p -u -p -r1.164 dbxout.c
--- dbxout.c	22 Oct 2003 14:28:09 -0000	1.164
+++ dbxout.c	7 Nov 2003 22:08:52 -0000
@@ -185,19 +185,25 @@ enum binclstatus {BINCL_NOT_REQUIRED, BI
    pair of the file number and the type number within the file.
    This is a stack of input files.  */
 
-struct dbx_file GTY(())
+struct dbx_file
 {
   struct dbx_file *next;
   int file_number;
   int next_type_number;
-  enum binclstatus bincl_status;      /* Keep track of lazy bincl.  */
-  const char *pending_bincl_name;     /* Name of bincl.  */
-  struct dbx_file *prev;              /* Chain to traverse all pending bincls.  */
+  enum binclstatus bincl_status;  /* Keep track of lazy bincl.  */
+  const char *pending_bincl_name; /* Name of bincl.  */
+  struct dbx_file *prev;          /* Chain to traverse all pending bincls.  */
 };
 
-/* This is the top of the stack.  */
+/* This is the top of the stack.  
+   
+   This is not saved for PCH, because restoring a PCH should not change it.
+   next_file_number does have to be saved, because the PCH may use some
+   file numbers; however, just before restoring a PCH, next_file_number
+   should always be 0 because we should not have needed any file numbers
+   yet.  */
 
-static GTY(()) struct dbx_file *current_file;
+static struct dbx_file *current_file;
 
 /* This is the next file number to use.  */
 
@@ -513,7 +519,7 @@ dbxout_init (const char *input_file_name
   next_type_number = 1;
 
 #ifdef DBX_USE_BINCL
-  current_file = ggc_alloc (sizeof *current_file);
+  current_file = xmalloc (sizeof *current_file);
   current_file->next = NULL;
   current_file->file_number = 0;
   current_file->next_type_number = 1;
@@ -625,7 +631,7 @@ dbxout_start_source_file (unsigned int l
 			  const char *filename ATTRIBUTE_UNUSED)
 {
 #ifdef DBX_USE_BINCL
-  struct dbx_file *n = ggc_alloc (sizeof *n);
+  struct dbx_file *n = xmalloc (sizeof *n);
 
   n->next = current_file;
   n->next_type_number = 1;
============================================================



More information about the Gcc-patches mailing list