2004-08-31 Robert Bowdidge <bowdidge@apple.com>
[external/binutils.git] / gdb / hpread.c
index 246f77e..de1670a 100644 (file)
@@ -37,6 +37,7 @@
 #include "demangle.h"
 #include "somsolib.h"
 #include "gdb_assert.h"
+#include "hppa-tdep.h"
 
 /* Private information attached to an objfile which we use to find
    and internalize the HP C debug symbols within that objfile.  */
@@ -234,15 +235,12 @@ static void fixup_class_method_type
 
 static void hpread_adjust_bitoffsets (struct type *, int);
 
+static int hpread_adjust_stack_address (CORE_ADDR func_addr);
+
 static dnttpointer hpread_get_next_skip_over_anon_unions
   (int, dnttpointer, union dnttentry **, struct objfile *);
 
 \f
-/* Global to indicate presence of HP-compiled objects,
-   in particular, SOM executable file with SOM debug info 
-   Defined in symtab.c, used in hppa-tdep.c. */
-extern int hp_som_som_object_present;
-
 /* Static used to indicate a class type that requires a
    fix-up of one of its method types */
 static struct type *fixup_class = NULL;
@@ -385,6 +383,7 @@ hpread_pxdb_needed (bfd *sym_bfd)
       if (header_section_size == (bfd_size_type) sizeof (DOC_info_PXDB_header))
        {
          buf = alloca (sizeof (DOC_info_PXDB_header));
+         memset (buf, 0, sizeof (DOC_info_PXDB_header));
 
          if (!bfd_get_section_contents (sym_bfd,
                                         header_section,
@@ -452,6 +451,7 @@ hpread_pxdb_needed (bfd *sym_bfd)
        {
 
          buf = alloca (sizeof (PXDB_header));
+         memset (buf, 0, sizeof (PXDB_header));
          if (!bfd_get_section_contents (sym_bfd,
                                         header_section,
                                         buf, 0,
@@ -1668,7 +1668,7 @@ hpread_symfile_init (struct objfile *objfile)
 
   /* Allocate struct to keep track of the symfile */
   objfile->sym_private =
-    xmmalloc (objfile->md, sizeof (struct hpread_symfile_info));
+    xmalloc (sizeof (struct hpread_symfile_info));
   memset (objfile->sym_private, 0, sizeof (struct hpread_symfile_info));
 
   /* We haven't read in any types yet.  */
@@ -1680,7 +1680,7 @@ hpread_symfile_init (struct objfile *objfile)
     return;
 
   GNTT (objfile)
-    = obstack_alloc (&objfile->symbol_obstack,
+    = obstack_alloc (&objfile->objfile_obstack,
                     bfd_section_size (objfile->obfd, gntt_section));
 
   bfd_get_section_contents (objfile->obfd, gntt_section, GNTT (objfile),
@@ -1702,7 +1702,7 @@ hpread_symfile_init (struct objfile *objfile)
     return;
 
   LNTT (objfile)
-    = obstack_alloc (&objfile->symbol_obstack,
+    = obstack_alloc (&objfile->objfile_obstack,
                     bfd_section_size (objfile->obfd, lntt_section));
 
   bfd_get_section_contents (objfile->obfd, lntt_section, LNTT (objfile),
@@ -1719,7 +1719,7 @@ hpread_symfile_init (struct objfile *objfile)
     return;
 
   SLT (objfile) =
-    obstack_alloc (&objfile->symbol_obstack,
+    obstack_alloc (&objfile->objfile_obstack,
                   bfd_section_size (objfile->obfd, slt_section));
 
   bfd_get_section_contents (objfile->obfd, slt_section, SLT (objfile),
@@ -1734,7 +1734,7 @@ hpread_symfile_init (struct objfile *objfile)
   VT_SIZE (objfile) = bfd_section_size (objfile->obfd, vt_section);
 
   VT (objfile) =
-    (char *) obstack_alloc (&objfile->symbol_obstack,
+    (char *) obstack_alloc (&objfile->objfile_obstack,
                            VT_SIZE (objfile));
 
   bfd_get_section_contents (objfile->obfd, vt_section, VT (objfile),
@@ -1973,7 +1973,7 @@ hpread_build_psymtabs (struct objfile *objfile, int mainline)
                    if (!have_name)
                      {
                        pst->filename = (char *)
-                         obstack_alloc (&pst->objfile->psymbol_obstack,
+                         obstack_alloc (&pst->objfile->objfile_obstack,
                                         strlen (namestring) + 1);
                        strcpy (pst->filename, namestring);
                        have_name = 1;
@@ -2286,7 +2286,7 @@ hpread_symfile_finish (struct objfile *objfile)
 {
   if (objfile->sym_private != NULL)
     {
-      xmfree (objfile->md, objfile->sym_private);
+      xfree (objfile->sym_private);
     }
 }
 \f
@@ -2392,7 +2392,7 @@ hpread_start_psymtab (struct objfile *objfile, char *filename,
 
   result->textlow += offset;
   result->read_symtab_private = (char *)
-    obstack_alloc (&objfile->psymbol_obstack, sizeof (struct symloc));
+    obstack_alloc (&objfile->objfile_obstack, sizeof (struct symloc));
   LDSYMOFF (result) = ldsymoff;
   result->read_symtab = hpread_psymtab_to_symtab;
 
@@ -2453,7 +2453,7 @@ hpread_end_psymtab (struct partial_symtab *pst, char **include_list,
   if (number_dependencies)
     {
       pst->dependencies = (struct partial_symtab **)
-       obstack_alloc (&objfile->psymbol_obstack,
+       obstack_alloc (&objfile->objfile_obstack,
                    number_dependencies * sizeof (struct partial_symtab *));
       memcpy (pst->dependencies, dependency_list,
              number_dependencies * sizeof (struct partial_symtab *));
@@ -2468,7 +2468,7 @@ hpread_end_psymtab (struct partial_symtab *pst, char **include_list,
 
       subpst->section_offsets = pst->section_offsets;
       subpst->read_symtab_private =
-       (char *) obstack_alloc (&objfile->psymbol_obstack,
+       (char *) obstack_alloc (&objfile->objfile_obstack,
                                sizeof (struct symloc));
       LDSYMOFF (subpst) =
        LDSYMLEN (subpst) =
@@ -2478,7 +2478,7 @@ hpread_end_psymtab (struct partial_symtab *pst, char **include_list,
       /* We could save slight bits of space by only making one of these,
          shared by the entire set of include files.  FIXME-someday.  */
       subpst->dependencies = (struct partial_symtab **)
-       obstack_alloc (&objfile->psymbol_obstack,
+       obstack_alloc (&objfile->objfile_obstack,
                       sizeof (struct partial_symtab *));
       subpst->dependencies[0] = pst;
       subpst->number_of_dependencies = 1;
@@ -2875,7 +2875,7 @@ hpread_expand_symtab (struct objfile *objfile, int sym_offset, int sym_size,
     }
 
   current_objfile = NULL;
-  hp_som_som_object_present = 1;       /* Indicate we've processed an HP SOM SOM file */
+  deprecated_hp_som_som_object_present = 1;    /* Indicate we've processed an HP SOM SOM file */
 
   return end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
 }
@@ -3024,7 +3024,7 @@ hpread_lookup_type (dnttpointer hp_type, struct objfile *objfile)
            {
              DNTT_TYPE_VECTOR_LENGTH (objfile) = LNTT_SYMCOUNT (objfile) + GNTT_SYMCOUNT (objfile);
              DNTT_TYPE_VECTOR (objfile) = (struct type **)
-               xmmalloc (objfile->md, DNTT_TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *));
+               xmalloc (DNTT_TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *));
              memset (&DNTT_TYPE_VECTOR (objfile)[old_len], 0,
                      (DNTT_TYPE_VECTOR_LENGTH (objfile) - old_len) *
                      sizeof (struct type *));
@@ -3042,8 +3042,7 @@ hpread_lookup_type (dnttpointer hp_type, struct objfile *objfile)
          if (size_changed)
            {
              DNTT_TYPE_VECTOR (objfile) = (struct type **)
-               xmrealloc (objfile->md,
-                          (char *) DNTT_TYPE_VECTOR (objfile),
+               xrealloc ((char *) DNTT_TYPE_VECTOR (objfile),
                   (DNTT_TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)));
 
              memset (&DNTT_TYPE_VECTOR (objfile)[old_len], 0,
@@ -3127,11 +3126,11 @@ hpread_read_enum_type (dnttpointer hp_type, union dnttentry *dn_bufp,
       memp = hpread_get_lntt (mem.dnttp.index, objfile);
 
       name = VT (objfile) + memp->dmember.name;
-      sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
+      sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
                                             sizeof (struct symbol));
       memset (sym, 0, sizeof (struct symbol));
       DEPRECATED_SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
-                                       &objfile->symbol_obstack);
+                                       &objfile->objfile_obstack);
       SYMBOL_CLASS (sym) = LOC_CONST;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_VALUE (sym) = memp->dmember.value;
@@ -3145,7 +3144,7 @@ hpread_read_enum_type (dnttpointer hp_type, union dnttentry *dn_bufp,
   TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
   TYPE_NFIELDS (type) = nsyms;
   TYPE_FIELDS (type) = (struct field *)
-    obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nsyms);
+    obstack_alloc (&objfile->objfile_obstack, sizeof (struct field) * nsyms);
 
   /* Find the symbols for the members and put them into the type.
      The symbols can be found in the symlist that we put them on
@@ -3235,11 +3234,11 @@ hpread_read_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
 
       /* Get the name.  */
       name = VT (objfile) + paramp->dfparam.name;
-      sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
+      sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
                                             sizeof (struct symbol));
       (void) memset (sym, 0, sizeof (struct symbol));
       DEPRECATED_SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
-                                       &objfile->symbol_obstack);
+                                       &objfile->objfile_obstack);
 
       /* Figure out where it lives.  */
       if (paramp->dfparam.regparam)
@@ -3252,10 +3251,9 @@ hpread_read_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
       if (paramp->dfparam.copyparam)
        {
          SYMBOL_VALUE (sym) = paramp->dfparam.location;
-#ifdef HPREAD_ADJUST_STACK_ADDRESS
          SYMBOL_VALUE (sym)
-           += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
-#endif
+           += hpread_adjust_stack_address (CURRENT_FUNCTION_VALUE (objfile));
+
          /* This is likely a pass-by-invisible reference parameter,
             Hack on the symbol class to make GDB happy.  */
          /* ??rehrauer: This appears to be broken w/r/t to passing
@@ -3306,7 +3304,7 @@ hpread_read_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
   /* Note how many parameters we found.  */
   TYPE_NFIELDS (type) = nsyms;
   TYPE_FIELDS (type) = (struct field *)
-    obstack_alloc (&objfile->type_obstack,
+    obstack_alloc (&objfile->objfile_obstack,
                   sizeof (struct field) * nsyms);
 
   /* Find the symbols for the parameters and 
@@ -3415,7 +3413,7 @@ hpread_read_doc_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
 
       /* Get the name.  */
       name = VT (objfile) + paramp->dfparam.name;
-      sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
+      sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
                                             sizeof (struct symbol));
       (void) memset (sym, 0, sizeof (struct symbol));
       DEPRECATED_SYMBOL_NAME (sym) = name;
@@ -3431,10 +3429,9 @@ hpread_read_doc_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
       if (paramp->dfparam.copyparam)
        {
          SYMBOL_VALUE (sym) = paramp->dfparam.location;
-#ifdef HPREAD_ADJUST_STACK_ADDRESS
          SYMBOL_VALUE (sym)
-           += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
-#endif
+           += hpread_adjust_stack_address(CURRENT_FUNCTION_VALUE (objfile));
+
          /* This is likely a pass-by-invisible reference parameter,
             Hack on the symbol class to make GDB happy.  */
          /* ??rehrauer: This appears to be broken w/r/t to passing
@@ -3485,7 +3482,7 @@ hpread_read_doc_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
   /* Note how many parameters we found.  */
   TYPE_NFIELDS (type) = nsyms;
   TYPE_FIELDS (type) = (struct field *)
-    obstack_alloc (&objfile->type_obstack,
+    obstack_alloc (&objfile->objfile_obstack,
                   sizeof (struct field) * nsyms);
 
   /* Find the symbols for the parameters and 
@@ -3690,6 +3687,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
 
          /* Get space to record the next field/data-member. */
          new = (struct nextfield *) alloca (sizeof (struct nextfield));
+         memset (new, 0, sizeof (struct nextfield));
          new->next = list;
          list = new;
 
@@ -3768,6 +3766,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
          n_templ_args++;
          /* Allocate and fill in a struct next_template */
          t_new = (struct next_template *) alloca (sizeof (struct next_template));
+         memset (t_new, 0, sizeof (struct next_template));
          t_new->next = t_list;
          t_list = t_new;
          t_list->arg.name = VT (objfile) + fieldp->dtempl_arg.name;
@@ -3782,7 +3781,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
 
   if (n_templ_args > 0)
     TYPE_TEMPLATE_ARGS (type) = (struct template_arg *)
-      obstack_alloc (&objfile->type_obstack, sizeof (struct template_arg) * n_templ_args);
+      obstack_alloc (&objfile->objfile_obstack, sizeof (struct template_arg) * n_templ_args);
   for (n = n_templ_args; t_list; t_list = t_list->next)
     {
       n -= 1;
@@ -3908,6 +3907,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
                  /* Get space to record this member function */
                  /* Note: alloca used; this will disappear on routine exit */
                  fn_new = (struct next_fn_field *) alloca (sizeof (struct next_fn_field));
+                 memset (fn_new, 0, sizeof (struct next_fn_field));
                  fn_new->next = fn_list;
                  fn_list = fn_new;
 
@@ -4025,6 +4025,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
 
              /* Get space to record this static member */
              new = (struct nextfield *) alloca (sizeof (struct nextfield));
+             memset (new, 0, sizeof (struct nextfield));
              new->next = list;
              list = new;
 
@@ -4055,6 +4056,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
                warning ("Debug info inconsistent: FIELD of anonymous union doesn't have a_union bit set");
              /* Get space to record the next field/data-member. */
              new = (struct nextfield *) alloca (sizeof (struct nextfield));
+             memset (new, 0, sizeof (struct nextfield));
              new->next = list;
              list = new;
 
@@ -4086,6 +4088,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
                warning ("Debug info inconsistent: SVAR field in anonymous union doesn't have a_union bit set");
              /* Get space to record the next field/data-member. */
              new = (struct nextfield *) alloca (sizeof (struct nextfield));
+             memset (new, 0, sizeof (struct nextfield));
              new->next = list;
              list = new;
 
@@ -4106,6 +4109,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
                warning ("Debug info inconsistent: DVAR field in anonymous union doesn't have a_union bit set");
              /* Get space to record the next field/data-member. */
              new = (struct nextfield *) alloca (sizeof (struct nextfield));
+             memset (new, 0, sizeof (struct nextfield));
              new->next = list;
              list = new;
 
@@ -4154,6 +4158,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
 
          /* Get space to record the next field/data-member. */
          new = (struct nextfield *) alloca (sizeof (struct nextfield));
+         memset (new, 0, sizeof (struct nextfield));
          new->next = list;
          list = new;
 
@@ -4237,6 +4242,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
            break;
 
          i_new = (struct next_instantiation *) alloca (sizeof (struct next_instantiation));
+         memset (i_new, 0, sizeof (struct next_instantiation));
          i_new->next = i_list;
          i_list = i_new;
          i_list->t = hpread_type_lookup (field, objfile);
@@ -4255,7 +4261,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
   TYPE_NINSTANTIATIONS (type) = ninstantiations;
   if (ninstantiations > 0)
     TYPE_INSTANTIATIONS (type) = (struct type **)
-      obstack_alloc (&objfile->type_obstack, sizeof (struct type *) * ninstantiations);
+      obstack_alloc (&objfile->objfile_obstack, sizeof (struct type *) * ninstantiations);
   for (n = ninstantiations; i_list; i_list = i_list->next)
     {
       n -= 1;
@@ -4267,7 +4273,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
   TYPE_NFIELDS (type) = nfields;
   TYPE_N_BASECLASSES (type) = n_base_classes;
   TYPE_FIELDS (type) = (struct field *)
-    obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nfields);
+    obstack_alloc (&objfile->objfile_obstack, sizeof (struct field) * nfields);
   /* Copy the saved-up fields into the field vector.  */
   for (n = nfields, tmp_list = list; tmp_list; tmp_list = tmp_list->next)
     {
@@ -4281,7 +4287,7 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
   TYPE_NFN_FIELDS (type) = n_fn_fields;
   TYPE_NFN_FIELDS_TOTAL (type) = n_fn_fields_total;
   TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
-    obstack_alloc (&objfile->type_obstack, sizeof (struct fn_fieldlist) * n_fn_fields);
+    obstack_alloc (&objfile->objfile_obstack, sizeof (struct fn_fieldlist) * n_fn_fields);
   for (n = n_fn_fields; fn_list; fn_list = fn_list->next)
     {
       n -= 1;
@@ -4399,7 +4405,7 @@ fix_static_member_physnames (struct type *type, char *class_name,
          return;               /* physnames are already set */
 
        SET_FIELD_PHYSNAME (TYPE_FIELDS (type)[i],
-                           obstack_alloc (&objfile->type_obstack,
+                           obstack_alloc (&objfile->objfile_obstack,
             strlen (class_name) + strlen (TYPE_FIELD_NAME (type, i)) + 3));
        strcpy (TYPE_FIELD_STATIC_PHYSNAME (type, i), class_name);
        strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), "::");
@@ -4562,7 +4568,7 @@ hpread_read_array_type (dnttpointer hp_type, union dnttentry *dn_bufp,
    */
   TYPE_NFIELDS (type) = 1;
   TYPE_FIELDS (type) = (struct field *)
-    obstack_alloc (&objfile->type_obstack, sizeof (struct field));
+    obstack_alloc (&objfile->objfile_obstack, sizeof (struct field));
   TYPE_FIELD_TYPE (type, 0) = hpread_type_lookup (dn_bufp->darray.indextype,
                                                  objfile);
   return type;
@@ -4585,7 +4591,7 @@ hpread_read_subrange_type (dnttpointer hp_type, union dnttentry *dn_bufp,
   TYPE_LENGTH (type) = dn_bufp->dsubr.bitlength / 8;
   TYPE_NFIELDS (type) = 2;
   TYPE_FIELDS (type)
-    = (struct field *) obstack_alloc (&objfile->type_obstack,
+    = (struct field *) obstack_alloc (&objfile->objfile_obstack,
                                      2 * sizeof (struct field));
 
   if (dn_bufp->dsubr.dyn_low)
@@ -4803,7 +4809,7 @@ hpread_type_lookup (dnttpointer hp_type, struct objfile *objfile)
 
        /* Build the correct name.  */
        TYPE_NAME (structtype)
-         = (char *) obstack_alloc (&objfile->type_obstack,
+         = (char *) obstack_alloc (&objfile->objfile_obstack,
                                    strlen (prefix) + strlen (suffix) + 1);
        TYPE_NAME (structtype) = strcpy (TYPE_NAME (structtype), prefix);
        TYPE_NAME (structtype) = strcat (TYPE_NAME (structtype), suffix);
@@ -5098,10 +5104,10 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
   char *class_scope_name;
 
   /* Allocate one GDB debug symbol and fill in some default values. */
-  sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
+  sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
                                         sizeof (struct symbol));
   memset (sym, 0, sizeof (struct symbol));
-  DEPRECATED_SYMBOL_NAME (sym) = obsavestring (name, strlen (name), &objfile->symbol_obstack);
+  DEPRECATED_SYMBOL_NAME (sym) = obsavestring (name, strlen (name), &objfile->objfile_obstack);
   SYMBOL_LANGUAGE (sym) = language_auto;
   SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
   SYMBOL_LINE (sym) = 0;
@@ -5304,7 +5310,7 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
           * some things broke, so I'm leaving it in here, and
           * working around the issue in stack.c. - RT
           */
-         SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
+         SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->objfile_obstack);
          if ((DEPRECATED_SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->dfunc.alias) &&
              (!SYMBOL_CPLUS_DEMANGLED_NAME (sym)))
            {
@@ -5420,7 +5426,7 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
           * some things broke, so I'm leaving it in here, and
           * working around the issue in stack.c. - RT 
           */
-         SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
+         SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->objfile_obstack);
 
          if ((DEPRECATED_SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->ddocfunc.alias) &&
              (!SYMBOL_CPLUS_DEMANGLED_NAME (sym)))
@@ -5702,10 +5708,8 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
       if (dn_bufp->dfparam.copyparam)
        {
          SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
-#ifdef HPREAD_ADJUST_STACK_ADDRESS
          SYMBOL_VALUE (sym)
-           += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
-#endif
+           += hpread_adjust_stack_address (CURRENT_FUNCTION_VALUE (objfile));
        }
       else
        SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
@@ -5747,7 +5751,7 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
          /* Thread-local variable.
           */
          SYMBOL_CLASS (sym) = LOC_HP_THREAD_LOCAL_STATIC;
-         SYMBOL_BASEREG (sym) = CR27_REGNUM;
+         SYMBOL_BASEREG (sym) = HPPA_CR27_REGNUM;
 
          if (objfile->flags & OBJF_SHARED)
            {
@@ -5759,11 +5763,14 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
               * to "somsolib.c".  But C lets us point to one.
               */
              struct so_list *so;
+              struct hppa_objfile_private *priv;
 
-             if (objfile->obj_private == NULL)
+              priv = (struct hppa_objfile_private *)
+               objfile_data (objfile, hppa_objfile_priv_data);
+             if (priv == NULL)
                error ("Internal error in reading shared library information.");
 
-             so = ((obj_private_data_t *) (objfile->obj_private))->so_info;
+             so = ((struct hppa_objfile_private *) priv)->so_info;
              if (so == NULL)
                error ("Internal error in reading shared library information.");
 
@@ -5786,10 +5793,8 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
        SYMBOL_CLASS (sym) = LOC_LOCAL;
 
       SYMBOL_VALUE (sym) = dn_bufp->ddvar.location;
-#ifdef HPREAD_ADJUST_STACK_ADDRESS
       SYMBOL_VALUE (sym)
-       += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
-#endif
+       += hpread_adjust_stack_address (CURRENT_FUNCTION_VALUE (objfile));
       SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->ddvar.type, objfile);
       if (dn_bufp->ddvar.global)
        add_symbol_to_list (sym, &global_symbols);
@@ -5886,7 +5891,7 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name,
          {
            struct symbol *newsym;
 
-           newsym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
+           newsym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
                                                    sizeof (struct symbol));
            memset (newsym, 0, sizeof (struct symbol));
            DEPRECATED_SYMBOL_NAME (newsym) = name;
@@ -6269,6 +6274,24 @@ hpread_adjust_bitoffsets (struct type *type, int bits)
     TYPE_FIELD_BITPOS (type, i) -= bits;
 }
 
+/* Return the adjustment necessary to make for addresses on the stack
+   as presented by hpread.c.
+
+   This is necessary because of the stack direction on the PA and the
+   bizarre way in which someone (?) decided they wanted to handle
+   frame pointerless code in GDB.  */
+int
+hpread_adjust_stack_address (CORE_ADDR func_addr)
+{
+  struct unwind_table_entry *u;
+
+  u = find_unwind_entry (func_addr);
+  if (!u)
+    return 0;
+  else
+    return u->Total_frame_size << 3;
+}
+
 /* Because of quirks in HP compilers' treatment of anonymous unions inside
    classes, we have to chase through a chain of threaded FIELD entries.
    If we encounter an anonymous union in the chain, we must recursively skip over