linux-thread-db.c (record_thread): Return the created thread.
[deliverable/binutils-gdb.git] / gdb / mdebugread.c
index bcbd9b0d7886419c0e8892ed69ba3436bd532fb3..f8338f418bf8a2bc88bff1f435c7276231fe1b1a 100644 (file)
@@ -1,6 +1,6 @@
 /* Read a symbol table in ECOFF format (Third-Eye).
 
-   Copyright (C) 1986-2014 Free Software Foundation, Inc.
+   Copyright (C) 1986-2015 Free Software Foundation, Inc.
 
    Original version contributed by Alessandro Forin (af@cs.cmu.edu) at
    CMU.  Major work by Per Bothner, John Gilmore and Ian Lance Taylor
@@ -430,24 +430,24 @@ static struct parse_stack
 static void
 push_parse_stack (void)
 {
-  struct parse_stack *new;
+  struct parse_stack *newobj;
 
   /* Reuse frames if possible.  */
   if (top_stack && top_stack->prev)
-    new = top_stack->prev;
+    newobj = top_stack->prev;
   else
-    new = (struct parse_stack *) xzalloc (sizeof (struct parse_stack));
+    newobj = XCNEW (struct parse_stack);
   /* Initialize new frame with previous content.  */
   if (top_stack)
     {
-      struct parse_stack *prev = new->prev;
+      struct parse_stack *prev = newobj->prev;
 
-      *new = *top_stack;
-      top_stack->prev = new;
-      new->prev = prev;
-      new->next = top_stack;
+      *newobj = *top_stack;
+      top_stack->prev = newobj;
+      newobj->prev = prev;
+      newobj->next = top_stack;
     }
-  top_stack = new;
+  top_stack = newobj;
 }
 
 /* Exit a lexical context.  */
@@ -559,7 +559,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
   struct type *t;
   struct field *f;
   int count = 1;
-  enum address_class class;
+  enum address_class theclass;
   TIR tir;
   long svalue = sh->value;
   int bitsize;
@@ -600,7 +600,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       break;
 
     case stGlobal:             /* External symbol, goes into global block.  */
-      class = LOC_STATIC;
+      theclass = LOC_STATIC;
       b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (top_stack->cur_st),
                             GLOBAL_BLOCK);
       s = new_symbol (name);
@@ -608,7 +608,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       goto data;
 
     case stStatic:             /* Static data, goes into current block.  */
-      class = LOC_STATIC;
+      theclass = LOC_STATIC;
       b = top_stack->cur_block;
       s = new_symbol (name);
       if (SC_IS_COMMON (sh->sc))
@@ -629,13 +629,13 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       s = new_symbol (name);
       SYMBOL_VALUE (s) = svalue;
       if (sh->sc == scRegister)
-       class = mdebug_register_index;
+       theclass = mdebug_register_index;
       else
-       class = LOC_LOCAL;
+       theclass = LOC_LOCAL;
 
     data:                      /* Common code for symbols describing data.  */
       SYMBOL_DOMAIN (s) = VAR_DOMAIN;
-      SYMBOL_ACLASS_INDEX (s) = class;
+      SYMBOL_ACLASS_INDEX (s) = theclass;
       add_symbol (s, top_stack->cur_st, b);
 
       /* Type could be missing if file is compiled without debugging info.  */
@@ -2395,8 +2395,7 @@ parse_partial_symbols (struct objfile *objfile)
   /* Allocate the map FDR -> PST.
      Minor hack: -O3 images might claim some global data belongs
      to FDR -1.  We`ll go along with that.  */
-  fdr_to_pst = (struct pst_map *)
-    xzalloc ((hdr->ifdMax + 1) * sizeof *fdr_to_pst);
+  fdr_to_pst = XCNEWVEC (struct pst_map, hdr->ifdMax + 1);
   old_chain = make_cleanup (xfree, fdr_to_pst);
   fdr_to_pst++;
   {
@@ -2415,7 +2414,7 @@ parse_partial_symbols (struct objfile *objfile)
          hdr->ifdMax * sizeof (struct mdebug_pending *));
 
   /* Pass 0 over external syms: swap them in.  */
