* inftarg.c (child_thread_alive): New function to see if a
[deliverable/binutils-gdb.git] / gdb / mdebugread.c
index 4313b4803465b5077bf03d97c58b874190938ba9..c4f18890072e559a9b8cb876a1d34361b4c69c1c 100644 (file)
@@ -97,34 +97,33 @@ typedef struct mips_extra_func_info {
 #ifndef ECOFF_REG_TO_REGNUM
 #define ECOFF_REG_TO_REGNUM(num) (num)
 #endif
-
-/* Each partial symbol table entry contains a pointer to private data
-   for the read_symtab() function to use when expanding a partial
-   symbol table entry to a full symbol table entry.
-
-   For mdebugread this structure contains the index of the FDR that this
-   psymtab represents and a pointer to the BFD that the psymtab was
-   created from.  */
-
-#define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private)
-#define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx)
-#define CUR_BFD(p) (PST_PRIVATE(p)->cur_bfd)
-#define DEBUG_SWAP(p) (PST_PRIVATE(p)->debug_swap)
-#define DEBUG_INFO(p) (PST_PRIVATE(p)->debug_info)
-#define PENDING_LIST(p) (PST_PRIVATE(p)->pending_list)
+\f
+/* We put a pointer to this structure in the read_symtab_private field
+   of the psymtab.  */
 
 struct symloc
 {
+  /* Index of the FDR that this psymtab represents.  */
   int fdr_idx;
+  /* The BFD that the psymtab was created from.  */
   bfd *cur_bfd;
   const struct ecoff_debug_swap *debug_swap;
   struct ecoff_debug_info *debug_info;
   struct mdebug_pending **pending_list;
-  EXTR *extern_tab;            /* Pointer to external symbols for this file. */
-  int extern_count;            /* Size of extern_tab. */
+  /* Pointer to external symbols for this file.  */
+  EXTR *extern_tab;
+  /* Size of extern_tab.  */
+  int extern_count;
   enum language pst_language;
 };
 
+#define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private)
+#define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx)
+#define CUR_BFD(p) (PST_PRIVATE(p)->cur_bfd)
+#define DEBUG_SWAP(p) (PST_PRIVATE(p)->debug_swap)
+#define DEBUG_INFO(p) (PST_PRIVATE(p)->debug_info)
+#define PENDING_LIST(p) (PST_PRIVATE(p)->pending_list)
+\f
 /* Things we import explicitly from other modules */
 
 extern int info_verbose;
@@ -278,6 +277,15 @@ static struct type *mdebug_type_fixed_dec;
 static struct type *mdebug_type_float_dec;
 static struct type *mdebug_type_string;
 
+/* Types for symbols from files compiled without debugging info.  */
+
+static struct type *nodebug_func_symbol_type;
+static struct type *nodebug_var_symbol_type;
+
+/* Nonzero if we have seen ecoff debugging info for a file.  */
+
+static int found_ecoff_debugging_info;
+
 /* Forward declarations */
 
 static int
@@ -679,9 +687,12 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
   switch (sh->sc)
     {
     case scText:
-      /* The value of a stEnd symbol is the displacement from the
-        corresponding start symbol value, do not relocate it.  */
-      if (sh->st != stEnd)
+      /* Do not relocate relative values.
+        The value of a stEnd symbol is the displacement from the
+        corresponding start symbol value.
+        The value of a stBlock symbol is the displacement from the
+        procedure address.  */
+      if (sh->st != stEnd && sh->st != stBlock)
        sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT);
       break;
     case scData:
@@ -744,9 +755,9 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
       SYMBOL_CLASS (s) = class;
       add_symbol (s, b);
 
-      /* Type could be missing in a number of cases */
-      if (sh->sc == scUndefined || sh->sc == scNil)
-       SYMBOL_TYPE (s) = builtin_type_int;     /* undefined? */
+      /* Type could be missing if file is compiled without debugging info.  */
+      if (sh->sc == scUndefined || sh->sc == scNil || sh->index == indexNil)
+       SYMBOL_TYPE (s) = nodebug_var_symbol_type;
       else
        SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name);
       /* Value of a data symbol is its memory address */
@@ -754,6 +765,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
 
     case stParam:              /* arg to procedure, goes into current block */
       max_gdbinfo++;
