2003-04-13 Michael Snyder <msnyder@redhat.com>
[binutils-gdb.git] / gdb / dbxread.c
index 2a1d4e20c69ecb6aee368a13462cd1495b5a6f07..752efdd7ed75ccb562240ec09e9f546d767aed0e 100644 (file)
@@ -1762,7 +1762,7 @@ read_dbx_symtab (struct objfile *objfile)
            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);
@@ -1772,7 +1772,7 @@ read_dbx_symtab (struct objfile *objfile)
            /* 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 +1790,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 +1798,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 +1814,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 +1826,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 +1888,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 +1905,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 +1966,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 +2031,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);
@@ -2784,9 +2784,10 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
      peculiarities of function_start_offset.  */
   static CORE_ADDR last_function_start;
 
-  /* If this is nonzero, we've seen an N_SLINE since the start of the current
-     function.  Initialized to nonzero to assure that last_function_start
-     is never used uninitialized.  */
+  /* If this is nonzero, we've seen an N_SLINE since the start of the
+     current function.  We use this to tell us to move the first sline
+     to the beginning of the function regardless of what its given
+     value is. */
   static int sline_found_in_function = 1;
 
   /* If this is nonzero, we've seen a non-gcc N_OPT symbol for this source
@@ -2830,7 +2831,13 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
              break;
            }
 
-         record_line (current_subfile, 0, function_start_offset + 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 ();
 
@@ -3260,13 +3267,13 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
                  int l = colon_pos - name;
 
                  m = lookup_minimal_symbol_by_pc (last_pc_address);
-                 if (m && STREQN (SYMBOL_NAME (m), name, l)
-                     && SYMBOL_NAME (m)[l] == '\0')
+                 if (m && STREQN (DEPRECATED_SYMBOL_NAME (m), name, l)
+                     && DEPRECATED_SYMBOL_NAME (m)[l] == '\0')
                    /* last_pc_address was in this function */
                    valu = SYMBOL_VALUE (m);
-                 else if (m && SYMBOL_NAME (m + 1)
-                          && STREQN (SYMBOL_NAME (m + 1), name, l)
-                          && SYMBOL_NAME (m + 1)[l] == '\0')
+                 else if (m && DEPRECATED_SYMBOL_NAME (m + 1)
+                          && STREQN (DEPRECATED_SYMBOL_NAME (m + 1), name, l)
+                          && DEPRECATED_SYMBOL_NAME (m + 1)[l] == '\0')
                    /* last_pc_address was in last function */
                    valu = SYMBOL_VALUE (m + 1);
                  else
@@ -3555,7 +3562,6 @@ elfstab_build_psymtabs (struct objfile *objfile, int mainline,
   buildsym_new_init ();
   free_header_files ();
   init_header_files ();
-  install_minimal_symbols (objfile);
 
   processing_acc_compilation = 1;
 
@@ -3567,7 +3573,10 @@ elfstab_build_psymtabs (struct objfile *objfile, int mainline,
 
   /* In an elf file, we've already installed the minimal symbols that came
      from the elf (non-stab) symbol table, so always act like an
-     incremental load here. */
+     incremental load here.  dbx_symfile_read should not generate any new
+     minimal symbols, since we will have already read the ELF dynamic symbol
+     table and normal symbol entries won't be in the ".stab" section; but in
+     case it does, it will install them itself.  */
   dbx_symfile_read (objfile, 0);
 
   if (back_to)
@@ -3649,7 +3658,6 @@ stabsect_build_psymtabs (struct objfile *objfile, int mainline, char *stab_name,
   buildsym_new_init ();
   free_header_files ();
   init_header_files ();
-  install_minimal_symbols (objfile);
 
   /* Now, do an incremental load */