-  ext_block = (EXTR *) xmalloc (hdr->iextMax * sizeof (EXTR));
+  ext_block = XNEWVEC (EXTR, hdr->iextMax);
   make_cleanup (xfree, ext_block);
 
   ext_out = (char *) debug_info->external_ext;
@@ -2646,7 +2645,7 @@ parse_partial_symbols (struct objfile *objfile)
        }
       else
        textlow = 0;
-      pst = start_psymtab_common (objfile, objfile->section_offsets,
+      pst = start_psymtab_common (objfile,
                                  fdr_name (fh),
                                  textlow,
                                  objfile->global_psymbols.next,
@@ -2936,7 +2935,7 @@ parse_partial_symbols (struct objfile *objfile)
                      prev_textlow_not_set = textlow_not_set;
 
                      /* A zero value is probably an indication for the
-                        SunPRO 3.0 compiler.  end_psymtab explicitly tests
+                        SunPRO 3.0 compiler.  dbx_end_psymtab explicitly tests
                         for zero, so don't relocate it.  */
 
                      if (sh.value == 0
@@ -3110,7 +3109,7 @@ parse_partial_symbols (struct objfile *objfile)
                        add_psymbol_to_list (namestring, p - namestring, 1,
                                             VAR_DOMAIN, LOC_STATIC,
                                             &objfile->static_psymbols,
-                                            0, sh.value,
+                                            sh.value,
                                             psymtab_language, objfile);
                        continue;
                      case 'G':
@@ -3122,7 +3121,7 @@ parse_partial_symbols (struct objfile *objfile)
                        add_psymbol_to_list (namestring, p - namestring, 1,
                                             VAR_DOMAIN, LOC_STATIC,
                                             &objfile->global_psymbols,
-                                            0, sh.value,
+                                            sh.value,
                                             psymtab_language, objfile);
                        continue;
 
@@ -3140,8 +3139,7 @@ parse_partial_symbols (struct objfile *objfile)
                            add_psymbol_to_list (namestring, p - namestring, 1,
                                                 STRUCT_DOMAIN, LOC_TYPEDEF,
                                                 &objfile->static_psymbols,
-                                                sh.value, 0,
-                                                psymtab_language, objfile);
+                                                0, psymtab_language, objfile);
                            if (p[2] == 't')
                              {
                                /* Also a typedef with the same name.  */
@@ -3149,8 +3147,7 @@ parse_partial_symbols (struct objfile *objfile)
                                                     p - namestring, 1,
                                                     VAR_DOMAIN, LOC_TYPEDEF,
                                                     &objfile->static_psymbols,
-                                                    sh.value, 0,
-                                                    psymtab_language,
+                                                    0, psymtab_language,
                                                     objfile);
                                p += 1;
                              }
@@ -3163,8 +3160,7 @@ parse_partial_symbols (struct objfile *objfile)
                            add_psymbol_to_list (namestring, p - namestring, 1,
                                                 VAR_DOMAIN, LOC_TYPEDEF,
                                                 &objfile->static_psymbols,
-                                                sh.value, 0,
-                                                psymtab_language, objfile);
+                                                0, psymtab_language, objfile);
                          }
                      check_enum:
                        /* If this is an enumerated type, we need to add
@@ -3228,7 +3224,7 @@ parse_partial_symbols (struct objfile *objfile)
                                add_psymbol_to_list (p, q - p, 1,
                                                     VAR_DOMAIN, LOC_CONST,
                                                     &objfile->static_psymbols,
-                                                    0, 0, psymtab_language,
+                                                    0, psymtab_language,
                                                     objfile);
                                /* Point past the name.  */
                                p = q;
@@ -3246,8 +3242,7 @@ parse_partial_symbols (struct objfile *objfile)
                        add_psymbol_to_list (namestring, p - namestring, 1,
                                             VAR_DOMAIN, LOC_CONST,
                                             &objfile->static_psymbols,
-                                            sh.value, 0, psymtab_language,
-                                            objfile);
+                                            0, psymtab_language, objfile);
                        continue;
 
                      case 'f':
