This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


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

coffread.c and one-line functions



Thu Apr  8 06:26:12 1999  Philippe De Muyter  <phdm@macqel.be>

	* breakpoint.c (maintenance_info_breakpoints): Function made static
	to match previous prototype.
	* coffread.c (coff_record_line): Static function removed.
	(enter_linenos): Call `record_line' instead of `coff_record_line'.
	(FILE-LEVEL, coff_start_symtab, coff_end_symtab): `coff_record_line'
	-related stuff removed.
	(coff_symfile_read): Redundant statement removed.
	(coff_symtab_read): `record_line' is now called with the first line
	number of each function, given by the ".bf" symbol.  This solves
	the line-number bug for one-line functions.

--- ./breakpoint.c	Thu Apr  8 06:21:55 1999
+++ ./breakpoint.c	Wed Mar 31 01:06:39 1999
@@ -2935,7 +2935,7 @@ breakpoints_info (bnum_exp, from_tty)
 #if MAINTENANCE_CMDS
 
 /* ARGSUSED */
-void
+static void
 maintenance_info_breakpoints (bnum_exp, from_tty)
      char *bnum_exp;
      int from_tty;
--- ./coffread.c	Thu Apr  8 06:21:58 1999
+++ ./coffread.c	Wed Apr  7 19:28:34 1999
@@ -84,21 +84,6 @@
 static bfd *nlist_bfd_global;
 static int nlist_nsyms_global;
 
-/* Vector of line number information.  */
-
-static struct linetable *line_vector;
-
-/* Index of next entry to go in line_vector_index.  */
-
-static int line_vector_index;
-
-/* Last line number recorded in the line vector.  */
-
-static int prev_line_number;
-
-/* Number of elements allocated for line_vector currently.  */
-
-static int line_vector_length;
 
 /* Pointers to scratch storage, used for reading raw symbols and auxents.  */
 
@@ -252,8 +237,6 @@
 
 static void coff_start_symtab PARAMS ((char *));
 
-static void coff_record_line PARAMS ((int, CORE_ADDR));
-
 static struct type *coff_alloc_type PARAMS ((int));
 
 static struct type **coff_lookup_type PARAMS ((int));
@@ -440,30 +423,6 @@ coff_alloc_type (index)
   return type;
 }
 
-/* Record a line number entry for line LINE at address PC.
-   FIXME:  Use record_line instead.  */
-
-static void
-coff_record_line (line, pc)
-     int line;
-     CORE_ADDR pc;
-{
-  struct linetable_entry *e;
-  /* Make sure line vector is big enough.  */
-
-  if (line_vector_index + 2 >= line_vector_length)
-    {
-      line_vector_length *= 2;
-      line_vector = (struct linetable *)
-	xrealloc ((char *) line_vector, sizeof (struct linetable)
-		  + (line_vector_length
-		     * sizeof (struct linetable_entry)));
-    }
-
-  e = line_vector->item + line_vector_index++;
-  e->line = line; e->pc = pc;
-}
-
 /* Start a new symtab for a new source file.
    This is called when a COFF ".file" symbol is seen;
    it indicates the start of data for one original source file.  */
@@ -484,17 +443,6 @@ coff_start_symtab (name)
 		   last_source_start_addr in coff_end_symtab.  */
 		0);
   record_debugformat ("COFF");
-
-  /* Initialize the source file line number information for this file.  */
-
-  if (line_vector)		/* Unlikely, but maybe possible? */
-    free ((PTR)line_vector);
-  line_vector_index = 0;
-  line_vector_length = 1000;
-  prev_line_number = -2;	/* Force first line number to be explicit */
-  line_vector = (struct linetable *)
-    xmalloc (sizeof (struct linetable)
-	     + line_vector_length * sizeof (struct linetable_entry));
 }
 
 /* Save the vital information from when starting to read a file,
@@ -535,26 +483,12 @@ coff_end_symtab (objfile)
 
   last_source_start_addr = current_source_start_addr;
 
-  /* For no good reason, this file stores the number of entries in a
-     separate variable instead of in line_vector->nitems.  Fix it.  */
-  if (line_vector)
-    line_vector->nitems = line_vector_index;
-
-  /* For COFF, we only have one subfile, so we can just look at
-     subfiles and not worry about there being other elements in the
-     chain.  We fill in various fields now because we didn't know them
-     before (or because doing it now is simply an artifact of how this
-     file used to be written).  */
-  subfiles->line_vector = line_vector;
-
   symtab = end_symtab (current_source_end_addr, objfile, 0);
 
   if (symtab != NULL)
     free_named_symtabs (symtab->filename);
 
   /* Reinitialize for beginning of new file. */
-  line_vector = 0;
-  line_vector_length = -1;
   last_source_file = NULL;
 }
 
@@ -683,7 +617,6 @@ coff_symfile_read (objfile, section_offs
 
   /* Set a few file-statics that give us specific information about
      the particular COFF file format we're reading.  */
-  local_linesz   = cdata->local_linesz;
   local_n_btmask = cdata->local_n_btmask;
   local_n_btshft = cdata->local_n_btshft;
   local_n_tmask  = cdata->local_n_tmask;
@@ -1086,6 +1019,7 @@ coff_symtab_read (symtab_offset, nsyms, 
 		new->name =
 		  process_coff_symbol (&fcn_cs_saved, &fcn_aux_saved,
 				       section_offsets, objfile);
+	        record_line (current_subfile, fcn_first_line, cs->c_value);
 	      }
 	    else if (STREQ (cs->c_name, ".ef"))
 	      {
@@ -1458,7 +1392,7 @@ enter_linenos (file_offset, first_line, 
     rawptr += local_linesz;
     /* The next function, or the sentinel, will have L_LNNO32 zero; we exit. */
     if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line)
-      coff_record_line (first_line + L_LNNO32 (&lptr),
+      record_line (current_subfile, first_line + L_LNNO32 (&lptr),
 			lptr.l_addr.l_paddr
 			+ ANOFFSET (section_offsets, SECT_OFF_TEXT));
     else