2003-09-11 Elena Zannoni <ezannoni@redhat.com>
[deliverable/binutils-gdb.git] / gdb / dbxread.c
index 11d038e0c78767ba2eebb1e80b40fb794b4fb65b..61c78c464576a7e8ef5d623bdad758e36bdc1bf3 100644 (file)
@@ -58,6 +58,7 @@
 #include "language.h"          /* Needed for local_hex_string */
 #include "complaints.h"
 #include "cp-abi.h"
+#include "gdb_assert.h"
 
 #include "aout/aout64.h"
 #include "aout/stab_gnu.h"     /* We always use GNU stabs, not native, now */
@@ -1232,7 +1233,7 @@ read_dbx_dynamic_symtab (struct objfile *objfile)
 }
 
 #ifdef SOFUN_ADDRESS_MAYBE_MISSING
-CORE_ADDR
+static CORE_ADDR
 find_stab_function_addr (char *namestring, char *filename,
                         struct objfile *objfile)
 {
@@ -1304,6 +1305,7 @@ read_dbx_symtab (struct objfile *objfile)
   struct cleanup *back_to;
   bfd *abfd;
   int textlow_not_set;
+  int data_sect_index;
 
   /* Current partial symtab */
   struct partial_symtab *pst;
@@ -1355,6 +1357,12 @@ read_dbx_symtab (struct objfile *objfile)
   textlow_not_set = 1;
   has_line_numbers = 0;
 
+  /* If the objfile has no .data section, try using the .bss section.  */
+  data_sect_index = objfile->sect_index_data;
+  if (data_sect_index == -1)
+    data_sect_index = SECT_OFF_BSS (objfile);
+  gdb_assert (data_sect_index != -1);
+
   for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++)
     {
       /* Get the symbol for this run and pull out some info */
@@ -1401,7 +1409,7 @@ read_dbx_symtab (struct objfile *objfile)
 
          case N_DATA | N_EXT:
          case N_NBDATA | N_EXT:
-         nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
+         nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
          goto record_it;
 
          case N_BSS:
@@ -1468,7 +1476,7 @@ read_dbx_symtab (struct objfile *objfile)
          continue;
 
          case N_DATA:
-         nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
+         nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
          goto record_it;
 
          case N_UNDF | N_EXT:
@@ -1757,22 +1765,22 @@ read_dbx_symtab (struct objfile *objfile)
          switch (p[1])
          {
          case 'S':
-           nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
+           nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
 #ifdef STATIC_TRANSFORM_NAME
            namestring = STATIC_TRANSFORM_NAME (namestring);
 #endif
            add_psymbol_to_list (namestring, p - namestring,
-                                VAR_NAMESPACE, LOC_STATIC,
+                                VAR_DOMAIN, LOC_STATIC,
                                 &objfile->static_psymbols,
                                 0, nlist.n_value,
                                 psymtab_language, objfile);
            continue;
          case 'G':
-           nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
+           nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
            /* The addresses in these entries are reported to be
               wrong.  See the code that reads 'G's for symtabs. */
            add_psymbol_to_list (namestring, p - namestring,
-                                VAR_NAMESPACE, LOC_STATIC,
+                                VAR_DOMAIN, LOC_STATIC,
                                 &objfile->global_psymbols,
                                 0, nlist.n_value,
                                 psymtab_language, objfile);
@@ -1790,7 +1798,7 @@ read_dbx_symtab (struct objfile *objfile)
                    && namestring[0] != ' '))
              {
                add_psymbol_to_list (namestring, p - namestring,
-                                    STRUCT_NAMESPACE, LOC_TYPEDEF,
+                                    STRUCT_DOMAIN, LOC_TYPEDEF,
                                     &objfile->static_psymbols,
                                     nlist.n_value, 0,
                                     psymtab_language, objfile);
@@ -1798,7 +1806,7 @@ read_dbx_symtab (struct objfile *objfile)
                  {
                    /* Also a typedef with the same name.  */
                    add_psymbol_to_list (namestring, p - namestring,
-                                        VAR_NAMESPACE, LOC_TYPEDEF,
+                                        VAR_DOMAIN, LOC_TYPEDEF,
                                         &objfile->static_psymbols,
                                         nlist.n_value, 0,
                                         psymtab_language, objfile);
@@ -1814,7 +1822,7 @@ read_dbx_symtab (struct objfile *objfile)
 // OBSOLETE              {
 // OBSOLETE                /* Also a typedef with the same name.  */
 // OBSOLETE                add_psymbol_to_list (namestring, p - namestring,
-// OBSOLETE                                     VAR_NAMESPACE, LOC_TYPEDEF,
+// OBSOLETE                                     VAR_DOMAIN, LOC_TYPEDEF,
 // OBSOLETE                                     &objfile->static_psymbols,
 // OBSOLETE                                     nlist.n_value, 0,
 // OBSOLETE                                     psymtab_language, objfile);
@@ -1826,7 +1834,7 @@ read_dbx_symtab (struct objfile *objfile)
            if (p != namestring)        /* a name is there, not just :T... */
              {
                add_psymbol_to_list (namestring, p - namestring,
-                                    VAR_NAMESPACE, LOC_TYPEDEF,
+                                    VAR_DOMAIN, LOC_TYPEDEF,
                                     &objfile->static_psymbols,
                                     nlist.n_value, 0,
                                     psymtab_language, objfile);
@@ -1888,7 +1896,7 @@ read_dbx_symtab (struct objfile *objfile)
                    /* Note that the value doesn't matter for
                       enum constants in psymtabs, just in symtabs.  */
                    add_psymbol_to_list (p, q - p,
-                                        VAR_NAMESPACE, LOC_CONST,
+                                        VAR_DOMAIN, LOC_CONST,
                                         &objfile->static_psymbols, 0,
                                         0, psymtab_language, objfile);
                    /* Point past the name.  */
@@ -1905,7 +1913,7 @@ read_dbx_symtab (struct objfile *objfile)
          case 'c':
            /* Constant, e.g. from "const" in Pascal.  */
            add_psymbol_to_list (namestring, p - namestring,
-                                VAR_NAMESPACE, LOC_CONST,
+                                VAR_DOMAIN, LOC_CONST,
                                 &objfile->static_psymbols, nlist.n_value,
                                 0, psymtab_language, objfile);
            continue;
@@ -1966,7 +1974,7 @@ read_dbx_symtab (struct objfile *objfile)
                textlow_not_set = 0;
              }
            add_psymbol_to_list (namestring, p - namestring,
-                                VAR_NAMESPACE, LOC_BLOCK,
+                                VAR_DOMAIN, LOC_BLOCK,
                                 &objfile->static_psymbols,
                                 0, nlist.n_value,
                                 psymtab_language, objfile);
@@ -2031,7 +2039,7 @@ read_dbx_symtab (struct objfile *objfile)
                textlow_not_set = 0;
              }
            add_psymbol_to_list (namestring, p - namestring,
-                                VAR_NAMESPACE, LOC_BLOCK,
+                                VAR_DOMAIN, LOC_BLOCK,
                                 &objfile->global_psymbols,
                                 0, nlist.n_value,
                                 psymtab_language, objfile);
@@ -2484,7 +2492,6 @@ dbx_psymtab_to_symtab_1 (struct partial_symtab *pst)
       /* Read in this file's symbols */
       bfd_seek (pst->objfile->obfd, SYMBOL_OFFSET (pst), SEEK_SET);
       read_ofile_symtab (pst);
-      sort_symtab_syms (pst->symtab);
 
       do_cleanups (old_chain);
     }
@@ -2831,7 +2838,13 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
              break;
            }
 
-         record_line (current_subfile, 0, last_function_start + valu);
+         /* The following check is added before recording line 0 at
+            end of function so as to handle hand-generated stabs
+            which may have an N_FUN stabs at the end of the function, but
+            no N_SLINE stabs.  */
+         if (sline_found_in_function)
+           record_line (current_subfile, 0, last_function_start + valu);
+
          within_function = 0;
          new = pop_context ();
 
This page took 0.027009 seconds and 4 git commands to generate.