* serial.h (SERIAL_SET_TTY_STATE): Comment return value.
[deliverable/binutils-gdb.git] / gdb / mdebugread.c
index 944ab7745e2dcb56b3861386c6901eb314ef2cc6..352b4c4a8db5a487d557e5dd21bb37c8ef0e6ecf 100644 (file)
@@ -268,13 +268,17 @@ static int n_undef_symbols, n_undef_labels, n_undef_vars, n_undef_procs;
 
 static char stabs_symbol[] = STABS_SYMBOL;
 
-/* Extra builtin types */
-
-struct type *builtin_type_complex;
-struct type *builtin_type_double_complex;
-struct type *builtin_type_fixed_dec;
-struct type *builtin_type_float_dec;
-struct type *builtin_type_string;
+/* Types corresponding to btComplex, btDComplex, etc.  These are here
+   rather than in gdbtypes.c or some such, because the meaning of codes
+   like btComplex is specific to the mdebug debug format.  FIXME:  We should
+   be using our own types thoughout this file, instead of sometimes using
+   builtin_type_*.  */
+
+static struct type *mdebug_type_complex;
+static struct type *mdebug_type_double_complex;
+static struct type *mdebug_type_fixed_dec;
+static struct type *mdebug_type_float_dec;
+static struct type *mdebug_type_string;
 
 /* Forward declarations */
 
@@ -989,8 +993,10 @@ parse_symbol (sh, ax, ext_sh, bigend)
        else
          t = pend->t;
 
-       /* Alpha cc unnamed structs do not get a tag name.  */
-       if (sh->iss == 0)
+       /* Do not set the tag name if it is a compiler generated tag name
+          (.Fxx or .xxfake or empty) for unnamed struct/union/enums.
+          Alpha cc puts out an sh->iss of zero for those.  */
+       if (sh->iss == 0 || name[0] == '.' || name[0] == '\0')
          TYPE_TAG_NAME (t) = NULL;
        else
          TYPE_TAG_NAME (t) = obconcat (&current_objfile->symbol_obstack,
@@ -1006,6 +1012,15 @@ parse_symbol (sh, ax, ext_sh, bigend)
        if (type_code == TYPE_CODE_ENUM)
          {
            /* This is a non-empty enum. */
+
+           /* DEC c89 has the number of enumerators in the sh.value field,
+              not the type length, so we have to compensate for that
+              incompatibility quirk.
+              This might do the wrong thing for an enum with one or two
+              enumerators and gcc -gcoff -fshort-enums, but these cases
+              are hopefully rare enough.  */
+           if (TYPE_LENGTH (t) == TYPE_NFIELDS (t))
+             TYPE_LENGTH (t) = TARGET_INT_BIT / HOST_CHAR_BIT;
            for (ext_tsym = ext_sh + external_sym_size;
                 ;
                 ext_tsym += external_sym_size)
@@ -1299,12 +1314,12 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name)
     0,                         /* btTypedef */
     0,                         /* btRange */
     0,                         /* btSet */
-    &builtin_type_complex,     /* btComplex */
-    &builtin_type_double_complex,      /* btDComplex */
+    &mdebug_type_complex,      /* btComplex */
+    &mdebug_type_double_complex,       /* btDComplex */
     0,                         /* btIndirect */
-    &builtin_type_fixed_dec,   /* btFixedDec */
-    &builtin_type_float_dec,   /* btFloatDec */
-    &builtin_type_string,      /* btString */
+    &mdebug_type_fixed_dec,    /* btFixedDec */
+    &mdebug_type_float_dec,    /* btFloatDec */
+    &mdebug_type_string,       /* btString */
     0,                         /* btBit */
     0,                         /* btPicture */
     &builtin_type_void,                /* btVoid */
@@ -1412,6 +1427,12 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name)
       if (tp == (struct type *) NULL)
        tp = init_type (type_code, 0, 0, (char *) NULL, current_objfile);
 
+      /* DEC c89 produces cross references to qualified aggregate types,
+        dereference them.  */
+      while (TYPE_CODE (tp) == TYPE_CODE_PTR
+            || TYPE_CODE (tp) == TYPE_CODE_ARRAY)
+       tp = tp->target_type;
+
       /* Make sure that TYPE_CODE(tp) has an expected type code.
         Any type may be returned from cross_ref if file indirect entries
         are corrupted.  */
@@ -1691,6 +1712,7 @@ parse_procedure (pr, search_symtab, first_off)
       if (pr->isym == -1)
        {
          /* Static procedure at address pr->adr.  Sigh. */
+         /* FIXME-32x64.  assuming pr->adr fits in long.  */
          complain (&pdr_static_symbol_complaint, (unsigned long) pr->adr);
          return;
        }
@@ -2157,7 +2179,7 @@ parse_partial_symbols (objfile, section_offsets)
          ms_type = mst_unknown;
          complain (&unknown_ext_complaint, name);
        }
-      prim_record_minimal_symbol (name, ext_in->asym.value, ms_type);
+      prim_record_minimal_symbol (name, ext_in->asym.value, ms_type, objfile);
     }
 
   /* Pass 3 over files, over local syms: fill in static symbols */
