* sparc64-tdep.h (stryct_frame_info, struct trad_frame_saved_reg):
[deliverable/binutils-gdb.git] / gdb / hpread.c
index 6acf576036450ec01d25c85ace6e2f62146faafd..246f77ec0c5a14855d5dba60a01d30f9ba66a7d1 100644 (file)
@@ -1,6 +1,6 @@
 /* Read hp debug symbols and convert to internal format, for GDB.
-   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-   Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+   2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -35,6 +35,8 @@
 #include "gdb-stabs.h"
 #include "gdbtypes.h"
 #include "demangle.h"
+#include "somsolib.h"
+#include "gdb_assert.h"
 
 /* Private information attached to an objfile which we use to find
    and internalize the HP C debug symbols within that objfile.  */
@@ -138,9 +140,7 @@ lbrac_mismatch_complaint (int arg1)
 
 /* Forward procedure declarations */
 
-static void set_namestring (union dnttentry *sym, char **namep,
-                            struct objfile *objfile);
-
+/* Used in somread.c.  */
 void hpread_symfile_init (struct objfile *);
 
 void do_pxdb (bfd *);
@@ -149,6 +149,9 @@ void hpread_build_psymtabs (struct objfile *, int);
 
 void hpread_symfile_finish (struct objfile *);
 
+static void set_namestring (union dnttentry *sym, char **namep,
+                            struct objfile *objfile);
+
 static union dnttentry *hpread_get_gntt (int, struct objfile *);
 
 static union dnttentry *hpread_get_lntt (int index, struct objfile *objfile);
@@ -170,11 +173,11 @@ static unsigned long hpread_get_line (sltpointer, struct objfile *);
 
 static CORE_ADDR hpread_get_location (sltpointer, struct objfile *);
 
-int hpread_has_name (enum dntt_entry_type kind);
+static int hpread_has_name (enum dntt_entry_type kind);
 
 static void hpread_psymtab_to_symtab_1 (struct partial_symtab *);
 
