This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


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

[RFC] GDB's mdebug support vs. GCC 3.0


The stabs support for mips-linux is now much more complete than it was; from
what I can see this is because we started using config/elfos.h in gcc.  Two
of the gems we get from this are EINCL/BINCL stabs, which as far as I can
see we did not before, and a trailing SO at the end of a file.

The way we call process_one_symbol in dbxread.c from psymtab_to_symtab_1 in
mdebugread.c is, to say the least, a little iffy.  We aren't doing the
initialization it expects.  This patch is a pair of bandaids, but I think
that they're about as correct bandaids as I can manage.  I spent a while
going through the stabs reader, trying to figure out how these things are
actually supposed to work, and couldn't.  With the patch, we no longer crash
every time we try to read in a symtab; one obvious NULL pointer dereference,
and then doubled calls to end_symtab.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2001-06-29  Daniel Jacobowitz  <drow@mvista.com>
	* dbxread.c (add_this_object_header_file): Make sure the header file
	list is allocated.
	* mdebugread.c (psymtab_to_symtab_1): Handle N_SO stabs without
	a name specially.

Index: dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.18
diff -u -r1.18 dbxread.c
--- dbxread.c	2001/04/27 00:19:09	1.18
+++ dbxread.c	2001/06/29 19:32:28
@@ -345,6 +345,8 @@
 static void
 add_this_object_header_file (int i)
 {
+  if (n_allocated_this_object_header_files == 0)
+      init_header_files ();
   if (n_this_object_header_files == n_allocated_this_object_header_files)
     {
       n_allocated_this_object_header_files *= 2;
Index: mdebugread.c
===================================================================
RCS file: /cvs/src/src/gdb/mdebugread.c,v
retrieving revision 1.13
diff -u -r1.13 mdebugread.c
--- mdebugread.c	2001/05/29 10:45:10	1.13
+++ mdebugread.c	2001/06/29 19:32:29
@@ -3210,10 +3210,11 @@
   void (*swap_sym_in) (bfd *, PTR, SYMR *);
   void (*swap_pdr_in) (bfd *, PTR, PDR *);
   int i;
-  struct symtab *st;
+  struct symtab *st = NULL;
   FDR *fh;
   struct linetable *lines;
   CORE_ADDR lowest_pdr_addr = 0;
+  int last_symtab_ended = 0;
 
   if (pst->readin)
     return;
@@ -3319,8 +3320,27 @@
 	         complaining about them.  */
 	      if (type_code & N_STAB)
 		{
-		  process_one_symbol (type_code, 0, valu, name,
-				      pst->section_offsets, pst->objfile);
+		  /* If we found a trailing N_SO with no name, process it here
+		     instead of in process_one_symbol, so we can keep its symtab. */
+		  if (type_code == N_SO
+		      && last_source_file
+		      && previous_stab_code != (unsigned char) N_SO
+		      && *name == '\000')
+		    {
+		      valu += ANOFFSET (pst->section_offsets,
+					SECT_OFF_TEXT (pst->objfile));
+		      previous_stab_code = N_SO;
+		      st = end_symtab (valu, pst->objfile,
+				       SECT_OFF_TEXT (pst->objfile));
+		      end_stabs ();
+		      last_symtab_ended = 1;
+		    }
+		  else
+		    {
+		      last_symtab_ended = 0;
+		      process_one_symbol (type_code, 0, valu, name,
+					  pst->section_offsets, pst->objfile);
+		    }
 		}
 	      /* Similarly a hack.  */
 	      else if (name[0] == '#')
@@ -3368,9 +3388,13 @@
 	    ;
 	  else
 	    complain (&stab_unknown_complaint, name);
+	}
+
+      if (! last_symtab_ended)
+	{
+	  st = end_symtab (pst->texthigh, pst->objfile, SECT_OFF_TEXT (pst->objfile));
+	  end_stabs ();
 	}
-      st = end_symtab (pst->texthigh, pst->objfile, SECT_OFF_TEXT (pst->objfile));
-      end_stabs ();
 
       /* Sort the symbol table now, we are done adding symbols to it.
          We must do this before parse_procedure calls lookup_symbol.  */


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