@@ -2329,7 +2351,8 @@ parse_partial_symbols (objfile, section_offsets)
                  /* I believe this is used only for file-local functions.
                     The comment in symconst.h ("load time only static procs")
                     isn't particularly clear on this point.  */
-                 prim_record_minimal_symbol (name, sh.value, mst_file_text);
+                 prim_record_minimal_symbol (name, sh.value, mst_file_text,
+                                             objfile);
                  /* FALLTHROUGH */
 
                case stProc:    /* Asm labels apparently */
@@ -2374,9 +2397,11 @@ parse_partial_symbols (objfile, section_offsets)
 
                case stStatic:  /* Variable */
                  if (sh.sc == scData || sh.sc == scSData || sh.sc == scRData)
-                   prim_record_minimal_symbol (name, sh.value, mst_file_data);
+                   prim_record_minimal_symbol (name, sh.value, mst_file_data,
+                                               objfile);
                  else
-                   prim_record_minimal_symbol (name, sh.value, mst_file_bss);
+                   prim_record_minimal_symbol (name, sh.value, mst_file_bss,
+                                               objfile);
                  class = LOC_STATIC;
                  break;
 
@@ -2698,8 +2723,15 @@ psymtab_to_symtab_1 (pst, filename)
          if (ECOFF_IS_STAB (&sh))
            {
              int type_code = ECOFF_UNMARK_STAB (sh.index);
-             process_one_symbol (type_code, 0, valu, name,
-                                 pst->section_offsets, pst->objfile);
+
+             /* We should never get non N_STAB symbols here, but they
+                should be harmless, so keep process_one_symbol from
+                complaining about them.  */
+             if (type_code & N_STAB)
+               {
+                 process_one_symbol (type_code, 0, valu, name,
+                                     pst->section_offsets, pst->objfile);
+               }
              if (type_code == N_FUN)
                {
                  /* Make up special symbol to contain
@@ -2716,10 +2748,17 @@ psymtab_to_symtab_1 (pst, filename)
                  add_symbol_to_list (s, &local_symbols);
                }
            }
-         else if (sh.st == stLabel && sh.index != indexNil)
+         else if (sh.st == stLabel)
            {
-             /* Handle encoded stab line number. */
-             record_line (current_subfile, sh.index, valu);
+             if (sh.index == indexNil)
+               {
+                 /* This is what the gcc2_compiled and __gnu_compiled_*
+                    show up as.  So don't complain.  */
+                 ;
+               }
+             else
+               /* Handle encoded stab line number. */
+               record_line (current_subfile, sh.index, valu);
            }
          else if (sh.st == stProc || sh.st == stStaticProc || sh.st == stEnd)
            /* These are generated by gcc-2.x, do not complain */
@@ -3208,6 +3247,10 @@ add_line (lt, lineno, adr, last)
      CORE_ADDR adr;
      int last;
 {
+  /* DEC c89 sometimes produces zero linenos which confuse gdb.
+     Change them to something sensible. */
+  if (lineno == 0)
+    lineno = 1;
   if (last == 0)
     last = -2;                 /* make sure we record first line */
 
@@ -3655,28 +3698,36 @@ _initialize_mdebugread ()
 {
   /* Missing basic types */
 
-  builtin_type_string =
+  /* Is a "string" the way btString means it the same as TYPE_CODE_STRING?
+     FIXME.  */
+  mdebug_type_string =
     init_type (TYPE_CODE_STRING,
               TARGET_CHAR_BIT / TARGET_CHAR_BIT,
               0, "string",
               (struct objfile *) NULL);
-  builtin_type_complex =
-    init_type (TYPE_CODE_FLT,
+
+  mdebug_type_complex =
+    init_type (TYPE_CODE_ERROR,
               TARGET_COMPLEX_BIT / TARGET_CHAR_BIT,
               0, "complex",
               (struct objfile *) NULL);
-  builtin_type_double_complex =
-    init_type (TYPE_CODE_FLT,
+  mdebug_type_double_complex =
+    init_type (TYPE_CODE_ERROR,
               TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT,
               0, "double complex",
               (struct objfile *) NULL);
-  builtin_type_fixed_dec =
+
+  /* We use TYPE_CODE_INT to print these as integers.  Does this do any
+     good?  Would we be better off with TYPE_CODE_ERROR?  Should
+     TYPE_CODE_ERROR print things in hex if it knows the size?  */
+  mdebug_type_fixed_dec =
     init_type (TYPE_CODE_INT,
               TARGET_INT_BIT / TARGET_CHAR_BIT,
               0, "fixed decimal",
               (struct objfile *) NULL);
-  builtin_type_float_dec =
-    init_type (TYPE_CODE_FLT,
+
+  mdebug_type_float_dec =
+    init_type (TYPE_CODE_ERROR,
               TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
               0, "floating decimal",
               (struct objfile *) NULL);
This page took 0.027105 seconds and 4 git commands to generate.