Simplify calls to init_psymbol_list
[deliverable/binutils-gdb.git] / gdb / xcoffread.c
index ba377d497bf989cd53a25019b028a7f097305774..50da0789755289943ac5696dbd45bf0377b0fcbf 100644 (file)
@@ -1,5 +1,5 @@
 /* Read AIX xcoff symbol tables and convert to internal format, for GDB.
-   Copyright (C) 1986-2018 Free Software Foundation, Inc.
+   Copyright (C) 1986-2019 Free Software Foundation, Inc.
    Derived from coffread.c, dbxread.c, and a lot of hacking.
    Contributed by IBM Corporation.
 
@@ -41,7 +41,7 @@
 /* FIXME: ezannoni/2004-02-13 Verify if the include below is really needed.  */
 #include "symfile.h"
 #include "objfiles.h"
-#include "buildsym.h"
+#include "buildsym-legacy.h"
 #include "stabsread.h"
 #include "expression.h"
 #include "complaints.h"
@@ -1022,6 +1022,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
   int just_started = 1;
   int depth = 0;
   CORE_ADDR fcn_start_addr = 0;
+  enum language pst_symtab_language;
 
   struct coff_symbol fcn_stab_saved = { 0 };
 
@@ -1042,10 +1043,11 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 
   set_last_source_file (NULL);
   last_csect_name = 0;
+  pst_symtab_language = deduce_language_from_filename (filestring);
 
   start_stabs ();
   start_symtab (objfile, filestring, (char *) NULL, file_start_addr,
-               language_unknown);
+               pst_symtab_language);
   record_debugformat (debugfmt);
   symnum = ((struct symloc *) pst->read_symtab_private)->first_symnum;
   max_symnum =
@@ -1138,8 +1140,8 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
            }
 
          start_stabs ();
-         start_symtab (objfile, "_globals_", (char *) NULL, (CORE_ADDR) 0,
-                       language_unknown);
+         start_symtab (objfile, "_globals_", (char *) NULL,
+                       (CORE_ADDR) 0, pst_symtab_language);
          record_debugformat (debugfmt);
          cur_src_end_addr = first_object_file_end;
          /* Done with all files, everything from here on is globals.  */
@@ -1229,7 +1231,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
                          /* Give all csects for this source file the same
                             name.  */
                          start_symtab (objfile, filestring, NULL,
-                                       (CORE_ADDR) 0, language_unknown);
+                                       (CORE_ADDR) 0, pst_symtab_language);
                          record_debugformat (debugfmt);
                        }
 
@@ -1350,7 +1352,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 
          start_stabs ();
          start_symtab (objfile, filestring, (char *) NULL, (CORE_ADDR) 0,
-                       language_unknown);
+                       pst_symtab_language);
          record_debugformat (debugfmt);
          last_csect_name = 0;
 
@@ -1421,12 +1423,12 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
        case C_BSTAT:
          /* Begin static block.  */
          {
-           struct internal_syment symbol;
+           struct internal_syment static_symbol;
 
-           read_symbol (&symbol, cs->c_value);
-           static_block_base = symbol.n_value;
+           read_symbol (&static_symbol, cs->c_value);
+           static_block_base = static_symbol.n_value;
            static_block_section =
-             secnum_to_section (symbol.n_scnum, objfile);
+             secnum_to_section (static_symbol.n_scnum, objfile);
          }
          break;
 
@@ -2024,16 +2026,13 @@ static unsigned int first_fun_line_offset;
 
 static struct partial_symtab *
 xcoff_start_psymtab (struct objfile *objfile,
-                    const char *filename, int first_symnum,
-                    std::vector<partial_symbol *> &global_psymbols,
-                    std::vector<partial_symbol *> &static_psymbols)
+                    const char *filename, int first_symnum)
 {
   struct partial_symtab *result =
     start_psymtab_common (objfile,
                          filename,
                          /* We fill in textlow later.  */
-                         0,
-                         global_psymbols, static_psymbols);
+                         0);
 
   result->read_symtab_private =
     XOBNEW (&objfile->objfile_obstack, struct symloc);
