daily update
[deliverable/binutils-gdb.git] / gdb / dbxread.c
index 33d164e8c6c96ea0bc17eacad51c89caee0b9bbd..d94922e1f0b18fdb755efd8f7388b9239a573582 100644 (file)
@@ -7,7 +7,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -16,9 +16,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* This module provides three functions: dbx_symfile_init,
    which initializes to read a symbol file; dbx_new_init, which 
@@ -1118,7 +1116,6 @@ read_dbx_dynamic_symtab (struct objfile *objfile)
   do_cleanups (back_to);
 }
 
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
 static CORE_ADDR
 find_stab_function_addr (char *namestring, char *filename,
                         struct objfile *objfile)
@@ -1162,7 +1159,6 @@ find_stab_function_addr (char *namestring, char *filename,
 
   return msym == NULL ? 0 : SYMBOL_VALUE_ADDRESS (msym);
 }
-#endif /* SOFUN_ADDRESS_MAYBE_MISSING */
 
 static void
 function_outside_compilation_unit_complaint (const char *arg1)
@@ -1465,21 +1461,19 @@ read_dbx_symtab (struct objfile *objfile)
 
            prev_textlow_not_set = textlow_not_set;
 
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
            /* A zero value is probably an indication for the SunPRO 3.0
               compiler. end_psymtab explicitly tests for zero, so
               don't relocate it.  */
 
-           if (nlist.n_value == 0)
+           if (nlist.n_value == 0
+               && gdbarch_sofun_address_maybe_missing (current_gdbarch))
              {
                textlow_not_set = 1;
                valu = 0;
              }
            else
              textlow_not_set = 0;
-#else
-           textlow_not_set = 0;
-#endif
+
            past_first_source_file = 1;
 
            if (prev_so_symnum != symnum - 1)
