tx19 sanitize fixes.
[deliverable/binutils-gdb.git] / gdb / mdebugread.c
index e0d4625c810d3571e6a5a850bc80b975fbb13d55..325afabbfce4cb3a020ed413cea664e919906a3f 100644 (file)
@@ -1,5 +1,5 @@
 /* Read a symbol table in ECOFF format (Third-Eye).
-   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
+   Copyright 1986, 87, 89, 90, 91, 92, 93, 94, 95, 96, 1997
    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
@@ -254,8 +254,8 @@ static int cur_sdx;
 /* Note how much "debuggable" this image is.  We would like
    to see at least one FDR with full symbols */
 
-static max_gdbinfo;
-static max_glevel;
+static int max_gdbinfo;
+static int max_glevel;
 
 /* When examining .o files, report on undefined symbols */
 
@@ -969,7 +969,9 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
                     without qualifiers, assume the tag is an
                     enumeration.
                     Alpha cc -migrate enums are recognized by a zero
-                    index and a zero symbol value.  */
+                    index and a zero symbol value.
+                    DU 4.0 cc enums are recognized by a member type of
+                    btEnum without qualifiers and a zero symbol value.  */
                  if (tsym.index == indexNil
                      || (tsym.index == 0 && sh->value == 0))
                    type_code = TYPE_CODE_ENUM;
@@ -978,7 +980,8 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
                      (*debug_swap->swap_tir_in) (bigend,
                                                  &ax[tsym.index].a_ti,
                                                  &tir);
-                     if ((tir.bt == btNil || tir.bt == btVoid)
+                     if ((tir.bt == btNil || tir.bt == btVoid
+                          || (tir.bt == btEnum && sh->value == 0))
                          && tir.tq0 == tqNil)
                        type_code = TYPE_CODE_ENUM;
                    }
@@ -1124,10 +1127,10 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
                if (tsym.st != stMember)
                  break;
 