@@ -2093,8 +2092,6 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       subpst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, symloc);
       ((struct symloc *) subpst->read_symtab_private)->first_symnum = 0;
       ((struct symloc *) subpst->read_symtab_private)->numsyms = 0;
-      subpst->textlow = 0;
-      subpst->texthigh = 0;
 
       /* We could save slight bits of space by only making one of these,
          shared by the entire set of include files.  FIXME-someday.  */
@@ -2103,13 +2100,6 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       subpst->dependencies[0] = pst;
       subpst->number_of_dependencies = 1;
 
-      subpst->globals_offset =
-       subpst->n_global_syms =
-       subpst->statics_offset =
-       subpst->n_static_syms = 0;
-
-      subpst->readin = 0;
-      subpst->compunit_symtab = NULL;
       subpst->read_symtab = pst->read_symtab;
     }
 
@@ -2324,9 +2314,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                            pst = xcoff_start_psymtab
                              (objfile,
                               filestring,
-                              symnum_before,
-                              objfile->global_psymbols,
-                              objfile->static_psymbols);
+                              symnum_before);
                          }
                      }
                    /* Activate the misc_func_recorded mechanism for
@@ -2344,10 +2332,11 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                        CORE_ADDR highval =
                          symbol.n_value + csect_aux.x_csect.x_scnlen.l;
 
-                       if (highval > pst->texthigh)
-                         pst->texthigh = highval;
-                       if (pst->textlow == 0 || symbol.n_value < pst->textlow)
-                         pst->textlow = symbol.n_value;
+                       if (highval > pst->raw_text_high ())
+                         pst->set_text_high (highval);
+                       if (!pst->text_low_valid
+                           || symbol.n_value < pst->raw_text_low ())
+                         pst->set_text_low (symbol.n_value);
                      }
                    misc_func_recorded = 0;
                    break;
@@ -2507,9 +2496,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 
            pst = xcoff_start_psymtab (objfile,
                                       filestring,
-                                      symnum_before,
-                                      objfile->global_psymbols,
-                                      objfile->static_psymbols);
+                                      symnum_before);
            last_csect_name = NULL;
          }
          break;
@@ -2660,28 +2647,25 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
            switch (p[1])
              {
              case 'S':
-               symbol.n_value += ANOFFSET (objfile->section_offsets,
-                                           SECT_OFF_DATA (objfile));
-
                if (gdbarch_static_transform_name_p (gdbarch))
                  namestring = gdbarch_static_transform_name
                                 (gdbarch, namestring);
 
                add_psymbol_to_list (namestring, p - namestring, 1,
                                     VAR_DOMAIN, LOC_STATIC,
-                                    &objfile->static_psymbols,
+                                    SECT_OFF_DATA (objfile),
+                                    psymbol_placement::STATIC,
                                     symbol.n_value,
                                     psymtab_language, objfile);
                continue;
 
              case 'G':
-               symbol.n_value += ANOFFSET (objfile->section_offsets,
-                                           SECT_OFF_DATA (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, 1,
                                     VAR_DOMAIN, LOC_STATIC,
-                                    &objfile->global_psymbols,
+                                    SECT_OFF_DATA (objfile),
+                                    psymbol_placement::GLOBAL,
                                     symbol.n_value,
                                     psymtab_language, objfile);
                continue;
@@ -2698,15 +2682,15 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                        && namestring[0] != ' '))
                  {
                    add_psymbol_to_list (namestring, p - namestring, 1,
-                                        STRUCT_DOMAIN, LOC_TYPEDEF,
-                                        &objfile->static_psymbols,
+                                        STRUCT_DOMAIN, LOC_TYPEDEF, -1,
+                                        psymbol_placement::STATIC,
                                         0, psymtab_language, objfile);
                    if (p[2] == 't')
                      {
                        /* Also a typedef with the same name.  */
                        add_psymbol_to_list (namestring, p - namestring, 1,
-                                            VAR_DOMAIN, LOC_TYPEDEF,
-                                            &objfile->static_psymbols,
+                                            VAR_DOMAIN, LOC_TYPEDEF, -1,
+                                            psymbol_placement::STATIC,
                                             0, psymtab_language, objfile);
                        p += 1;
                      }
