* stabsread.c (get_substring): Declare second arg as int.
[deliverable/binutils-gdb.git] / gdb / mdebugread.c
index 0fa3c3d4565956d71f8acd1c88f94621d1916e64..67ded75fe5c9eae670d1306202ba2621828d6af9 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
+   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
    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
@@ -49,6 +49,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "buildsym.h"
 #include "stabsread.h"
 #include "complaints.h"
+#include "demangle.h"
 
 /* These are needed if the tm.h file does not contain the necessary
    mips specific definitions.  */
@@ -304,6 +305,24 @@ static int found_ecoff_debugging_info;
 
 /* Forward declarations */
 
+static void
+add_pending PARAMS ((FDR *, char *, struct type *));
+
+static struct mdebug_pending *
+is_pending_symbol PARAMS ((FDR *, char *));
+
+static void
+pop_parse_stack PARAMS ((void));
+
+static void
+push_parse_stack PARAMS ((void));
+
+static char *
+fdr_name PARAMS ((FDR *));
+
+static void
+mdebug_psymtab_to_symtab PARAMS ((struct partial_symtab *));
+
 static int
 upgrade_type PARAMS ((int, struct type **, int, union aux_ext *, int, char *));
 
@@ -346,7 +365,7 @@ static struct type *
 parse_type PARAMS ((int, union aux_ext *, unsigned int, int *, int, char *));
 
 static struct symbol *
-mylookup_symbol PARAMS ((char *, struct block *, enum namespace,
+mylookup_symbol PARAMS ((char *, struct block *, namespace_enum,
                         enum address_class));
 
 static struct block *
@@ -785,7 +804,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
       top_stack->numargs++;
 
       /* Special GNU C++ name.  */
-      if (name[0] == CPLUS_MARKER && name[1] == 't' && name[2] == 0)
+      if (is_cplus_marker (name[0]) && name[1] == 't' && name[2] == 0)
        name = "this";          /* FIXME, not alloc'd in obstack */
       s = new_symbol (name);
 
@@ -834,7 +853,23 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
       if (sh->sc == scUndefined || sh->sc == scNil)
        t = mdebug_type_int;
       else
-       t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name);
+       {
+         t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name);
+         if (STREQ(name, "malloc") && t->code == TYPE_CODE_VOID)
+           {
+             /* I don't know why, but, at least under Linux/Alpha,
+                when linking against a malloc without debugging
+                symbols, its read as a function returning void---this
+                is bad because it means we cannot call functions with
+                string arguments interactively; i.e., "call
+                printf("howdy\n")" would fail with the error message
+                "program has no memory available".  To avoid this, we
+                patch up the type and make it void*
+                instead. (davidm@azstarnet.com)
+                */
+             t = t->pointer_type;
+           }
+       }
       b = top_stack->cur_block;
       if (sh->st == stProc)
        {
@@ -1097,7 +1132,9 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
                            obstack_alloc (&current_objfile->symbol_obstack,
                                           sizeof (struct symbol)));
                memset ((PTR) enum_sym, 0, sizeof (struct symbol));
-               SYMBOL_NAME (enum_sym) = f->name;
+               SYMBOL_NAME (enum_sym) =
+                 obsavestring (f->name, strlen (f->name),
+                               &current_objfile->symbol_obstack);
                SYMBOL_CLASS (enum_sym) = LOC_CONST;
                SYMBOL_TYPE (enum_sym) = t;
                SYMBOL_NAMESPACE (enum_sym) = VAR_NAMESPACE;
@@ -2216,7 +2253,7 @@ parse_partial_symbols (objfile, section_offsets)
   EXTR *ext_in_end;
   SYMR sh;
   struct partial_symtab *pst;
-
+  int textlow_not_set = 1;
   int past_first_source_file = 0;
 
   /* List of current psymtab's include files */
@@ -2612,7 +2649,7 @@ parse_partial_symbols (objfile, section_offsets)
 #define CUR_SYMBOL_VALUE sh.value
 #define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\
   pst = save_pst
-#define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps) (void)0
+#define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set) (void)0
 #define HANDLE_RBRAC(val) \
   if ((val) > save_pst->texthigh) save_pst->texthigh = (val);
 #include "partial-stab.h"
@@ -2696,15 +2733,15 @@ parse_partial_symbols (objfile, section_offsets)
                     symbol table, and the MAIN__ symbol via the minimal
                     symbol table.  */
                  if (sh.st == stProc)
-                   ADD_PSYMBOL_TO_LIST (name, strlen (name),
+                   add_psymbol_to_list (name, strlen (name),
                                         VAR_NAMESPACE, LOC_BLOCK,
-                                        objfile->global_psymbols,
-                                        sh.value, psymtab_language, objfile);
+                                        &objfile->global_psymbols,
+                                        sh.value, 0, psymtab_language, objfile);
                  else