@@ -3266,7 +3261,7 @@ parse_partial_symbols (struct objfile *objfile)
                        add_psymbol_to_list (namestring, p - namestring, 1,
                                             VAR_DOMAIN, LOC_BLOCK,
                                             &objfile->static_psymbols,
-                                            0, sh.value,
+                                            sh.value,
                                             psymtab_language, objfile);
                        continue;
 
@@ -3290,7 +3285,7 @@ parse_partial_symbols (struct objfile *objfile)
                        add_psymbol_to_list (namestring, p - namestring, 1,
                                             VAR_DOMAIN, LOC_BLOCK,
                                             &objfile->global_psymbols,
-                                            0, sh.value,
+                                            sh.value,
                                             psymtab_language, objfile);
                        continue;
 
@@ -3347,7 +3342,7 @@ parse_partial_symbols (struct objfile *objfile)
 
                  case N_ENDM:
                    /* Solaris 2 end of module, finish current partial
-                      symbol table.  END_PSYMTAB will set
+                      symbol table.  dbx_end_psymtab will set
                       pst->texthigh to the proper value, which is
                       necessary if a module compiled without
                       debugging info follows this module.  */
@@ -3416,7 +3411,7 @@ parse_partial_symbols (struct objfile *objfile)
          for (cur_sdx = 0; cur_sdx < fh->csym;)
            {
              char *name;
-             enum address_class class;
+             enum address_class theclass;
              CORE_ADDR minsym_value;
 
              (*swap_sym_in) (cur_bfd,
@@ -3533,12 +3528,12 @@ parse_partial_symbols (struct objfile *objfile)
                    add_psymbol_to_list (name, strlen (name), 1,
                                         VAR_DOMAIN, LOC_BLOCK,
                                         &objfile->global_psymbols,
-                                   0, sh.value, psymtab_language, objfile);
+                                        sh.value, psymtab_language, objfile);
                  else
                    add_psymbol_to_list (name, strlen (name), 1,
                                         VAR_DOMAIN, LOC_BLOCK,
                                         &objfile->static_psymbols,
-                                   0, sh.value, psymtab_language, objfile);
+                                        sh.value, psymtab_language, objfile);
 
                  procaddr = sh.value;
 
@@ -3572,7 +3567,7 @@ parse_partial_symbols (struct objfile *objfile)
                                                         mst_file_bss,
                                                         SECT_OFF_BSS (objfile),
                                                         objfile);
-                 class = LOC_STATIC;
+                 theclass = LOC_STATIC;
                  break;
 
                case stIndirect:        /* Irix5 forward declaration */
@@ -3584,11 +3579,11 @@ parse_partial_symbols (struct objfile *objfile)
                     structs from alpha and mips cc.  */
                  if (sh.iss == 0 || has_opaque_xref (fh, &sh))
                    goto skip;
-                 class = LOC_TYPEDEF;
+                 theclass = LOC_TYPEDEF;
                  break;
 
                case stConstant:        /* Constant decl */
-                 class = LOC_CONST;
+                 theclass = LOC_CONST;
                  break;
 
                case stUnion:
@@ -3605,8 +3600,7 @@ parse_partial_symbols (struct objfile *objfile)
                      add_psymbol_to_list (name, strlen (name), 1,
                                           STRUCT_DOMAIN, LOC_TYPEDEF,
                                           &objfile->static_psymbols,
-                                          0, (CORE_ADDR) 0,
-                                          psymtab_language, objfile);
+                                          0, psymtab_language, objfile);
                    }
                  handle_psymbol_enumerators (objfile, fh, sh.st, sh.value);
 
@@ -3644,9 +3638,9 @@ parse_partial_symbols (struct objfile *objfile)
                }
              /* Use this gdb symbol.  */
              add_psymbol_to_list (name, strlen (name), 1,
-                                  VAR_DOMAIN, class,
+                                  VAR_DOMAIN, theclass,
                                   &objfile->static_psymbols,
-                                  0, sh.value, psymtab_language, objfile);
+                                  sh.value, psymtab_language, objfile);
            skip:
              cur_sdx++;        /* Go to next file symbol.  */
            }