@@ -2717,8 +2701,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                if (p != namestring)    /* a name is there, not just :T...  */
                  {
                    add_psymbol_to_list (namestring, p - namestring, 1,
-                                        VAR_DOMAIN, LOC_TYPEDEF,
-                                        &objfile->static_psymbols,
+                                        VAR_DOMAIN, LOC_TYPEDEF, -1,
+                                        psymbol_placement::STATIC,
                                         0, psymtab_language, objfile);
                  }
              check_enum:
@@ -2779,8 +2763,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                        /* Note that the value doesn't matter for
                           enum constants in psymtabs, just in symtabs.  */
                        add_psymbol_to_list (p, q - p, 1,
-                                            VAR_DOMAIN, LOC_CONST,
-                                            &objfile->static_psymbols,
+                                            VAR_DOMAIN, LOC_CONST, -1,
+                                            psymbol_placement::STATIC,
                                             0, psymtab_language, objfile);
                        /* Point past the name.  */
                        p = q;
@@ -2797,8 +2781,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
              case 'c':
                /* Constant, e.g. from "const" in Pascal.  */
                add_psymbol_to_list (namestring, p - namestring, 1,
-                                    VAR_DOMAIN, LOC_CONST,
-                                    &objfile->static_psymbols,
+                                    VAR_DOMAIN, LOC_CONST, -1,
+                                    psymbol_placement::STATIC,
                                     0, psymtab_language, objfile);
                continue;
 
@@ -2813,11 +2797,10 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                    function_outside_compilation_unit_complaint (name);
                    xfree (name);
                  }
-               symbol.n_value += ANOFFSET (objfile->section_offsets,
-                                           SECT_OFF_TEXT (objfile));
                add_psymbol_to_list (namestring, p - namestring, 1,
                                     VAR_DOMAIN, LOC_BLOCK,
-                                    &objfile->static_psymbols,
+                                    SECT_OFF_TEXT (objfile),
+                                    psymbol_placement::STATIC,
                                     symbol.n_value,
                                     psymtab_language, objfile);
                continue;
@@ -2844,11 +2827,10 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                if (startswith (namestring, "@FIX"))
                  continue;
 
-               symbol.n_value += ANOFFSET (objfile->section_offsets,
-                                           SECT_OFF_TEXT (objfile));
                add_psymbol_to_list (namestring, p - namestring, 1,
                                     VAR_DOMAIN, LOC_BLOCK,
-                                    &objfile->global_psymbols,
+                                    SECT_OFF_TEXT (objfile),
+                                    psymbol_placement::GLOBAL,
                                     symbol.n_value,
                                     psymtab_language, objfile);
                continue;
@@ -3009,14 +2991,11 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
   if (val != size)
     perror_with_name (_("reading symbol table"));
 
-  /* If we are reinitializing, or if we have never loaded syms yet, init.  */
-  if (objfile->global_psymbols.capacity () == 0
-      && objfile->static_psymbols.capacity () == 0)
-    /* I'm not sure how how good num_symbols is; the rule of thumb in
-       init_psymbol_list was developed for a.out.  On the one hand,
-       num_symbols includes auxents.  On the other hand, it doesn't
-       include N_SLINE.  */
-    init_psymbol_list (objfile, num_symbols);
+  /* I'm not sure how how good num_symbols is; the rule of thumb in
+     init_psymbol_list was developed for a.out.  On the one hand,
+     num_symbols includes auxents.  On the other hand, it doesn't
+     include N_SLINE.  */
+  init_psymbol_list (objfile, num_symbols);
 
   scoped_free_pendings free_pending;
   minimal_symbol_reader reader (objfile);
This page took 0.02821 seconds and 4 git commands to generate.