+2004-04-17 Randolph Chung <tausq@debian.org>
+
+ * Makefile.in (hpread.o, pa64solib.o, somsolib.o): Add $(hppa_tdep_h)
+ * hppa-tdep.h (INSTRUCTION_SIZE): Move from tm-hppa.h.
+ (hpread_adjust_stack_address): Move to hpread.c.
+ * hppa-tdep.h (unwind_table_entry, unwind_stub_types, obj_unwind_info,
+ obj_private_struct): Move from tm-hppa.h.
+ * hpread.c (hppa-tdep.h): Include.
+ (hpread_adjust_stack_address): Move from hppa-tdep.c.
+ (hpread_read_function_type, hpread_read_doc_function_type)
+ (hpread_process_one_debug_symbol): Call hpread_adjust_stack_address
+ directly.
+ * pa64solib.c (hppa-tdep.h): Include.
+ * somsolib.c (hppa-tdep.h): Include.
+ * config/pa/tm-hppa.h (frame_info, frame_saved_regs, value, type,
+ inferior_status): Remove unused forward declarations.
+ (INSTRUCTION_SIZE): Move to hppa-tdep.c.
+ (unwind_table_entry, unwind_stub_types, obj_unwind_info,
+ obj_private_struct): Move to hppa-tdep.h.
+ (HPREAD_ADJUST_STACK_ADDRESS): Remove.
+
2004-04-17 Randolph Chung <tausq@debian.org>
* hppa-tdep.c (hppa_reg_struct_has_addr, hppa_skip_prologue)
hpread.o: hpread.c $(defs_h) $(bfd_h) $(gdb_string_h) $(hp_symtab_h) \
$(syms_h) $(symtab_h) $(symfile_h) $(objfiles_h) $(buildsym_h) \
$(complaints_h) $(gdb_stabs_h) $(gdbtypes_h) $(demangle_h) \
- $(somsolib_h) $(gdb_assert_h) $(gdb_string_h)
+ $(somsolib_h) $(gdb_assert_h) $(gdb_string_h) $(hppa_tdep_h)
hpux-thread.o: hpux-thread.c $(defs_h) $(gdbthread_h) $(target_h) \
$(inferior_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h)
i386bsd-nat.o: i386bsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
pa64solib.o: pa64solib.c $(defs_h) $(frame_h) $(bfd_h) $(libhppa_h) \
$(gdbcore_h) $(symtab_h) $(breakpoint_h) $(symfile_h) $(objfiles_h) \
$(inferior_h) $(gdb_stabs_h) $(gdb_stat_h) $(gdbcmd_h) $(language_h) \
- $(regcache_h) $(exec_h)
+ $(regcache_h) $(exec_h) $(hppa_tdep_h)
parse.o: parse.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
$(frame_h) $(expression_h) $(value_h) $(command_h) $(language_h) \
$(parser_defs_h) $(gdbcmd_h) $(symfile_h) $(inferior_h) \
somsolib.o: somsolib.c $(defs_h) $(frame_h) $(bfd_h) $(som_h) $(libhppa_h) \
$(gdbcore_h) $(symtab_h) $(breakpoint_h) $(symfile_h) $(objfiles_h) \
$(inferior_h) $(gdb_stabs_h) $(gdb_stat_h) $(gdbcmd_h) $(language_h) \
- $(regcache_h) $(gdb_assert_h) $(exec_h)
+ $(regcache_h) $(gdb_assert_h) $(exec_h) $(hppa_tdep_h)
source.o: source.c $(defs_h) $(symtab_h) $(expression_h) $(language_h) \
$(command_h) $(source_h) $(gdbcmd_h) $(frame_h) $(value_h) \
$(gdb_string_h) $(gdb_stat_h) $(gdbcore_h) $(gdb_regex_h) \
#define GDB_MULTI_ARCH 1
-/* Hack, get around problem with including "arch-utils.h". */
-struct frame_info;
-
-/* Forward declarations of some types we use in prototypes */
-
-struct frame_info;
-struct frame_saved_regs;
-struct value;
-struct type;
-struct inferior_status;
-
extern int hppa_pc_requires_run_before_use (CORE_ADDR pc);
#define PC_REQUIRES_RUN_BEFORE_USE(pc) hppa_pc_requires_run_before_use (pc)
#define INSTRUCTION_NULLIFIED hppa_instruction_nullified ()
#endif
-#define INSTRUCTION_SIZE 4
-
-/*
- * Unwind table and descriptor.
- */
-
-struct unwind_table_entry
- {
- CORE_ADDR region_start;
- CORE_ADDR region_end;
-
- unsigned int Cannot_unwind:1; /* 0 */
- unsigned int Millicode:1; /* 1 */
- unsigned int Millicode_save_sr0:1; /* 2 */
- unsigned int Region_description:2; /* 3..4 */
- unsigned int reserved1:1; /* 5 */
- unsigned int Entry_SR:1; /* 6 */
- unsigned int Entry_FR:4; /* number saved *//* 7..10 */
- unsigned int Entry_GR:5; /* number saved *//* 11..15 */
- unsigned int Args_stored:1; /* 16 */
- unsigned int Variable_Frame:1; /* 17 */
- unsigned int Separate_Package_Body:1; /* 18 */
- unsigned int Frame_Extension_Millicode:1; /* 19 */
- unsigned int Stack_Overflow_Check:1; /* 20 */
- unsigned int Two_Instruction_SP_Increment:1; /* 21 */
- unsigned int Ada_Region:1; /* 22 */
- unsigned int cxx_info:1; /* 23 */
- unsigned int cxx_try_catch:1; /* 24 */
- unsigned int sched_entry_seq:1; /* 25 */
- unsigned int reserved2:1; /* 26 */
- unsigned int Save_SP:1; /* 27 */
- unsigned int Save_RP:1; /* 28 */
- unsigned int Save_MRP_in_frame:1; /* 29 */
- unsigned int extn_ptr_defined:1; /* 30 */
- unsigned int Cleanup_defined:1; /* 31 */
-
- unsigned int MPE_XL_interrupt_marker:1; /* 0 */
- unsigned int HP_UX_interrupt_marker:1; /* 1 */
- unsigned int Large_frame:1; /* 2 */
- unsigned int Pseudo_SP_Set:1; /* 3 */
- unsigned int reserved4:1; /* 4 */
- unsigned int Total_frame_size:27; /* 5..31 */
-
- /* This is *NOT* part of an actual unwind_descriptor in an object
- file. It is *ONLY* part of the "internalized" descriptors that
- we create from those in a file.
- */
- struct
- {
- unsigned int stub_type:4; /* 0..3 */
- unsigned int padding:28; /* 4..31 */
- }
- stub_unwind;
- };
-
-/* HP linkers also generate unwinds for various linker-generated stubs.
- GDB reads in the stubs from the $UNWIND_END$ subspace, then
- "converts" them into normal unwind entries using some of the reserved
- fields to store the stub type. */
-
-/* The gaps represent linker stubs used in MPE and space for future
- expansion. */
-enum unwind_stub_types
- {
- LONG_BRANCH = 1,
- PARAMETER_RELOCATION = 2,
- EXPORT = 10,
- IMPORT = 11,
- IMPORT_SHLIB = 12,
- };
-
-/* We use the objfile->obj_private pointer for two things:
-
- * 1. An unwind table;
- *
- * 2. A pointer to any associated shared library object.
- *
- * #defines are used to help refer to these objects.
- */
-
-/* Info about the unwind table associated with an object file.
-
- * This is hung off of the "objfile->obj_private" pointer, and
- * is allocated in the objfile's psymbol obstack. This allows
- * us to have unique unwind info for each executable and shared
- * library that we are debugging.
- */
-struct obj_unwind_info
- {
- struct unwind_table_entry *table; /* Pointer to unwind info */
- struct unwind_table_entry *cache; /* Pointer to last entry we found */
- int last; /* Index of last entry */
- };
-
-typedef struct obj_private_struct
- {
- struct obj_unwind_info *unwind_info; /* a pointer */
- struct so_list *so_info; /* a pointer */
- CORE_ADDR dp;
- }
-obj_private_data_t;
-
-/* For a number of horrible reasons we may have to adjust the location
- of variables on the stack. Ugh. */
-#define HPREAD_ADJUST_STACK_ADDRESS(ADDR) hpread_adjust_stack_address(ADDR)
-extern int hpread_adjust_stack_address (CORE_ADDR);
-
/* Here's how to step off a permanent breakpoint. */
#define SKIP_PERMANENT_BREAKPOINT (hppa_skip_permanent_breakpoint)
extern void hppa_skip_permanent_breakpoint (void);
static const int hppa32_num_regs = 128;
static const int hppa64_num_regs = 96;
+/* hppa-specific object data -- unwind and solib info.
+ TODO/maybe: think about splitting this into two parts; the unwind data is
+ common to all hppa targets, but is only used in this file; we can register
+ that separately and make this static. The solib data is probably hpux-
+ specific, so we can create a separate extern objfile_data that is registered
+ by hppa-hpux-tdep.c and shared with pa64solib.c and somsolib.c. */
+const struct objfile_data *hppa_objfile_priv_data = NULL;
+
/* Get at various relevent fields of an instruction word. */
#define MASK_5 0x1f
#define MASK_11 0x7ff
/* Define offsets into the call dummy for the _sr4export address.
See comments related to CALL_DUMMY for more info. */
-#define SR4EXPORT_LDIL_OFFSET (INSTRUCTION_SIZE * 12)
-#define SR4EXPORT_LDO_OFFSET (INSTRUCTION_SIZE * 13)
+#define SR4EXPORT_LDIL_OFFSET (HPPA_INSTRUCTION_SIZE * 12)
+#define SR4EXPORT_LDO_OFFSET (HPPA_INSTRUCTION_SIZE * 13)
/* To support detection of the pseudo-initial frame
that threads have. */
unsigned index, unwind_entries;
unsigned stub_entries, total_entries;
CORE_ADDR text_offset;
- struct obj_unwind_info *ui;
- obj_private_data_t *obj_private;
+ struct hppa_unwind_info *ui;
+ struct hppa_objfile_private *obj_private;
text_offset = ANOFFSET (objfile->section_offsets, 0);
- ui = (struct obj_unwind_info *) obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct obj_unwind_info));
+ ui = (struct hppa_unwind_info *) obstack_alloc (&objfile->objfile_obstack,
+ sizeof (struct hppa_unwind_info));
ui->table = NULL;
ui->cache = NULL;
compare_unwind_entries);
/* Keep a pointer to the unwind information. */
- if (objfile->obj_private == NULL)
+ obj_private = (struct hppa_objfile_private *)
+ objfile_data (objfile, hppa_objfile_priv_data);
+ if (obj_private == NULL)
{
- obj_private = (obj_private_data_t *)
- obstack_alloc (&objfile->objfile_obstack,
- sizeof (obj_private_data_t));
+ obj_private = (struct hppa_objfile_private *)
+ obstack_alloc (&objfile->objfile_obstack,
+ sizeof (struct hppa_objfile_private));
+ set_objfile_data (objfile, hppa_objfile_priv_data, obj_private);
obj_private->unwind_info = NULL;
obj_private->so_info = NULL;
obj_private->dp = 0;
-
- objfile->obj_private = obj_private;
}
- obj_private = (obj_private_data_t *) objfile->obj_private;
obj_private->unwind_info = ui;
}
{
int first, middle, last;
struct objfile *objfile;
+ struct hppa_objfile_private *priv;
/* A function at address 0? Not in HP-UX! */
if (pc == (CORE_ADDR) 0)
ALL_OBJFILES (objfile)
{
- struct obj_unwind_info *ui;
+ struct hppa_unwind_info *ui;
ui = NULL;
- if (objfile->obj_private)
- ui = ((obj_private_data_t *) (objfile->obj_private))->unwind_info;
+ priv = objfile_data (objfile, hppa_objfile_priv_data);
+ if (priv)
+ ui = ((struct hppa_objfile_private *) priv)->unwind_info;
if (!ui)
{
read_unwind_info (objfile);
- if (objfile->obj_private == NULL)
+ priv = objfile_data (objfile, hppa_objfile_priv_data);
+ if (priv == NULL)
error ("Internal error reading unwind information.");
- ui = ((obj_private_data_t *) (objfile->obj_private))->unwind_info;
+ ui = ((struct hppa_objfile_private *) priv)->unwind_info;
}
/* First, check the cache */
return names[i];
}
-
-
-/* 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;
-}
-
/* This function pushes a stack frame with arguments as part of the
inferior function calling mechanism.
gdbarch_register (bfd_arch_hppa, hppa_gdbarch_init, hppa_dump_tdep);
+ hppa_objfile_priv_data = register_objfile_data ();
+
add_cmd ("unwind", class_maintenance, unwind_command,
"Print unwind table entry at given address.",
&maintenanceprintlist);
#ifndef HPPA_TDEP_H
#define HPPA_TDEP_H
+enum { HPPA_INSTRUCTION_SIZE = 4 };
+
/* Target-dependent structure in gdbarch. */
struct gdbarch_tdep
{
int bytes_per_address;
};
+/*
+ * Unwind table and descriptor.
+ */
+
+struct unwind_table_entry
+ {
+ CORE_ADDR region_start;
+ CORE_ADDR region_end;
+
+ unsigned int Cannot_unwind:1; /* 0 */
+ unsigned int Millicode:1; /* 1 */
+ unsigned int Millicode_save_sr0:1; /* 2 */
+ unsigned int Region_description:2; /* 3..4 */
+ unsigned int reserved1:1; /* 5 */
+ unsigned int Entry_SR:1; /* 6 */
+ unsigned int Entry_FR:4; /* number saved *//* 7..10 */
+ unsigned int Entry_GR:5; /* number saved *//* 11..15 */
+ unsigned int Args_stored:1; /* 16 */
+ unsigned int Variable_Frame:1; /* 17 */
+ unsigned int Separate_Package_Body:1; /* 18 */
+ unsigned int Frame_Extension_Millicode:1; /* 19 */
+ unsigned int Stack_Overflow_Check:1; /* 20 */
+ unsigned int Two_Instruction_SP_Increment:1; /* 21 */
+ unsigned int Ada_Region:1; /* 22 */
+ unsigned int cxx_info:1; /* 23 */
+ unsigned int cxx_try_catch:1; /* 24 */
+ unsigned int sched_entry_seq:1; /* 25 */
+ unsigned int reserved2:1; /* 26 */
+ unsigned int Save_SP:1; /* 27 */
+ unsigned int Save_RP:1; /* 28 */
+ unsigned int Save_MRP_in_frame:1; /* 29 */
+ unsigned int extn_ptr_defined:1; /* 30 */
+ unsigned int Cleanup_defined:1; /* 31 */
+
+ unsigned int MPE_XL_interrupt_marker:1; /* 0 */
+ unsigned int HP_UX_interrupt_marker:1; /* 1 */
+ unsigned int Large_frame:1; /* 2 */
+ unsigned int Pseudo_SP_Set:1; /* 3 */
+ unsigned int reserved4:1; /* 4 */
+ unsigned int Total_frame_size:27; /* 5..31 */
+
+ /* This is *NOT* part of an actual unwind_descriptor in an object
+ file. It is *ONLY* part of the "internalized" descriptors that
+ we create from those in a file.
+ */
+ struct
+ {
+ unsigned int stub_type:4; /* 0..3 */
+ unsigned int padding:28; /* 4..31 */
+ }
+ stub_unwind;
+ };
+
+/* HP linkers also generate unwinds for various linker-generated stubs.
+ GDB reads in the stubs from the $UNWIND_END$ subspace, then
+ "converts" them into normal unwind entries using some of the reserved
+ fields to store the stub type. */
+
+/* The gaps represent linker stubs used in MPE and space for future
+ expansion. */
+enum unwind_stub_types
+ {
+ LONG_BRANCH = 1,
+ PARAMETER_RELOCATION = 2,
+ EXPORT = 10,
+ IMPORT = 11,
+ IMPORT_SHLIB = 12,
+ };
+
+/* We use the objfile->obj_private pointer for two things:
+ * 1. An unwind table;
+ *
+ * 2. A pointer to any associated shared library object.
+ *
+ * #defines are used to help refer to these objects.
+ */
+
+/* Info about the unwind table associated with an object file.
+ * This is hung off of the "objfile->obj_private" pointer, and
+ * is allocated in the objfile's psymbol obstack. This allows
+ * us to have unique unwind info for each executable and shared
+ * library that we are debugging.
+ */
+struct hppa_unwind_info
+ {
+ struct unwind_table_entry *table; /* Pointer to unwind info */
+ struct unwind_table_entry *cache; /* Pointer to last entry we found */
+ int last; /* Index of last entry */
+ };
+
+struct hppa_objfile_private
+ {
+ struct hppa_unwind_info *unwind_info; /* a pointer */
+ struct so_list *so_info; /* a pointer */
+ CORE_ADDR dp;
+ };
+
+extern const struct objfile_data *hppa_objfile_priv_data;
+
#endif /* HPPA_TDEP_H */
#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. */
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 *);
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
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
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;
* 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.");
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);
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
#include "language.h"
#include "regcache.h"
#include "exec.h"
+#include "hppa-tdep.h"
#include <fcntl.h>
{
bfd *tmp_bfd;
asection *sec;
- obj_private_data_t *obj_private;
+ struct hppa_objfile_private *obj_private;
struct section_addr_info *section_addrs;
struct cleanup *my_cleanups;
/* Mark this as a shared library and save private data. */
so->objfile->flags |= OBJF_SHARED;
- if (so->objfile->obj_private == NULL)
+ obj_private = (struct hppa_objfile_private *)
+ objfile_data (so->objfile, hppa_objfile_priv_data);
+ if (obj_private == NULL)
{
- obj_private = (obj_private_data_t *)
+ obj_private = (struct hppa_objfile_private *)
obstack_alloc (&so->objfile->objfile_obstack,
- sizeof (obj_private_data_t));
+ sizeof (struct hppa_objfile_private));
+ set_objfile_data (so->objfile, hppa_objfile_priv_data, obj_private);
obj_private->unwind_info = NULL;
obj_private->so_info = NULL;
- so->objfile->obj_private = obj_private;
}
- obj_private = (obj_private_data_t *) so->objfile->obj_private;
obj_private->so_info = so;
obj_private->dp = so->pa64_solib_desc.linkage_ptr;
do_cleanups (my_cleanups);
#include "regcache.h"
#include "gdb_assert.h"
#include "exec.h"
+#include "hppa-tdep.h"
#include <fcntl.h>
som_solib_add_solib_objfile (struct so_list *so, char *name, int from_tty,
CORE_ADDR text_addr)
{
- obj_private_data_t *obj_private;
+ struct hppa_objfile_private *obj_private;
struct obj_section *s;
so->objfile = symbol_file_add (name, from_tty, NULL, 0, OBJF_SHARED);
*/
so->objfile->flags |= OBJF_SHARED;
- if (so->objfile->obj_private == NULL)
+ obj_private = (struct hppa_objfile_private *)
+ objfile_data (so->objfile, hppa_objfile_priv_data);
+ if (obj_private == NULL)
{
- obj_private = (obj_private_data_t *)
+ obj_private = (struct hppa_objfile_private *)
obstack_alloc (&so->objfile->objfile_obstack,
- sizeof (obj_private_data_t));
+ sizeof (struct hppa_objfile_private));
+ set_objfile_data (so->objfile, hppa_objfile_priv_data, obj_private);
obj_private->unwind_info = NULL;
obj_private->so_info = NULL;
- so->objfile->obj_private = obj_private;
}
- obj_private = (obj_private_data_t *) so->objfile->obj_private;
obj_private->so_info = so;
if (!bfd_check_format (so->abfd, bfd_object))