import gdb-1999-06-14 snapshot
[deliverable/binutils-gdb.git] / gdb / coffread.c
index 9c8f47540574194abd786b0c7d21a898e9a89733..1a63cfb755280e6c66c589b712a63afc4208c605 100644 (file)
@@ -42,6 +42,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "complaints.h"
 #include "target.h"
 
+extern void _initialize_coffread PARAMS ((void));
+
 struct coff_symfile_info {
   file_ptr min_lineno_offset;          /* Where in file lowest line#s are */
   file_ptr max_lineno_offset;          /* 1+last byte of line#s in file */
@@ -686,6 +688,17 @@ coff_symfile_read (objfile, section_offsets, mainline)
 
   if (info->stabsects)
     {
+      if (! info->stabstrsect)
+       {
+         error_begin ();
+         fprintf_filtered
+           (gdb_stderr,
+            ("The debugging information in `%s' is corrupted.\n"
+             "The file has a `.stabs' section, but no `.stabstr' section.\n"),
+            name);
+         return_to_top_level (RETURN_ERROR);
+       }
+
       /* FIXME: dubious.  Why can't we use something normal like
         bfd_get_section_contents?  */
       bfd_seek (abfd, abfd->where, 0);
@@ -753,6 +766,7 @@ coff_symtab_read (symtab_offset, nsyms, section_offsets, objfile)
   char *filestring = "";
   int depth = 0;
   int fcn_first_line = 0;
+  CORE_ADDR fcn_first_line_addr;
   int fcn_last_line = 0;
   int fcn_start_addr = 0;
   long fcn_line_ptr = 0;
@@ -1009,6 +1023,7 @@ coff_symtab_read (symtab_offset, nsyms, section_offsets, objfile)
                if (cs->c_naux != 1)
                  complain (&bf_no_aux_complaint, cs->c_symnum);
                fcn_first_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
+               fcn_first_line_addr = cs->c_value;
 
                /* Might want to check that locals are 0 and
                   context_stack_depth is zero, and complain if not.  */
@@ -1019,7 +1034,6 @@ coff_symtab_read (symtab_offset, nsyms, section_offsets, objfile)
                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"))
              {
@@ -1052,8 +1066,18 @@ coff_symtab_read (symtab_offset, nsyms, section_offsets, objfile)
                  {
                    fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
                  }
-               enter_linenos (fcn_line_ptr, fcn_first_line, fcn_last_line,
-                              section_offsets);
+               /* fcn_first_line is the line number of the opening '{'.
+                  Do not record it - because it would affect gdb's idea
+                  of the line number of the first statement of the function -
+                  except for one-line functions, for which it is also the line
+                  number of all the statements and of the closing '}', and
+                  for which we do not have any other statement-line-number. */
+               if (fcn_last_line == 1)
+                 record_line (current_subfile, fcn_first_line,
+                              fcn_first_line_addr);
+               else
+                 enter_linenos (fcn_line_ptr, fcn_first_line, fcn_last_line,
+                                section_offsets);
 
                finish_block (new->name, &local_symbols, new->old_blocks,
                              new->start_addr,
This page took 0.023665 seconds and 4 git commands to generate.