-                   ADD_PSYMBOL_TO_LIST (name, strlen (name),
+                   add_psymbol_to_list (name, strlen (name),
                                         VAR_NAMESPACE, LOC_BLOCK,
-                                        objfile->static_psymbols,
-                                        sh.value, psymtab_language, objfile);
+                                        &objfile->static_psymbols,
+                                        sh.value, 0, psymtab_language, objfile);
 
                  /* Skip over procedure to next one. */
                  if (sh.index >= hdr->iauxMax)
@@ -2792,10 +2829,10 @@ parse_partial_symbols (objfile, section_offsets)
                      && sh.iss != 0
                      && sh.index != cur_sdx + 2)
                    {
-                     ADD_PSYMBOL_TO_LIST (name, strlen (name),
+                     add_psymbol_to_list (name, strlen (name),
                                           STRUCT_NAMESPACE, LOC_TYPEDEF,
-                                          objfile->static_psymbols,
-                                          sh.value,
+                                          &objfile->static_psymbols,
+                                          sh.value, 0,
                                           psymtab_language, objfile);
                    }
                  handle_psymbol_enumerators (objfile, fh, sh.st, sh.value);
@@ -2831,10 +2868,10 @@ parse_partial_symbols (objfile, section_offsets)
                  continue;
                }
              /* Use this gdb symbol */
-             ADD_PSYMBOL_TO_LIST (name, strlen (name),
+             add_psymbol_to_list (name, strlen (name),
                                   VAR_NAMESPACE, class,
-                                  objfile->static_psymbols, sh.value,
-                                  psymtab_language, objfile);
+                                  &objfile->static_psymbols, sh.value,
+                                  0, psymtab_language, objfile);
            skip:
              cur_sdx++;        /* Go to next file symbol */
            }
@@ -2907,11 +2944,11 @@ parse_partial_symbols (objfile, section_offsets)
                  break;
                }
              name = debug_info->ssext + psh->iss;
-             ADD_PSYMBOL_ADDR_TO_LIST (name, strlen (name),
-                                       VAR_NAMESPACE, class,
-                                       objfile->global_psymbols,
-                                       svalue,
-                                       psymtab_language, objfile);
+             add_psymbol_to_list (name, strlen (name),
+                                  VAR_NAMESPACE, class,
+                                  &objfile->global_psymbols,
+                                  0, svalue,
+                                  psymtab_language, objfile);
            }
        }
 
@@ -2920,7 +2957,7 @@ parse_partial_symbols (objfile, section_offsets)
       fdr_to_pst[f_idx].pst = end_psymtab (save_pst,
                                           psymtab_include_list, includes_used,
                                           -1, save_pst->texthigh,
-                                          dependency_list, dependencies_used);
+                                          dependency_list, dependencies_used, textlow_not_set);
       includes_used = 0;
       dependencies_used = 0;
 
@@ -3076,10 +3113,10 @@ handle_psymbol_enumerators (objfile, fh, stype, svalue)
 
       /* Note that the value doesn't matter for enum constants
         in psymtabs, just in symtabs.  */
-      ADD_PSYMBOL_TO_LIST (name, strlen (name),
+      add_psymbol_to_list (name, strlen (name),
                           VAR_NAMESPACE, LOC_CONST,
-                          objfile->static_psymbols, 0,
-                          psymtab_language, objfile);
+                          &objfile->static_psymbols, 0,
+                          0, psymtab_language, objfile);
       ext_sym += external_sym_size;
     }
 }
@@ -3271,7 +3308,7 @@ psymtab_to_symtab_1 (pst, filename)
          else
            complain (&stab_unknown_complaint, name);
        }
-      st = end_symtab (pst->texthigh, 0, 0, pst->objfile, SECT_OFF_TEXT);
+      st = end_symtab (pst->texthigh, pst->objfile, SECT_OFF_TEXT);
       end_stabs ();
 
       /* Sort the symbol table now, we are done adding symbols to it.
@@ -3731,7 +3768,7 @@ static struct symbol *
 mylookup_symbol (name, block, namespace, class)
      char *name;
      register struct block *block;
-     enum namespace namespace;
+     namespace_enum namespace;
      enum address_class class;
 {
   register int bot, top, inc;
@@ -4082,7 +4119,8 @@ new_symbol (name)
                                     sizeof (struct symbol)));
 
   memset ((PTR) s, 0, sizeof (*s));
-  SYMBOL_NAME (s) = name;
+  SYMBOL_NAME (s) = obsavestring (name, strlen (name),
+                                 &current_objfile->symbol_obstack);
   SYMBOL_LANGUAGE (s) = psymtab_language;
   SYMBOL_INIT_DEMANGLED_NAME (s, &current_objfile->symbol_obstack);
   return s;
This page took 0.026847 seconds and 4 git commands to generate.