-void hpread_psymtab_to_symtab (struct partial_symtab *);
+static void hpread_psymtab_to_symtab (struct partial_symtab *);
 
 static struct symtab *hpread_expand_symtab
   (struct objfile *, int, int, CORE_ADDR, int,
@@ -259,7 +262,7 @@ static struct type *fixup_method = NULL;
 #include "gdb_string.h"
 
 /* check for the existence of a file, given its full pathname */
-int
+static int
 file_exists (char *filename)
 {
   if (filename)
@@ -319,7 +322,7 @@ set_namestring (union dnttentry *sym, char **namep, struct objfile *objfile)
    NOTE: uses system function and string functions directly.
 
    Return value: 1 if ok, 0 if not */
-int
+static int
 hpread_call_pxdb (const char *file_name)
 {
   char *p;
@@ -352,7 +355,7 @@ hpread_call_pxdb (const char *file_name)
    by PXDB, and we have thus called PXDB to do this processing
    and the file therefore needs to be re-loaded.  Otherwise
    return 0. */
-int
+static int
 hpread_pxdb_needed (bfd *sym_bfd)
 {
   asection *pinfo_section, *debug_section, *header_section;
@@ -787,7 +790,7 @@ scan_procs (int *curr_pd_p, quick_procedure_entry *qPD, int max_procs,
                                           strlen (rtn_name),
                                           rtn_dem_name,
                                           strlen (rtn_dem_name),
-                                          VAR_NAMESPACE,
+                                          VAR_DOMAIN,
                                           LOC_BLOCK,   /* "I am a routine"        */
                                           &objfile->global_psymbols,
                                           (qPD[curr_pd].adrStart +     /* Starting address of rtn */
@@ -800,7 +803,7 @@ scan_procs (int *curr_pd_p, quick_procedure_entry *qPD, int max_procs,
                                           strlen (rtn_name),
                                           rtn_dem_name,
                                           strlen (rtn_dem_name),
-                                          VAR_NAMESPACE,
+                                          VAR_DOMAIN,
                                           LOC_BLOCK,   /* "I am a routine"        */
                                           &objfile->static_psymbols,
                                           (qPD[curr_pd].adrStart +     /* Starting address of rtn */
@@ -835,7 +838,7 @@ scan_procs (int *curr_pd_p, quick_procedure_entry *qPD, int max_procs,
    a file can result in a compiled object which does not have a module
    entry for it, so in such cases we create a psymtab for the file.  */
 
-int
+static int
 hpread_quick_traverse (struct objfile *objfile, char *gntt_bits,
                       char *vt_bits, PXDB_header_ptr pxdb_header_p)
 {
@@ -1024,7 +1027,7 @@ hpread_quick_traverse (struct objfile *objfile, char *gntt_bits,
   while (VALID_CURR_FILE || VALID_CURR_MODULE)
     {
 
-      char *mod_name_string;
+      char *mod_name_string = NULL;
       char *full_name_string;
 
       /* First check for modules like "version.c", which have no code
@@ -1540,7 +1543,7 @@ hpread_quick_traverse (struct objfile *objfile, char *gntt_bits,
 
 /* Get appropriate header, based on pxdb type. 
    Return value: 1 if ok, 0 if not */
-int
+static int
 hpread_get_header (struct objfile *objfile, PXDB_header_ptr pxdb_header_p)
 {
   asection *pinfo_section, *debug_section, *header_section;
@@ -2059,12 +2062,12 @@ hpread_build_psymtabs (struct objfile *objfile, int mainline)
              set_namestring (dn_bufp, &namestring, objfile);
              if (dn_bufp->dfunc.global)
                add_psymbol_to_list (namestring, strlen (namestring),
-                                    VAR_NAMESPACE, LOC_BLOCK,
+                                    VAR_DOMAIN, LOC_BLOCK,
                                     &objfile->global_psymbols, valu,
                                     0, language_unknown, objfile);
              else
                add_psymbol_to_list (namestring, strlen (namestring),
-                                    VAR_NAMESPACE, LOC_BLOCK,
+                                    VAR_DOMAIN, LOC_BLOCK,
                                     &objfile->static_psymbols, valu,
                                     0, language_unknown, objfile);
              within_function = 1;
@@ -2080,12 +2083,12 @@ hpread_build_psymtabs (struct objfile *objfile, int mainline)
              set_namestring (dn_bufp, &namestring, objfile);
              if (dn_bufp->ddocfunc.global)
                add_psymbol_to_list (namestring, strlen (namestring),
-                                    VAR_NAMESPACE, LOC_BLOCK,
+                                    VAR_DOMAIN, LOC_BLOCK,
                                     &objfile->global_psymbols, valu,
                                     0, language_unknown, objfile);
              else
                add_psymbol_to_list (namestring, strlen (namestring),
-                                    VAR_NAMESPACE, LOC_BLOCK,
+                                    VAR_DOMAIN, LOC_BLOCK,
                                     &objfile->static_psymbols, valu,
                                     0, language_unknown, objfile);
              within_function = 1;
@@ -2126,7 +2129,7 @@ hpread_build_psymtabs (struct objfile *objfile, int mainline)
              {
                /* Variables, typedefs an the like.  */
                enum address_class storage;
-               namespace_enum namespace;
+               domain_enum domain;
 
                /* Don't add locals to the partial symbol table.  */
                if (within_function
@@ -2134,11 +2137,11 @@ hpread_build_psymtabs (struct objfile *objfile, int mainline)
                        || dn_bufp->dblock.kind == DNTT_TYPE_DVAR))
                  continue;
 
-               /* TAGDEFs go into the structure namespace.  */
+               /* TAGDEFs go into the structure domain.  */
                if (dn_bufp->dblock.kind == DNTT_TYPE_TAGDEF)
-                 namespace = STRUCT_NAMESPACE;
+                 domain = STRUCT_DOMAIN;
                else
-                 namespace = VAR_NAMESPACE;
+                 domain = VAR_DOMAIN;
 
                /* What kind of "storage" does this use?  */
                if (dn_bufp->dblock.kind == DNTT_TYPE_SVAR)
@@ -2176,7 +2179,7 @@ hpread_build_psymtabs (struct objfile *objfile, int mainline)
                if (dn_bufp->dsvar.global)
                  {
                    add_psymbol_to_list (namestring, strlen (namestring),
-                                        namespace, storage,
+                                        domain, storage,
                                         &objfile->global_psymbols,
                                         valu,
                                         0, language_unknown, objfile);
@@ -2184,18 +2187,18 @@ hpread_build_psymtabs (struct objfile *objfile, int mainline)
                else
                  {
                    add_psymbol_to_list (namestring, strlen (namestring),
-                                        namespace, storage,
+                                        domain, storage,
                                         &objfile->static_psymbols,
                                         valu,
                                         0, language_unknown, objfile);
                  }
 
                /* For TAGDEF's, the above code added the tagname to the
-                  struct namespace. This will cause tag "t" to be found
+                  struct domain. This will cause tag "t" to be found
                   on a reference of the form "(struct t) x". But for
                   C++ classes, "t" will also be a typename, which we
                   want to find on a reference of the form "ptype t".
-                  Therefore, we also add "t" to the var namespace.
+                  Therefore, we also add "t" to the var domain.
                   Do the same for enum's due to the way aCC generates
                   debug info for these (see more extended comment
                   in hp-symtab-read.c).
@@ -2214,7 +2217,7 @@ hpread_build_psymtabs (struct objfile *objfile, int mainline)
                        if (global)
                          {
                            add_psymbol_to_list (namestring, strlen (namestring),
-                                                VAR_NAMESPACE, storage,
+                                                VAR_DOMAIN, storage,
                                                 &objfile->global_psymbols,
                                                 dn_bufp->dsvar.location,
                                              0, language_unknown, objfile);
@@ -2222,7 +2225,7 @@ hpread_build_psymtabs (struct objfile *objfile, int mainline)
                        else
                          {
                            add_psymbol_to_list (namestring, strlen (namestring),
-                                                VAR_NAMESPACE, storage,
+                                                VAR_DOMAIN, storage,
                                                 &objfile->static_psymbols,
                                                 dn_bufp->dsvar.location,
                                              0, language_unknown, objfile);
@@ -2247,12 +2250,12 @@ hpread_build_psymtabs (struct objfile *objfile, int mainline)
                }
              if (dn_bufp->dconst.global)
                add_psymbol_to_list (namestring, strlen (namestring),
-                                    VAR_NAMESPACE, LOC_CONST,
+                                    VAR_DOMAIN, LOC_CONST,
                                     &objfile->global_psymbols, 0,
                                     0, language_unknown, objfile);
              else
                add_psymbol_to_list (namestring, strlen (namestring),
-                                    VAR_NAMESPACE, LOC_CONST,
+                                    VAR_DOMAIN, LOC_CONST,
                                     &objfile->static_psymbols, 0,
                                     0, language_unknown, objfile);
              continue;
@@ -2292,7 +2295,7 @@ hpread_symfile_finish (struct objfile *objfile)
 
 /* Various small functions to get entries in the debug symbol sections.  */
 
-union dnttentry *
+static union dnttentry *
 hpread_get_lntt (int index, struct objfile *objfile)
 {
   return (union dnttentry *)
@@ -2306,7 +2309,7 @@ hpread_get_gntt (int index, struct objfile *objfile)
     &(GNTT (objfile)[(index * sizeof (struct dntt_type_block))]);
 }
 
-union sltentry *
+static union sltentry *
 hpread_get_slt (int index, struct objfile *objfile)
 {
   return (union sltentry *) &(SLT (objfile)[index * sizeof (union sltentry)]);
@@ -2321,7 +2324,7 @@ static unsigned long
 hpread_get_textlow (int global, int index, struct objfile *objfile,
                    int symcount)
 {
-  union dnttentry *dn_bufp;
+  union dnttentry *dn_bufp = NULL;
   struct minimal_symbol *msymbol;
 
   /* Look for a DNTT_TYPE_FUNCTION symbol.  */
@@ -2340,6 +2343,11 @@ hpread_get_textlow (int global, int index, struct objfile *objfile,
             && index < symcount);
     }
 
+  /* NOTE: cagney/2003-03-29: If !(index < symcount), dn_bufp is left
+     undefined and that means that the test below is using a garbage
+     pointer from the stack.  */
+  gdb_assert (dn_bufp != NULL);
+
   /* Avoid going past a DNTT_TYPE_END when looking for a DNTT_TYPE_FUNCTION.  This
      might happen when a sourcefile has no functions.  */
   if (dn_bufp->dblock.kind == DNTT_TYPE_END)
@@ -2581,7 +2589,7 @@ hpread_get_location (sltpointer index, struct objfile *objfile)
  * leave it here in case it proves useful later on. - RT).
  */
 
-int
+static int
 hpread_has_name (enum dntt_entry_type kind)
 {
   switch (kind)
@@ -2703,7 +2711,6 @@ hpread_psymtab_to_symtab_1 (struct partial_symtab *pst)
        hpread_expand_symtab (pst->objfile, LDSYMOFF (pst), LDSYMLEN (pst),
                              pst->textlow, pst->texthigh - pst->textlow,
                              pst->section_offsets, pst->filename);
-      sort_symtab_syms (pst->symtab);
 
       do_cleanups (old_chain);
     }
@@ -2714,7 +2721,7 @@ hpread_psymtab_to_symtab_1 (struct partial_symtab *pst)
 /* Read in all of the symbols for a given psymtab for real.
    Be verbose about it if the user wants that.  */
 
-void
+static void
 hpread_psymtab_to_symtab (struct partial_symtab *pst)
 {
   /* Get out quick if given junk.  */
@@ -3126,7 +3133,7 @@ hpread_read_enum_type (dnttpointer hp_type, union dnttentry *dn_bufp,
       DEPRECATED_SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
                                        &objfile->symbol_obstack);
       SYMBOL_CLASS (sym) = LOC_CONST;
-      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_VALUE (sym) = memp->dmember.value;
       add_symbol_to_list (sym, symlist);
       nsyms++;
@@ -3241,7 +3248,7 @@ hpread_read_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
        SYMBOL_CLASS (sym) = LOC_REF_ARG;
       else
        SYMBOL_CLASS (sym) = LOC_ARG;
-      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       if (paramp->dfparam.copyparam)
        {
          SYMBOL_VALUE (sym) = paramp->dfparam.location;
@@ -3359,10 +3366,10 @@ static struct type *
 hpread_read_doc_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
                               struct objfile *objfile, int newblock)
 {
-  struct type *type, *type1;
   struct pending *syms;
   struct pending *local_list = NULL;
   int nsyms = 0;
+  struct type *type;
   dnttpointer param;
   union dnttentry *paramp;
   char *name;
@@ -3378,11 +3385,17 @@ hpread_read_doc_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
     }
   else
     {
+      struct type *type1 = NULL;
       /* Nope, so read it in and store it away.  */
       if (dn_bufp->dblock.kind == DNTT_TYPE_DOC_FUNCTION ||
          dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC)
        type1 = lookup_function_type (hpread_type_lookup (dn_bufp->ddocfunc.retval,
                                                          objfile));
+      /* NOTE: cagney/2003-03-29: Oh, no not again.  TYPE1 is
+         potentially left undefined here.  Assert it isn't and hope
+         the assert never fails ...  */
+      gdb_assert (type1 != NULL);
+
       replace_type (type, type1);
 
       /* Mark it -- in the middle of processing */
@@ -3414,7 +3427,7 @@ hpread_read_doc_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
        SYMBOL_CLASS (sym) = LOC_REF_ARG;
       else
        SYMBOL_CLASS (sym) = LOC_ARG;
-      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       if (paramp->dfparam.copyparam)
        {
          SYMBOL_VALUE (sym) = paramp->dfparam.location;
@@ -3884,7 +3897,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
              fn_p = fn_list;
              while (fn_p)
                {
-                 if (STREQ (fn_p->field.name, method_name))
+                 if (DEPRECATED_STREQ (fn_p->field.name, method_name))
                    break;
                  fn_p = fn_p->next;
                }
@@ -4147,16 +4160,19 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
          list->field.name = VT (objfile) + fieldp->dfield.name;
 
 
-         /* A FIELD by itself (without a GENFIELD) can also be a static member */
-         FIELD_STATIC_KIND (list->field) = 0;
+         /* A FIELD by itself (without a GENFIELD) can also be a static
+            member.  Mark it as static with a physname of NULL.
+            fix_static_member_physnames will assign the physname later. */
          if (fieldp->dfield.staticmem)
            {
-             FIELD_BITPOS (list->field) = -1;
+             SET_FIELD_PHYSNAME (list->field, NULL);
+             FIELD_BITPOS (list->field) = 0;
              FIELD_BITSIZE (list->field) = 0;
            }
          else
            /* Non-static data member */
            {
+             FIELD_STATIC_KIND (list->field) = 0;
              FIELD_BITPOS (list->field) = fieldp->dfield.bitoffset;
              if (fieldp->dfield.bitlength % 8)
                FIELD_BITSIZE (list->field) = fieldp->dfield.bitlength;
@@ -5003,7 +5019,7 @@ hpread_record_lines (struct subfile *subfile, sltpointer s_idx,
  * Called from hpread_process_one_debug_symbol()
  * If "f" is not a member function, return NULL.
  */
-char *
+static char *
 class_of (struct type *functype)
 {
   struct type *first_param_type;
@@ -5087,7 +5103,7 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
   memset (sym, 0, sizeof (struct symbol));
   DEPRECATED_SYMBOL_NAME (sym) = obsavestring (name, strlen (name), &objfile->symbol_obstack);
   SYMBOL_LANGUAGE (sym) = language_auto;
-  SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
   SYMBOL_LINE (sym) = 0;
   SYMBOL_VALUE (sym) = 0;
   SYMBOL_CLASS (sym) = LOC_TYPEDEF;
@@ -5647,7 +5663,7 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
       /* DNTT_TYPE_IMPORT is not handled */
 
     case DNTT_TYPE_LABEL:
-      SYMBOL_NAMESPACE (sym) = LABEL_NAMESPACE;
+      SYMBOL_DOMAIN (sym) = LABEL_DOMAIN;
       break;
 
     case DNTT_TYPE_FPARAM:
@@ -5682,7 +5698,7 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
        SYMBOL_CLASS (sym) = LOC_REF_ARG;
       else
        SYMBOL_CLASS (sym) = LOC_ARG;
-      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       if (dn_bufp->dfparam.copyparam)
        {
          SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
@@ -5798,9 +5814,9 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
 
     case DNTT_TYPE_TYPEDEF:
       /* A typedef. We do want to process these, since a name is
-       * added to the namespace for the typedef'ed name.
+       * added to the domain for the typedef'ed name.
        */
-      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile);
       if (dn_bufp->dtype.global)
        add_symbol_to_list (sym, &global_symbols);
@@ -5815,10 +5831,10 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
        int global = dn_bufp->dtag.global;
        /* Structure, union, enum, template, or class tag definition */
        /* We do want to process these, since a name is
-        * added to the namespace for the tag name (and if C++ class,
+        * added to the domain for the tag name (and if C++ class,
         * for the typename also).
         */
-       SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
+       SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
 
        /* The tag contains in its "type" field a pointer to the
         * DNTT_TYPE_STRUCT, DNTT_TYPE_UNION, DNTT_TYPE_ENUM, 
@@ -5875,7 +5891,7 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
            memset (newsym, 0, sizeof (struct symbol));
            DEPRECATED_SYMBOL_NAME (newsym) = name;
            SYMBOL_LANGUAGE (newsym) = language_auto;
-           SYMBOL_NAMESPACE (newsym) = VAR_NAMESPACE;
+           SYMBOL_DOMAIN (newsym) = VAR_DOMAIN;
            SYMBOL_LINE (newsym) = 0;
            SYMBOL_VALUE (newsym) = 0;
            SYMBOL_CLASS (newsym) = LOC_TYPEDEF;
@@ -6190,9 +6206,9 @@ static int
 hpread_get_scope_depth (union dnttentry *dn_bufp, struct objfile *objfile,
                        int report_nested)
 {
-  register int index;
-  register union dnttentry *dn_tmp;
-  register short depth = 0;
+  int index;
+  union dnttentry *dn_tmp;
+  short depth = 0;
 /****************************/
   return 0;
 /****************************/
@@ -6235,7 +6251,7 @@ hpread_get_scope_depth (union dnttentry *dn_bufp, struct objfile *objfile,
 static void
 hpread_adjust_bitoffsets (struct type *type, int bits)
 {
-  register int i;
+  int i;
 
   /* This is done only for unions; caller had better check that
      it is an anonymous one. */
@@ -6272,7 +6288,7 @@ hpread_get_next_skip_over_anon_unions (int skip_fields, dnttpointer field,
                                       struct objfile *objfile)
 {
   struct type *anon_type;
-  register int i;
+  int i;
   int bitoffset;
   char *name;
 
@@ -6290,7 +6306,7 @@ hpread_get_next_skip_over_anon_unions (int skip_fields, dnttpointer field,
       /* Do we have another anonymous union? If so, adjust the bitoffsets
          of its members and skip over its members. */
       if ((TYPE_CODE (anon_type) == TYPE_CODE_UNION) &&
-         (!name || STREQ (name, "")))
+         (!name || DEPRECATED_STREQ (name, "")))
        {
          hpread_adjust_bitoffsets (anon_type, bitoffset);
          field = hpread_get_next_skip_over_anon_unions (TYPE_NFIELDS (anon_type), field, fieldp, objfile);
This page took 0.032407 seconds and 4 git commands to generate.