Add detection of IMB and IMBRange SWIs.
[deliverable/binutils-gdb.git] / gdb / mdebugread.c
index 489c20f7eeca449230405ad5ba4fd5ebb7826c8a..12b84553b0f1340dc1b2050b8e5074ba35010bbe 100644 (file)
@@ -1,5 +1,5 @@
 /* Read a symbol table in ECOFF format (Third-Eye).
-   Copyright 1986, 87, 89, 90, 91, 92, 93, 94, 95, 96, 1997
+   Copyright 1986, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998
    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
@@ -88,6 +88,7 @@ typedef struct mips_extra_func_info {
 #include "expression.h"
 #include "language.h"          /* Needed inside partial-stab.h */
 
+extern void _initialize_mdebugread PARAMS ((void));
 
 /* Provide a default mapping from a ecoff register number to a gdb REGNUM.  */
 #ifndef ECOFF_REG_TO_REGNUM
@@ -988,26 +989,28 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
 
              case stMember:
                if (nfields == 0 && type_code == TYPE_CODE_UNDEF)
-                 /* If the type of the member is Nil (or Void),
-                    without qualifiers, assume the tag is an
-                    enumeration.
-                    Alpha cc -migrate enums are recognized by a zero
-                    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;
-                 else
-                   {
-                     (*debug_swap->swap_tir_in) (bigend,
-                                                 &ax[tsym.index].a_ti,
-                                                 &tir);
-                     if ((tir.bt == btNil || tir.bt == btVoid
-                          || (tir.bt == btEnum && sh->value == 0))
-                         && tir.tq0 == tqNil)
-                       type_code = TYPE_CODE_ENUM;
-                   }
+                 {
+                   /* If the type of the member is Nil (or Void),
+                      without qualifiers, assume the tag is an
+                      enumeration.
+                      Alpha cc -migrate enums are recognized by a zero
+                      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;
+                   else
+                     {
+                       (*debug_swap->swap_tir_in) (bigend,
+                                                   &ax[tsym.index].a_ti,
+                                                   &tir);
+                       if ((tir.bt == btNil || tir.bt == btVoid
+                            || (tir.bt == btEnum && sh->value == 0))
+                           && tir.tq0 == tqNil)
+                         type_code = TYPE_CODE_ENUM;
+                     }
+                 }
                nfields++;
                if (tsym.value > max_value)
                  max_value = tsym.value;
@@ -1090,10 +1093,12 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
           here.) */
 
        if (type_code == TYPE_CODE_UNDEF)
-         if (nfields > 1 && max_value == 0)
-           type_code = TYPE_CODE_UNION;
-         else
-           type_code = TYPE_CODE_STRUCT;
+         {
+           if (nfields > 1 && max_value == 0)
+             type_code = TYPE_CODE_UNION;
+           else
+             type_code = TYPE_CODE_STRUCT;
+         }
 
        /* Create a new type or use the pending type.  */
        pend = is_pending_symbol (cur_fdr, ext_sh);
@@ -2431,111 +2436,109 @@ parse_partial_symbols (objfile, section_offsets)
      Skip the creation of the minimal symbols based on the ECOFF 
      symbol table. */
 