+      found_ecoff_debugging_info = 1;
       top_stack->numargs++;
 
       /* Special GNU C++ name.  */
@@ -879,6 +891,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
           unknown-type blocks of info about structured data.  `type_code'
           has been set to the proper TYPE_CODE, if we know it.  */
       structured_common:
+       found_ecoff_debugging_info = 1;
        push_parse_stack ();
        top_stack->blocktype = stBlock;
 
@@ -1101,6 +1114,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
       }
 
     case_stBlock_code:
+      found_ecoff_debugging_info = 1;
       /* beginnning of (code) block. Value of symbol
         is the displacement from procedure start */
       push_parse_stack ();
@@ -1150,6 +1164,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
          e = ((struct mips_extra_func_info *)
               obstack_alloc (&current_objfile->symbol_obstack,
                              sizeof (struct mips_extra_func_info)));
+         memset ((PTR) e, 0, sizeof (struct mips_extra_func_info));
          SYMBOL_VALUE (s) = (long) e;
          e->numargs = top_stack->numargs;
          e->pdr.framereg = -1;
@@ -1246,6 +1261,8 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
       break;
 
     case stTypedef:            /* type definition */
+      found_ecoff_debugging_info = 1;
+
       /* Typedefs for forward declarations and opaque structs from alpha cc
         are handled by cross_ref, skip them.  */
       if (sh->iss == 0)
@@ -1885,6 +1902,26 @@ parse_procedure (pr, search_symtab, first_off, pst)
          e->pdr.regoffset = -4;
        }
     }
+
+  /* It would be reasonable that functions that have been compiled
+     without debugging info have a btNil type for their return value,
+     and functions that are void and are compiled with debugging info
+     have btVoid.
+     gcc and DEC f77 put out btNil types for both cases, so btNil is mapped
+     to TYPE_CODE_VOID in parse_type to get the `compiled with debugging info'
+     case right.
+     The glevel field in cur_fdr could be used to determine the presence
+     of debugging info, but GCC doesn't always pass the -g switch settings
+     to the assembler and GAS doesn't set the glevel field from the -g switch
+     settings.
+     To work around these problems, the return value type of a TYPE_CODE_VOID
+     function is adjusted accordingly if no debugging info was found in the
+     compilation unit.  */
+  if (processing_gcc_compilation == 0
+      && found_ecoff_debugging_info == 0
+      && TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (s))) == TYPE_CODE_VOID)
+    SYMBOL_TYPE (s) = nodebug_func_symbol_type;
 }
 
 /* Relocate the extra function info pointed to by the symbol table.  */
@@ -3119,6 +3156,8 @@ psymtab_to_symtab_1 (pst, filename)
                     obstack_alloc (&current_objfile->symbol_obstack,
                                    sizeof (struct mips_extra_func_info)));
                  struct symbol *s = new_symbol (MIPS_EFI_SYMBOL_NAME);
+
+                 memset ((PTR) e, 0, sizeof (struct mips_extra_func_info));
                  SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE;
                  SYMBOL_CLASS (s) = LOC_CONST;
                  SYMBOL_TYPE (s) = builtin_type_void;
@@ -3181,8 +3220,6 @@ psymtab_to_symtab_1 (pst, filename)
     {
       /* This symbol table contains ordinary ecoff entries.  */
 
-      /* FIXME:  doesn't use pst->section_offsets.  */
-
       int f_max;
       int maxlines;
       EXTR *ext_ptr;
@@ -3223,6 +3260,7 @@ psymtab_to_symtab_1 (pst, filename)
       top_stack->cur_type = 0;
       top_stack->procadr = 0;
       top_stack->numargs = 0;
+      found_ecoff_debugging_info = 0;
 
       if (fh)
        {
@@ -4099,4 +4137,11 @@ _initialize_mdebugread ()
               TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
               0, "floating decimal",
               (struct objfile *) NULL);
+
+  nodebug_func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0,
+                                       "<function, no debug info>", NULL);
+  TYPE_TARGET_TYPE (nodebug_func_symbol_type) = builtin_type_int;
+  nodebug_var_symbol_type =
+    init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
+              "<variable, no debug info>", NULL);
 }
This page took 0.02551 seconds and 4 git commands to generate.