-               f->bitpos = tsym.value;
-               f->type = t;
-               f->name = debug_info->ss + cur_fdr->issBase + tsym.iss;
-               f->bitsize = 0;
+               FIELD_BITPOS (*f) = tsym.value;
+               FIELD_TYPE (*f) = t;
+               FIELD_NAME (*f) = debug_info->ss + cur_fdr->issBase + tsym.iss;
+               FIELD_BITSIZE (*f) = 0;
 
                enum_sym = ((struct symbol *)
                            obstack_alloc (&current_objfile->symbol_obstack,
@@ -1314,11 +1317,11 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
 
     case stMember:             /* member of struct or union */
       f = &TYPE_FIELDS (top_stack->cur_type)[top_stack->cur_field++];
-      f->name = name;
-      f->bitpos = sh->value;
+      FIELD_NAME (*f) = name;
+      FIELD_BITPOS (*f) = sh->value;
       bitsize = 0;
-      f->type = parse_type (cur_fd, ax, sh->index, &bitsize, bigend, name);
-      f->bitsize = bitsize;
+      FIELD_TYPE (*f) = parse_type (cur_fd, ax, sh->index, &bitsize, bigend, name);
+      FIELD_BITSIZE (*f) = bitsize;
       break;
 
     case stIndirect:           /* forward declaration on Irix5 */
@@ -1893,14 +1896,13 @@ upgrade_type (fd, tpp, tq, ax, bigend, sym_name)
    to look for the function which contains the MIPS_EFI_SYMBOL_NAME symbol
    in question, or NULL to use top_stack->cur_block.  */
 
-static void parse_procedure PARAMS ((PDR *, struct symtab *, CORE_ADDR,
+static void parse_procedure PARAMS ((PDR *, struct symtab *,
                                     struct partial_symtab *));
 
 static void
-parse_procedure (pr, search_symtab, lowest_pdr_addr, pst)
+parse_procedure (pr, search_symtab, pst)
      PDR *pr;
      struct symtab *search_symtab;
-     CORE_ADDR lowest_pdr_addr;
      struct partial_symtab *pst;
 {
   struct symbol *s, *i;
@@ -2006,7 +2008,18 @@ parse_procedure (pr, search_symtab, lowest_pdr_addr, pst)
       e = (struct mips_extra_func_info *) SYMBOL_VALUE (i);
       e->pdr = *pr;
       e->pdr.isym = (long) s;
-      e->pdr.adr += pst->textlow - lowest_pdr_addr;
+
+      /* GDB expects the absolute function start address for the
+        procedure descriptor in e->pdr.adr.
+        As the address in the procedure descriptor is usually relative,
+        we would have to relocate e->pdr.adr with cur_fdr->adr and
+        ANOFFSET (pst->section_offsets, SECT_OFF_TEXT).
+        Unfortunately cur_fdr->adr and e->pdr.adr are both absolute
+        in shared libraries on some systems, and on other systems
+        e->pdr.adr is sometimes offset by a bogus value.
+        To work around these problems, we replace e->pdr.adr with
+        the start address of the function.  */
+      e->pdr.adr = BLOCK_START (b);
 
       /* Correct incorrect setjmp procedure descriptor from the library
         to make backtrace through setjmp work.  */
@@ -2477,6 +2490,13 @@ parse_partial_symbols (objfile, section_offsets)
 
       cur_fdr = fh = debug_info->fdr + f_idx;
 
+      /* If a partial symbol table has already been read for this file,
+         don't make another one.  This works around a problem with some
+        compilers that emit both DWARF and mdebug sections for a single
+        module.  */
+      if (lookup_partial_symtab (fdr_name (fh)))
+       continue;
+
       if (fh->csym == 0)
        {
          fdr_to_pst[f_idx].pst = NULL;
@@ -2586,6 +2606,7 @@ parse_partial_symbols (objfile, section_offsets)
                                                               mst_file_text,
                                                               NULL,
                                                               SECT_OFF_TEXT,
+                                                              NULL,
                                                               objfile);
                        }
                      procaddr = sh.value;
@@ -2633,6 +2654,7 @@ parse_partial_symbols (objfile, section_offsets)
                                                               mst_file_data,
                                                               NULL,
                                                               SECT_OFF_DATA,
+                                                              NULL,
                                                               objfile);
                          break;
 
@@ -2644,6 +2666,7 @@ parse_partial_symbols (objfile, section_offsets)
                                                               mst_file_bss,
                                                               NULL,
                                                               SECT_OFF_BSS,
+                                                              NULL,
                                                               objfile);
                          break;
                        }
@@ -2725,7 +2748,8 @@ parse_partial_symbols (objfile, section_offsets)
                case stStaticProc:
                  prim_record_minimal_symbol_and_info (name, sh.value,
                                                       mst_file_text, NULL,
-                                                      SECT_OFF_TEXT, objfile);
+                                                      SECT_OFF_TEXT, NULL,
+                                                      objfile);
 
                  /* FALLTHROUGH */
 
@@ -2745,12 +2769,12 @@ parse_partial_symbols (objfile, section_offsets)
                    add_psymbol_to_list (name, strlen (name),
                                         VAR_NAMESPACE, LOC_BLOCK,
                                         &objfile->global_psymbols,
-                                        sh.value, 0, psymtab_language, objfile);
+                                        0, sh.value, psymtab_language, objfile);
                  else
                    add_psymbol_to_list (name, strlen (name),
                                         VAR_NAMESPACE, LOC_BLOCK,
                                         &objfile->static_psymbols,
-                                        sh.value, 0, psymtab_language, objfile);
+                                        0, sh.value, psymtab_language, objfile);
 
                  /* Skip over procedure to next one. */
                  if (sh.index >= hdr->iauxMax)
@@ -2802,11 +2826,13 @@ parse_partial_symbols (objfile, section_offsets)
                    prim_record_minimal_symbol_and_info (name, sh.value,
                                                         mst_file_data, NULL,
                                                         SECT_OFF_DATA,
+                                                        NULL,
                                                         objfile);
                  else
                    prim_record_minimal_symbol_and_info (name, sh.value,
                                                         mst_file_bss, NULL,
                                                         SECT_OFF_BSS,
+                                                        NULL,
                                                         objfile);
                  class = LOC_STATIC;
                  break;