@@ -3658,7 +3652,7 @@ parse_partial_symbols (struct objfile *objfile)
          PST_PRIVATE (save_pst)->extern_tab = ext_ptr;
          for (; --cur_sdx >= 0; ext_ptr++)
            {
-             enum address_class class;
+             enum address_class theclass;
              SYMR *psh;
              char *name;
              CORE_ADDR svalue;
@@ -3708,7 +3702,7 @@ parse_partial_symbols (struct objfile *objfile)
                     Ignore them, as parse_external will ignore them too.  */
                  continue;
                case stLabel:
-                 class = LOC_LABEL;
+                 theclass = LOC_LABEL;
                  break;
                default:
                  unknown_ext_complaint (debug_info->ssext + psh->iss);
@@ -3719,24 +3713,25 @@ parse_partial_symbols (struct objfile *objfile)
                  if (SC_IS_COMMON (psh->sc))
                    continue;
 
-                 class = LOC_STATIC;
+                 theclass = LOC_STATIC;
                  break;
                }
              name = debug_info->ssext + psh->iss;
              add_psymbol_to_list (name, strlen (name), 1,
-                                  VAR_DOMAIN, class,
+                                  VAR_DOMAIN, theclass,
                                   &objfile->global_psymbols,
-                                  0, svalue,
-                                  psymtab_language, objfile);
+                                  svalue, psymtab_language, objfile);
            }
        }
 
-      /* Link pst to FDR.  end_psymtab returns NULL if the psymtab was
+      /* Link pst to FDR.  dbx_end_psymtab returns NULL if the psymtab was
          empty and put on the free list.  */
-      fdr_to_pst[f_idx].pst = end_psymtab (objfile, save_pst,
-                                       psymtab_include_list, includes_used,
-                                          -1, save_pst->texthigh,
-                      dependency_list, dependencies_used, textlow_not_set);
+      fdr_to_pst[f_idx].pst
+       = dbx_end_psymtab (objfile, save_pst,
+                          psymtab_include_list, includes_used,
+                          -1, save_pst->texthigh,
+                          dependency_list, dependencies_used,
+                          textlow_not_set);
       includes_used = 0;
       dependencies_used = 0;
 
@@ -3889,8 +3884,8 @@ handle_psymbol_enumerators (struct objfile *objfile, FDR *fh, int stype,
          in psymtabs, just in symtabs.  */
       add_psymbol_to_list (name, strlen (name), 1,
                           VAR_DOMAIN, LOC_CONST,
-                          &objfile->static_psymbols, 0,
-                          (CORE_ADDR) 0, psymtab_language, objfile);
+                          &objfile->static_psymbols,
+                          0, psymtab_language, objfile);
       ext_sym += external_sym_size;
     }
 }
@@ -3935,6 +3930,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
   struct linetable *lines;
   CORE_ADDR lowest_pdr_addr = 0;
   int last_symtab_ended = 0;
+  struct section_offsets *section_offsets = objfile->section_offsets;
 
   if (pst->readin)
     return;
@@ -4051,7 +4047,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
                      && previous_stab_code != (unsigned char) N_SO
                      && *name == '\000')
                    {
-                     valu += ANOFFSET (pst->section_offsets,
+                     valu += ANOFFSET (section_offsets,
                                        SECT_OFF_TEXT (objfile));
                      previous_stab_code = N_SO;
                      cust = end_symtab (valu, SECT_OFF_TEXT (objfile));
@@ -4062,14 +4058,14 @@ psymtab_to_symtab_1 (struct objfile *objfile,
                    {
                      last_symtab_ended = 0;
                      process_one_symbol (type_code, 0, valu, name,
-                                         pst->section_offsets, objfile);
+                                         section_offsets, objfile);
                    }
                }
              /* Similarly a hack.  */
              else if (name[0] == '#')
                {
                  process_one_symbol (N_SLINE, 0, valu, name,
-                                     pst->section_offsets, objfile);
+                                     section_offsets, objfile);
                }
              if (type_code == N_FUN)
                {
@@ -4101,7 +4097,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
              else
                {
                  /* Handle encoded stab line number.  */
-                 valu += ANOFFSET (pst->section_offsets,
+                 valu += ANOFFSET (section_offsets,
                                    SECT_OFF_TEXT (objfile));
                  record_line (current_subfile, sh.index,
                               gdbarch_addr_bits_remove (gdbarch, valu));
@@ -4138,7 +4134,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
          PDR *pdr_in;
          PDR *pdr_in_end;
 
-         pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR));
+         pr_block = XNEWVEC (PDR, fh->cpd);
          old_chain = make_cleanup (xfree, pr_block);
 
          pdr_ptr = ((char *) debug_info->external_pdr
@@ -4225,7 +4221,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
              c = parse_symbol (&sh,
                                debug_info->external_aux + fh->iauxBase,
                                sym_ptr, fh->fBigendian,
-                               pst->section_offsets, objfile);
+                               section_offsets, objfile);
              sym_ptr += c * external_sym_size;
            }
 