@@ -1682,9 +1676,11 @@ read_dbx_symtab (struct objfile *objfile)
          {
          case 'S':
            nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
-#ifdef STATIC_TRANSFORM_NAME
-           namestring = STATIC_TRANSFORM_NAME (namestring);
-#endif
+
+           if (gdbarch_static_transform_name_p (current_gdbarch))
+             namestring = gdbarch_static_transform_name
+                            (current_gdbarch, namestring);
+
            add_psymbol_to_list (namestring, p - namestring,
                                 VAR_DOMAIN, LOC_STATIC,
                                 &objfile->static_psymbols,
@@ -1828,17 +1824,20 @@ read_dbx_symtab (struct objfile *objfile)
                function_outside_compilation_unit_complaint (name);
                xfree (name);
              }
-           nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+           nlist.n_value += ANOFFSET (objfile->section_offsets, 
+                                      SECT_OFF_TEXT (objfile));
            /* Kludges for ELF/STABS with Sun ACC */
            last_function_name = namestring;
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
            /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
               value for the bottom of the text seg in those cases. */
            if (nlist.n_value == ANOFFSET (objfile->section_offsets, 
-                                          SECT_OFF_TEXT (objfile)))
+                                          SECT_OFF_TEXT (objfile))
+               && gdbarch_sofun_address_maybe_missing (current_gdbarch))
              {
                CORE_ADDR minsym_valu = 
-                 find_stab_function_addr (namestring, pst->filename, objfile);
+                 find_stab_function_addr (namestring, 
+                                          pst ? pst->filename : NULL, 
+                                          objfile);
                /* find_stab_function_addr will return 0 if the minimal
                   symbol wasn't found.  (Unfortunately, this might also
                   be a valid address.)  Anyway, if it *does* return 0,
@@ -1847,12 +1846,12 @@ read_dbx_symtab (struct objfile *objfile)
                if (minsym_valu != 0)
                  nlist.n_value = minsym_valu;
              }
-           if (pst && textlow_not_set)
+           if (pst && textlow_not_set
+               && gdbarch_sofun_address_maybe_missing (current_gdbarch))
              {
                pst->textlow = nlist.n_value;
                textlow_not_set = 0;
              }
-#endif
            /* End kludge.  */
 
            /* Keep track of the start of the last function so we
@@ -1893,17 +1892,20 @@ read_dbx_symtab (struct objfile *objfile)
                function_outside_compilation_unit_complaint (name);
                xfree (name);
              }
-           nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+           nlist.n_value += ANOFFSET (objfile->section_offsets, 
+                                      SECT_OFF_TEXT (objfile));
            /* Kludges for ELF/STABS with Sun ACC */
            last_function_name = namestring;
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
            /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
               value for the bottom of the text seg in those cases. */
            if (nlist.n_value == ANOFFSET (objfile->section_offsets, 
-                                          SECT_OFF_TEXT (objfile)))
+                                          SECT_OFF_TEXT (objfile))
+               && gdbarch_sofun_address_maybe_missing (current_gdbarch))
              {
                CORE_ADDR minsym_valu = 
-                 find_stab_function_addr (namestring, pst->filename, objfile);
+                 find_stab_function_addr (namestring, 
+                                          pst ? pst->filename : NULL, 
+                                          objfile);
                /* find_stab_function_addr will return 0 if the minimal
                   symbol wasn't found.  (Unfortunately, this might also
                   be a valid address.)  Anyway, if it *does* return 0,
@@ -1912,12 +1914,12 @@ read_dbx_symtab (struct objfile *objfile)
                if (minsym_valu != 0)
                  nlist.n_value = minsym_valu;
              }
-           if (pst && textlow_not_set)
+           if (pst && textlow_not_set
+               && gdbarch_sofun_address_maybe_missing (current_gdbarch))
              {
                pst->textlow = nlist.n_value;
                textlow_not_set = 0;
              }
-#endif
            /* End kludge.  */
 
            /* Keep track of the start of the last function so we
@@ -2043,12 +2045,11 @@ read_dbx_symtab (struct objfile *objfile)
          continue;
 
          case N_ENDM:
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
          /* Solaris 2 end of module, finish current partial symbol table.
             end_psymtab will set pst->texthigh to the proper value, which
             is necessary if a module compiled without debugging info
             follows this module.  */
-         if (pst)
+         if (pst && gdbarch_sofun_address_maybe_missing (current_gdbarch))
          {
            end_psymtab (pst, psymtab_include_list, includes_used,
                         symnum * symbol_size,
@@ -2058,7 +2059,6 @@ read_dbx_symtab (struct objfile *objfile)
            includes_used = 0;
            dependencies_used = 0;
          }
-#endif
          continue;
 
          case N_RBRAC:
@@ -2148,11 +2148,13 @@ start_psymtab (struct objfile *objfile, char *filename, CORE_ADDR textlow,
   STRING_OFFSET (result) = string_table_offset;
   FILE_STRING_OFFSET (result) = file_string_table_offset;
 
+#ifdef HAVE_ELF
   /* If we're handling an ELF file, drag some section-relocation info
      for this source file out of the ELF symbol table, to compensate for
      Sun brain death.  This replaces the section_offsets in this psymtab,
      if successful.  */
   elfstab_offset_sections (objfile, result);
+#endif
 
   /* Deduce the source language from the filename for this psymtab. */
   psymtab_language = deduce_language_from_filename (filename);
@@ -2178,7 +2180,6 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes,
     LDSYMLEN (pst) = capping_symbol_offset - LDSYMOFF (pst);
   pst->texthigh = capping_text;
 
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
   /* Under Solaris, the N_SO symbols always have a value of 0,
      instead of the usual address of the .o file.  Therefore,
      we have to do some tricks to fill in texthigh and textlow.
@@ -2194,7 +2195,8 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes,
      a reliable texthigh by taking the address plus size of the
      last function in the file.  */
 
-  if (pst->texthigh == 0 && last_function_name)
+  if (pst->texthigh == 0 && last_function_name
+      && gdbarch_sofun_address_maybe_missing (current_gdbarch))
     {
       char *p;
       int n;
@@ -2225,8 +2227,10 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes,
       last_function_name = NULL;
     }
 
+  if (!gdbarch_sofun_address_maybe_missing (current_gdbarch))
+    ;
   /* this test will be true if the last .o file is only data */
-  if (textlow_not_set)
+  else if (textlow_not_set)
     pst->textlow = pst->texthigh;
   else
     {
@@ -2251,7 +2255,6 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes,
     }
 
   /* End of kludge for patching Solaris textlow and texthigh.  */
-#endif /* SOFUN_ADDRESS_MAYBE_MISSING.  */
 
   pst->n_global_syms =
     objfile->global_psymbols.next - (objfile->global_psymbols.list + pst->globals_offset);
@@ -2608,8 +2611,6 @@ read_ofile_symtab (struct partial_symtab *pst)
        }
     }
 
-  current_objfile = NULL;
-
   /* In a Solaris elf file, this variable, which comes from the
      value of the N_SO symbol, will still be 0.  Luckily, text_offset,
      which comes from pst->textlow is correct. */
@@ -2625,6 +2626,8 @@ read_ofile_symtab (struct partial_symtab *pst)
   pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
 
   end_stabs ();
+
+  current_objfile = NULL;
 }
 \f
 