@@ -2841,7 +2867,7 @@ parse_partial_symbols (objfile, section_offsets)
                      add_psymbol_to_list (name, strlen (name),
                                           STRUCT_NAMESPACE, LOC_TYPEDEF,
                                           &objfile->static_psymbols,
-                                          sh.value, 0,
+                                          0, (CORE_ADDR) 0,
                                           psymtab_language, objfile);
                    }
                  handle_psymbol_enumerators (objfile, fh, sh.st, sh.value);
@@ -2879,8 +2905,8 @@ parse_partial_symbols (objfile, section_offsets)
              /* Use this gdb symbol */
              add_psymbol_to_list (name, strlen (name),
                                   VAR_NAMESPACE, class,
-                                  &objfile->static_psymbols, sh.value,
-                                  0, psymtab_language, objfile);
+                                  &objfile->static_psymbols,
+                                  0, sh.value, psymtab_language, objfile);
            skip:
              cur_sdx++;        /* Go to next file symbol */
            }
@@ -3093,7 +3119,9 @@ handle_psymbol_enumerators (objfile, fh, stype, svalue)
         and its auxiliary index is indexNil or its auxiliary entry
         is a plain btNil or btVoid.
         Alpha cc -migrate enums are recognized by a zero index and
-        a zero symbol value.  */
+        a zero symbol value.
+        DU 4.0 cc enums are recognized by a member type of btEnum without
+        qualifiers and a zero symbol value.  */
       (*swap_sym_in) (cur_bfd, ext_sym, &sh);
       if (sh.st != stMember)
        return;
@@ -3105,7 +3133,10 @@ handle_psymbol_enumerators (objfile, fh, stype, svalue)
                                  &(debug_info->external_aux
                                    + fh->iauxBase + sh.index)->a_ti,
                                  &tir);
-      if ((tir.bt != btNil && tir.bt != btVoid) || tir.tq0 != tqNil)
+      if ((tir.bt != btNil
+          && tir.bt != btVoid
+          && (tir.bt != btEnum || svalue != 0))
+         || tir.tq0 != tqNil)
        return;
       break;
 
@@ -3127,7 +3158,7 @@ handle_psymbol_enumerators (objfile, fh, stype, svalue)
       add_psymbol_to_list (name, strlen (name),
                           VAR_NAMESPACE, LOC_CONST,
                           &objfile->static_psymbols, 0,
-                          0, psymtab_language, objfile);
+                          (CORE_ADDR) 0, psymtab_language, objfile);
       ext_sym += external_sym_size;
     }
 }
@@ -3366,7 +3397,7 @@ psymtab_to_symtab_1 (pst, filename)
          pdr_in = pr_block;
          pdr_in_end = pdr_in + fh->cpd;
          for (; pdr_in < pdr_in_end; pdr_in++)
-           parse_procedure (pdr_in, st, lowest_pdr_addr, pst);
+           parse_procedure (pdr_in, st, pst);
 
          do_cleanups (old_chain);
        }
@@ -3480,7 +3511,7 @@ psymtab_to_symtab_1 (pst, filename)
              pdr_in = pr_block;
              pdr_in_end = pdr_in + fh->cpd;
              for (; pdr_in < pdr_in_end; pdr_in++)
-               parse_procedure (pdr_in, 0, lowest_pdr_addr, pst);
+               parse_procedure (pdr_in, 0, pst);
 
              do_cleanups (old_chain);
            }
@@ -3993,7 +4024,8 @@ new_symtab (name, maxsyms, maxlines, objfile)
     BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
 
   s->free_code = free_linetable;
-
+  s->debugformat = obsavestring ("ECOFF", 5,
+                                &objfile -> symbol_obstack);
   return (s);
 }
 
This page took 0.02793 seconds and 4 git commands to generate.