-  if (ECOFF_IN_ELF(cur_bfd))
-    {
-      /* Pass 2 over external syms: fill in external symbols */
-      ext_in = ext_block;
-      ext_in_end = ext_in + hdr->iextMax;
-      for (; ext_in < ext_in_end; ext_in++)
-       {
-         enum minimal_symbol_type ms_type = mst_text;
-         CORE_ADDR svalue = ext_in->asym.value;
+    /* Pass 2 over external syms: fill in external symbols */
+    ext_in = ext_block;
+    ext_in_end = ext_in + hdr->iextMax;
+    for (; ext_in < ext_in_end; ext_in++)
+      {
+       enum minimal_symbol_type ms_type = mst_text;
+       CORE_ADDR svalue = ext_in->asym.value;
 
-         /* The Irix 5 native tools seem to sometimes generate bogus
-            external symbols.  */
-         if (ext_in->ifd < -1 || ext_in->ifd >= hdr->ifdMax)
-           {
-             complain (&bad_ext_ifd_complaint, ext_in->ifd, hdr->ifdMax);
-             continue;
-           }
-         if (ext_in->asym.iss < 0 || ext_in->asym.iss >= hdr->issExtMax)
-           {
-             complain (&bad_ext_iss_complaint, ext_in->asym.iss,
+       /* The Irix 5 native tools seem to sometimes generate bogus
+          external symbols.  */
+       if (ext_in->ifd < -1 || ext_in->ifd >= hdr->ifdMax)
+         {
+           complain (&bad_ext_ifd_complaint, ext_in->ifd, hdr->ifdMax);
+           continue;
+         }
+       if (ext_in->asym.iss < 0 || ext_in->asym.iss >= hdr->issExtMax)
+         {
+           complain (&bad_ext_iss_complaint, ext_in->asym.iss,
                        hdr->issExtMax);
-             continue;
-           }
+           continue;
+         }
 
-         extern_tab[fdr_to_pst[ext_in->ifd].globals_offset
-                    + fdr_to_pst[ext_in->ifd].n_globals++] = *ext_in;
+       extern_tab[fdr_to_pst[ext_in->ifd].globals_offset
+                  + fdr_to_pst[ext_in->ifd].n_globals++] = *ext_in;
 
 
-         if (SC_IS_UNDEF(ext_in->asym.sc) || ext_in->asym.sc == scNil)
-           continue;
+       if (SC_IS_UNDEF(ext_in->asym.sc) || ext_in->asym.sc == scNil)
+         continue;
 
-      
-         /* Pass 3 over files, over local syms: fill in static symbols */
-         name = debug_info->ssext + ext_in->asym.iss;
+    
+       /* Pass 3 over files, over local syms: fill in static symbols */
+       name = debug_info->ssext + ext_in->asym.iss;
 
-         /* Process ECOFF Symbol Types and Storage Classes */
-         switch (ext_in->asym.st)
-           {
-           case stProc:
-             /* Beginnning of Procedure */
-             svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT);
-             break;
-           case stStaticProc:
-             /* Load time only static procs */
-             ms_type = mst_file_text;
-             svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT);
-             break;
-           case stGlobal:
-             /* External symbol */
-             if (SC_IS_COMMON (ext_in->asym.sc))
-               {
-                 /* The value of a common symbol is its size, not its address.
-                    Ignore it.  */
-                 continue;
-               }
-             else if (SC_IS_DATA (ext_in->asym.sc))
-               {
-                 ms_type = mst_data;
-                 svalue += ANOFFSET (section_offsets, SECT_OFF_DATA);
-               }
-             else if (SC_IS_BSS (ext_in->asym.sc))
-               {
-                 ms_type = mst_bss;
-                 svalue += ANOFFSET (section_offsets, SECT_OFF_BSS);
-               }
-             else
-               ms_type = mst_abs;
-             break;
-           case stLabel:
-             /* Label */
-             if (SC_IS_TEXT (ext_in->asym.sc))
-               {
-                 ms_type = mst_file_text;
-                 svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT);
-               }
-             else if (SC_IS_DATA (ext_in->asym.sc))
-               {
-                 ms_type = mst_file_data;
-                 svalue += ANOFFSET (section_offsets, SECT_OFF_DATA);
-               }
-             else if (SC_IS_BSS (ext_in->asym.sc))
-               {
-                 ms_type = mst_file_bss;
-                 svalue += ANOFFSET (section_offsets, SECT_OFF_BSS);
-               }
-             else
-               ms_type = mst_abs;
-             break;
-           case stLocal:
-           case stNil:
-             /* The alpha has the section start addresses in stLocal symbols
+       /* Process ECOFF Symbol Types and Storage Classes */
+       switch (ext_in->asym.st)
+         {
+         case stProc:
+           /* Beginnning of Procedure */
+           svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+           break;
+         case stStaticProc:
+           /* Load time only static procs */
+           ms_type = mst_file_text;
+           svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+           break;
+         case stGlobal:
+           /* External symbol */
+           if (SC_IS_COMMON (ext_in->asym.sc))
+             {
+               /* The value of a common symbol is its size, not its address.
+                  Ignore it.  */
+               continue;
+             }
+           else if (SC_IS_DATA (ext_in->asym.sc))
+             {
+               ms_type = mst_data;
+               svalue += ANOFFSET (section_offsets, SECT_OFF_DATA);
+             }
+           else if (SC_IS_BSS (ext_in->asym.sc))
+             {
+               ms_type = mst_bss;
+               svalue += ANOFFSET (section_offsets, SECT_OFF_BSS);
+             }
+           else
+             ms_type = mst_abs;
+           break;
+         case stLabel:
+           /* Label */
+           if (SC_IS_TEXT (ext_in->asym.sc))
+             {
+               ms_type = mst_file_text;
+               svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+             }
+           else if (SC_IS_DATA (ext_in->asym.sc))
+             {
+               ms_type = mst_file_data;
+               svalue += ANOFFSET (section_offsets, SECT_OFF_DATA);
+             }
+           else if (SC_IS_BSS (ext_in->asym.sc))
+             {
+               ms_type = mst_file_bss;
+               svalue += ANOFFSET (section_offsets, SECT_OFF_BSS);
+             }
+           else
+             ms_type = mst_abs;
+           break;
+         case stLocal:
+         case stNil:
+           /* The alpha has the section start addresses in stLocal symbols
                 whose name starts with a `.'. Skip those but complain for all
                 other stLocal symbols.
                 Irix6 puts the section start addresses in stNil symbols, skip
-                those too.  */
-             if (name[0] == '.')
-               continue;
-             /* Fall through.  */
-           default:
-             ms_type = mst_unknown;
-             complain (&unknown_ext_complaint, name);
-           }
+                those too.*/
+           if (name[0] == '.')
+             continue;
+           /* Fall through.  */
+         default:
+           ms_type = mst_unknown;
+           complain (&unknown_ext_complaint, name);
+         }
+        if (!ECOFF_IN_ELF(cur_bfd))
          prim_record_minimal_symbol (name, svalue, ms_type, objfile);
-       }
-    }
+      }
 
   /* Pass 3 over files, over local syms: fill in static symbols */
   for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++)
@@ -2751,11 +2754,12 @@ parse_partial_symbols (objfile, section_offsets)
                    /* Concatinate stabstring2 with stabstring1 */
                    if (stabstring
                        && stabstring != debug_info->ss + fh->issBase + sh.iss)
-                     stabstring = realloc (stabstring, len + len2 + 1);
+                     stabstring = xrealloc (stabstring, len + len2 + 1);
                    else
-                     stabstring = malloc (len + len2 + 1);
+                     stabstring = xmalloc (len + len2 + 1);
                    strcpy (stabstring, stabstring1);
                    strcpy (stabstring + len, stabstring2);
+                   len += len2;
                  }
 
 #define SET_NAMESTRING() \
This page took 0.03142 seconds and 4 git commands to generate.