@@ -4241,7 +4237,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
              PDR *pdr_in;
              PDR *pdr_in_end;
 
-             pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR));
+             pr_block = XNEWVEC (PDR, fh->cpd);
 
              old_chain = make_cleanup (xfree, pr_block);
 
@@ -4300,7 +4296,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
       ext_ptr = PST_PRIVATE (pst)->extern_tab;
       for (i = PST_PRIVATE (pst)->extern_count; --i >= 0; ext_ptr++)
        parse_external (ext_ptr, fh->fBigendian,
-                       pst->section_offsets, objfile);
+                       section_offsets, objfile);
 
       /* If there are undefined symbols, tell the user.
          The alpha has an undefined symbol for every symbol that is
@@ -4380,7 +4376,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp,
   int xref_fd;
   struct mdebug_pending *pend;
 
-  *tpp = (struct type *) NULL;
+  *tpp = NULL;
 
   (*debug_swap->swap_rndx_in) (bigend, &ax->a_rndx, rn);
 
@@ -4568,7 +4564,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp,
 
 static struct symbol *
 mylookup_symbol (char *name, const struct block *block,
-                domain_enum domain, enum address_class class)
+                domain_enum domain, enum address_class theclass)
 {
   struct block_iterator iter;
   int inc;
@@ -4579,14 +4575,14 @@ mylookup_symbol (char *name, const struct block *block,
     {
       if (SYMBOL_LINKAGE_NAME (sym)[0] == inc
          && SYMBOL_DOMAIN (sym) == domain
-         && SYMBOL_CLASS (sym) == class
+         && SYMBOL_CLASS (sym) == theclass
          && strcmp (SYMBOL_LINKAGE_NAME (sym), name) == 0)
        return sym;
     }
 
   block = BLOCK_SUPERBLOCK (block);
   if (block)
-    return mylookup_symbol (name, block, domain, class);
+    return mylookup_symbol (name, block, domain, theclass);
   return 0;
 }
 
@@ -4596,7 +4592,7 @@ mylookup_symbol (char *name, const struct block *block,
 static void
 add_symbol (struct symbol *s, struct symtab *symtab, struct block *b)
 {
-  SYMBOL_SYMTAB (s) = symtab;
+  symbol_set_symtab (s, symtab);
   dict_add_symbol (BLOCK_DICT (b), s);
 }
 
@@ -4758,7 +4754,6 @@ new_psymtab (char *name, struct objfile *objfile)
   struct partial_symtab *psymtab;
 
   psymtab = allocate_psymtab (name, objfile);
-  psymtab->section_offsets = objfile->section_offsets;
 
   /* Keep a backpointer to the file's symbols.  */
 
@@ -4835,7 +4830,7 @@ new_block (enum block_type type)
   /* FIXME: carlton/2003-09-11: This should use allocate_block to
      allocate the block.  Which, in turn, suggests that the block
      should be allocated on an obstack.  */
-  struct block *retval = xzalloc (sizeof (struct block));
+  struct block *retval = XCNEW (struct block);
 
   if (type == FUNCTION_BLOCK)
     BLOCK_DICT (retval) = dict_create_linear_expandable ();
This page took 0.031494 seconds and 4 git commands to generate.