@@ -2738,7 +2741,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
 
       /* Relocate for dynamic loading.  */
       valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
-      valu = SMASH_TEXT_ADDRESS (valu);
+      valu = gdbarch_smash_text_address (current_gdbarch, valu);
       last_function_start = valu;
 
       goto define_a_symbol;
@@ -2788,38 +2791,19 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
       if (desc != new->depth)
        lbrac_mismatch_complaint (symnum);
 
-      /* Some compilers put the variable decls inside of an
-         LBRAC/RBRAC block.  This macro should be nonzero if this is
-         true.  DESC is N_DESC from the N_RBRAC symbol.  GCC_P is true
-         if we've detected the GCC_COMPILED_SYMBOL or the
-         GCC2_COMPILED_SYMBOL.  */
-#if !defined (VARIABLES_INSIDE_BLOCK)
-#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) 0
-#endif
-
-      /* Can only use new->locals as local symbols here if we're in
-         GCC or on a machine that puts them before the lbrack.  */
-      if (!VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation))
+      if (local_symbols != NULL)
        {
-         if (local_symbols != NULL)
-           {
-             /* GCC development snapshots from March to December of
-                2000 would output N_LSYM entries after N_LBRAC
-                entries.  As a consequence, these symbols are simply
-                discarded.  Complain if this is the case.  Note that
-                there are some compilers which legitimately put local
-                symbols within an LBRAC/RBRAC block; this complaint
-                might also help sort out problems in which
-                VARIABLES_INSIDE_BLOCK is incorrectly defined.  */
-             complaint (&symfile_complaints, _("\
+         /* GCC development snapshots from March to December of
+            2000 would output N_LSYM entries after N_LBRAC
+            entries.  As a consequence, these symbols are simply
+            discarded.  Complain if this is the case.  */
+         complaint (&symfile_complaints, _("\
 misplaced N_LBRAC entry; discarding local symbols which have \
 no enclosing block"));
-           }
-         local_symbols = new->locals;
        }
+      local_symbols = new->locals;
 
-      if (context_stack_depth
-         > !VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation))
+      if (context_stack_depth > 1)
        {
          /* This is not the outermost LBRAC...RBRAC pair in the
             function, its local symbols preceded it, and are the ones
@@ -2852,9 +2836,6 @@ no enclosing block"));
          within_function = 0;
        }
 
-      if (VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation))
-       /* Now pop locals of block just finished.  */
-       local_symbols = new->locals;
       break;
 
     case N_FN:
@@ -3095,12 +3076,12 @@ no enclosing block"));
            case 'F':
              function_stab_type = type;
 
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
              /* Deal with the SunPRO 3.0 compiler which omits the
                 address from N_FUN symbols.  */
              if (type == N_FUN
                  && valu == ANOFFSET (section_offsets,
-                                      SECT_OFF_TEXT (objfile)))
+                                      SECT_OFF_TEXT (objfile))
+                 && gdbarch_sofun_address_maybe_missing (current_gdbarch))
                {
                  CORE_ADDR minsym_valu = 
                    find_stab_function_addr (name, last_source_file, objfile);
@@ -3114,7 +3095,6 @@ no enclosing block"));
                  if (minsym_valu != 0)
                    valu = minsym_valu;
                }
-#endif
 
              if (block_address_function_relative)
                /* For Solaris 2 compilers, the block addresses and
@@ -3505,6 +3485,9 @@ static struct sym_fns aout_sym_fns =
   dbx_symfile_read,            /* sym_read: read a symbol file into symtab */
   dbx_symfile_finish,          /* sym_finish: finished with file, cleanup */
   default_symfile_offsets,     /* sym_offsets: parse user's offsets to internal form */
+  default_symfile_segments,    /* sym_segments: Get segment information from
+                                  a file.  */
+  NULL,                         /* sym_read_linetable */
   NULL                         /* next: pointer to next struct sym_fns */
 };
 
This page took 0.031233 seconds and 4 git commands to generate.