Further multiarching work mostly for hppa64-*-hpux11:

* hppa-tdep.h: New file.
        * hppa-tdep.c: #include hppa-tdep.c.
        (hppa32_num_regs): Renamed from hppa_num_regs.
        (hppa64_num_regs): New constant.
        (hppa64_call_dummy_breakpoint_offset): New constant.
        (hppa32_call_dummy_length): New constant.
        (hppa64_call_dummy_length): New constant.
        (hppa32_stack_align): Make name 32bit explicit.
        (hppa32_register_virtual_type): Likewise.
        (hppa32_extract_return_value): Likewise.
        (hppa32_use_struct_convention): Likewise.
        (hppa32_store_return_value): Likewise.
        (hppa64_register_virtual_type): New function.
        (hppa64_extract_return_value): New function.
        (hppa64_use_struct_convention): New function.
        (hppa64_store_return_value): New function.
        (hppa_frame_locals_address): Remove declaration, function does
        not exist anymore.
        (hppa_register_byte): Add support for PA64 ABI.
        (hppa_gdbarch_init): Add support for PA64 ABI.
        * hppa-hpux-tdep.c (hppa32_hpux_frame_saved_pc_in_sigtramp):
        Make name 32bit explicit.
        (hppa32_hpux_frame_base_before_sigtramp): Likewise.
        (hppa32_hpux_frame_find_saved_regs_in_sigtramp): Likewise.
        (hppa64_hpux_frame_saved_pc_in_sigtramp): New function.
        (hppa64_hpux_frame_base_before_sigtramp): New function.
        (hppa64_hpux_frame_find_saved_regs_in_sigtramp): New function.
        * config/pa/tm-hppa64.h: Remove macros that are no longer
        necessary now that the gdbarch vector is properly setup.
        Transform some macros into function calls. Some minor cleanup.
        * config/pa/tm-hppah.h: Update function calls in macros
        following the function renaming in hppa-hpux-tdep.c.
        * Makefile.in (hppa_tdep_h): New variable.
        (hppa-tdep.o): Add dependency over hppa_tdep_h.
This commit is contained in:
Joel Brobecker 2003-08-15 23:02:05 +00:00
parent 530f3c202a
commit 3ff7cf9eed
7 changed files with 335 additions and 244 deletions

View File

@ -1,3 +1,41 @@
2003-08-15 J. Brobecker <brobecker@gnat.com>
Further multiarching work mostly for hppa64-*-hpux11:
* hppa-tdep.h: New file.
* hppa-tdep.c: #include hppa-tdep.c.
(hppa32_num_regs): Renamed from hppa_num_regs.
(hppa64_num_regs): New constant.
(hppa64_call_dummy_breakpoint_offset): New constant.
(hppa32_call_dummy_length): New constant.
(hppa64_call_dummy_length): New constant.
(hppa32_stack_align): Make name 32bit explicit.
(hppa32_register_virtual_type): Likewise.
(hppa32_extract_return_value): Likewise.
(hppa32_use_struct_convention): Likewise.
(hppa32_store_return_value): Likewise.
(hppa64_register_virtual_type): New function.
(hppa64_extract_return_value): New function.
(hppa64_use_struct_convention): New function.
(hppa64_store_return_value): New function.
(hppa_frame_locals_address): Remove declaration, function does
not exist anymore.
(hppa_register_byte): Add support for PA64 ABI.
(hppa_gdbarch_init): Add support for PA64 ABI.
* hppa-hpux-tdep.c (hppa32_hpux_frame_saved_pc_in_sigtramp):
Make name 32bit explicit.
(hppa32_hpux_frame_base_before_sigtramp): Likewise.
(hppa32_hpux_frame_find_saved_regs_in_sigtramp): Likewise.
(hppa64_hpux_frame_saved_pc_in_sigtramp): New function.
(hppa64_hpux_frame_base_before_sigtramp): New function.
(hppa64_hpux_frame_find_saved_regs_in_sigtramp): New function.
* config/pa/tm-hppa64.h: Remove macros that are no longer
necessary now that the gdbarch vector is properly setup.
Transform some macros into function calls. Some minor cleanup.
* config/pa/tm-hppah.h: Update function calls in macros
following the function renaming in hppa-hpux-tdep.c.
* Makefile.in (hppa_tdep_h): New variable.
(hppa-tdep.o): Add dependency over hppa_tdep_h.
2003-08-14 Michael Snyder <msnyder@redhat.com>
* disasm.c (gdb_disassemble_info): Set info->insn_sets to zero.

View File

@ -687,6 +687,7 @@ gdb_vfork_h = gdb_vfork.h
gdb_wait_h = gdb_wait.h
gnu_nat_h = gnu-nat.h
gregset_h = gregset.h
hppa_tdep_h = hppa-tdep.h
i386_linux_tdep_h = i386-linux-tdep.h
i386_tdep_h = i386-tdep.h
i387_tdep_h = i387-tdep.h
@ -1801,7 +1802,7 @@ hppa-tdep.o: hppa-tdep.c $(defs_h) $(frame_h) $(bfd_h) $(inferior_h) \
$(value_h) $(regcache_h) $(completer_h) $(language_h) $(osabi_h) \
$(gdb_assert_h) $(infttrace_h) $(symtab_h) $(infcall_h) \
$(a_out_encap_h) $(gdb_stat_h) $(gdb_wait_h) $(gdbcore_h) \
$(gdbcmd_h) $(target_h) $(symfile_h) $(objfiles_h)
$(gdbcmd_h) $(target_h) $(symfile_h) $(objfiles_h) $(hppa_tdep_h)
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) \

View File

@ -21,10 +21,6 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
struct type;
struct value;
struct frame_info;
/* PA 64-bit specific definitions. Override those which are in
tm-hppa.h */
@ -43,86 +39,13 @@ struct frame_info;
#include "pa/tm-hppah.h"
/* Say how long (ordinary) registers are. This is used in
push_word and a few other places, but REGISTER_RAW_SIZE is
the real way to know how big a register is. */
#undef DEPRECATED_REGISTER_SIZE
#define DEPRECATED_REGISTER_SIZE 8
/* Number of bytes of storage in the actual machine representation
for register N. On the PA-RISC 2.0, all regs are 8 bytes, including
the FP registers (they're accessed as two 4 byte halves). */
#undef REGISTER_RAW_SIZE
#define REGISTER_RAW_SIZE(N) 8
/* Largest value REGISTER_RAW_SIZE can have. */
#undef DEPRECATED_MAX_REGISTER_RAW_SIZE
#define DEPRECATED_MAX_REGISTER_RAW_SIZE 8
/* Total amount of space needed to store our copies of the machine's
register state, the array `registers'. */
#undef DEPRECATED_REGISTER_BYTES
#define DEPRECATED_REGISTER_BYTES (NUM_REGS * 8)
/* Index within `registers' of the first byte of the space for
register N. */
#undef REGISTER_BYTE
#define REGISTER_BYTE(N) ((N) * 8)
#undef REGISTER_VIRTUAL_TYPE
#define REGISTER_VIRTUAL_TYPE(N) \
((N) < FP4_REGNUM ? builtin_type_unsigned_long_long : builtin_type_double)
/* Number of machine registers */
#undef NUM_REGS
#define NUM_REGS 96
/* Initializer for an array of names of registers.
There should be NUM_REGS strings in this initializer.
They are in rows of eight entries */
extern const char *hppa64_register_name (int i);
#define REGISTER_NAME hppa64_register_name
#undef FP0_REGNUM
#undef FP4_REGNUM
#define FP0_REGNUM 64 /* floating point reg. 0 (fspr)*/
#define FP4_REGNUM 68
/* Redefine some target bit sizes from the default. */
/* Number of bits in a long or unsigned long for the target machine. */
#define TARGET_LONG_BIT 64
/* Number of bits in a long long or unsigned long long for the
target machine. */
#define TARGET_LONG_LONG_BIT 64
/* Number of bits in a pointer for the target machine */
#define TARGET_PTR_BIT 64
/* Argument Pointer Register */
#define AP_REGNUM 29
#define AP_REGNUM 29 /* Argument Pointer Register */
#define DP_REGNUM 27
#define FP5_REGNUM 70
#define SR5_REGNUM 48
/* We access locals from SP. This may not work for frames which call
alloca; for those, we may need to consult unwind tables.
jimb: FIXME. */
#undef DEPRECATED_FRAME_LOCALS_ADDRESS
#define DEPRECATED_FRAME_LOCALS_ADDRESS(fi) (get_frame_base (fi))
/* For a number of horrible reasons we may have to adjust the location
of variables on the stack. Ugh. jimb: why? */
@ -179,19 +102,6 @@ call_dummy
0xe820f0000fb110d3LL, 0x0001000400151820LL,\
0xe6c0000008000240LL}
#define DEPRECATED_CALL_DUMMY_BREAKPOINT_OFFSET 22 * 4
/* DEPRECATED_CALL_DUMMY_LENGTH is computed based on the size of a
word on the target machine, not the size of an instruction. Since
a word on this target holds two instructions we have to divide the
instruction size by two to get the word size of the dummy. */
#undef DEPRECATED_CALL_DUMMY_LENGTH
#define DEPRECATED_CALL_DUMMY_LENGTH (INSTRUCTION_SIZE * 26 / 2)
/* The PA64 ABI mandates a 16 byte stack alignment. */
#undef STACK_ALIGN
#define STACK_ALIGN(arg) ( ((arg)%16) ? (((arg)+15)&-16) : (arg))
/* The PA64 ABI reserves 64 bytes of stack space for outgoing register
parameters. */
#undef REG_PARM_STACK_SPACE
@ -205,115 +115,22 @@ call_dummy
#undef SR4EXPORT_LDIL_OFFSET
#undef SR4EXPORT_LDO_OFFSET
#undef REG_STRUCT_HAS_ADDR
#undef DEPRECATED_EXTRACT_RETURN_VALUE
/* RM: floats are returned in FR4R, doubles in FR4
* integral values are in r28, padded on the left
* aggregates less that 65 bits are in r28, right padded
* aggregates upto 128 bits are in r28 and r29, right padded
*/
#define DEPRECATED_EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
{ \
if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
memcpy ((VALBUF), \
((char *)(REGBUF)) + REGISTER_BYTE (FP4_REGNUM) + \
(DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
TYPE_LENGTH (TYPE)); \
else if (is_integral_type(TYPE)) \
memcpy ((VALBUF), \
(char *)(REGBUF) + REGISTER_BYTE (28) + \
(DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
TYPE_LENGTH (TYPE)); \
else if (TYPE_LENGTH (TYPE) <= 8) \
memcpy ((VALBUF), \
(char *)(REGBUF) + REGISTER_BYTE (28), \
TYPE_LENGTH (TYPE)); \
else if (TYPE_LENGTH (TYPE) <= 16) \
{ \
memcpy ((VALBUF), \
(char *)(REGBUF) + REGISTER_BYTE (28), \
8); \
memcpy (((char *) VALBUF + 8), \
(char *)(REGBUF) + REGISTER_BYTE (29), \
TYPE_LENGTH (TYPE) - 8); \
} \
}
/* RM: struct upto 128 bits are returned in registers */
#undef USE_STRUCT_CONVENTION
#define USE_STRUCT_CONVENTION(gcc_p, value_type)\
(TYPE_LENGTH (value_type) > 16)
/* RM: for return command */
#undef DEPRECATED_STORE_RETURN_VALUE
#define DEPRECATED_STORE_RETURN_VALUE(TYPE,VALBUF) \
{ \
if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
deprecated_write_register_bytes \
(REGISTER_BYTE (FP4_REGNUM) + \
(DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
(VALBUF), \
TYPE_LENGTH (TYPE)); \
else if (is_integral_type(TYPE)) \
deprecated_write_register_bytes \
(REGISTER_BYTE (28) + \
(DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
(VALBUF), \
TYPE_LENGTH (TYPE)); \
else if (TYPE_LENGTH (TYPE) <= 8) \
deprecated_write_register_bytes \
( REGISTER_BYTE (28), \
(VALBUF), \
TYPE_LENGTH (TYPE)); \
else if (TYPE_LENGTH (TYPE) <= 16) \
{ \
deprecated_write_register_bytes \
(REGISTER_BYTE (28), \
(VALBUF), \
8); \
deprecated_write_register_bytes \
(REGISTER_BYTE (29), \
((char *) VALBUF + 8), \
TYPE_LENGTH (TYPE) - 8); \
} \
}
/* RM: these are the PA64 equivalents of the macros in tm-hppah.h --
* see comments there. For PA64, the save_state structure is at an
* offset of 24 32-bit words from the sigcontext structure. The 64 bit
* general registers are at an offset of 640 bytes from the beginning of the
* save_state structure, and the floating pointer register are at an offset
* of 256 bytes from the beginning of the save_state structure.
*/
#undef FRAME_SAVED_PC_IN_SIGTRAMP
extern void hppa64_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp);
#define FRAME_SAVED_PC_IN_SIGTRAMP(FRAME, TMP) \
{ \
*(TMP) = read_memory_integer (get_frame_base (FRAME) + (24 * 4) + 640 + (33 * 8), 8); \
}
hppa64_hpux_frame_saved_pc_in_sigtramp (FRAME, TMP)
#undef FRAME_BASE_BEFORE_SIGTRAMP
extern void hppa64_hpux_frame_base_before_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp);
#define FRAME_BASE_BEFORE_SIGTRAMP(FRAME, TMP) \
{ \
*(TMP) = read_memory_integer (get_frame_base (FRAME) + (24 * 4) + 640 + (30 * 8), 8); \
}
hppa64_hpux_frame_base_before_sigtramp (FRAME, TMP)
#undef FRAME_FIND_SAVED_REGS_IN_SIGTRAMP
extern void hppa64_hpux_frame_find_saved_regs_in_sigtramp
(struct frame_info *fi, CORE_ADDR *fsr);
#define FRAME_FIND_SAVED_REGS_IN_SIGTRAMP(FRAME, FSR) \
{ \
int i; \
CORE_ADDR TMP1, TMP2; \
TMP1 = get_frame_base (FRAME) + (24 * 4) + 640; \
TMP2 = get_frame_base (FRAME) + (24 * 4) + 256; \
for (i = 0; i < NUM_REGS; i++) \
{ \
if (i == SP_REGNUM) \
(FSR)[SP_REGNUM] = read_memory_integer (TMP1 + SP_REGNUM * 8, 8); \
else if (i >= FP0_REGNUM) \
(FSR)[i] = TMP2 + (i - FP0_REGNUM) * 8; \
else \
(FSR)[i] = TMP1 + i * 8; \
} \
}
hppa64_hpux_frame_find_saved_regs_in_sigtramp (FRAME, FSR)
/* jimb: omitted purify call support */

View File

@ -38,17 +38,17 @@ struct frame_info;
extern void hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp);
#define FRAME_SAVED_PC_IN_SIGTRAMP(FRAME, TMP) \
hppa_hpux_frame_saved_pc_in_sigtramp (FRAME, TMP)
hppa32_hpux_frame_saved_pc_in_sigtramp (FRAME, TMP)
extern void hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp);
#define FRAME_BASE_BEFORE_SIGTRAMP(FRAME, TMP) \
hppa_hpux_frame_base_before_sigtramp (FRAME, TMP)
hppa32_hpux_frame_base_before_sigtramp (FRAME, TMP)
extern void hppa_hpux_frame_find_saved_regs_in_sigtramp
(struct frame_info *fi, CORE_ADDR *fsr);
#define FRAME_FIND_SAVED_REGS_IN_SIGTRAMP(FRAME, FSR) \
hppa_hpux_frame_find_saved_regs_in_sigtramp (FRAME, FSR)
hppa32_hpux_frame_find_saved_regs_in_sigtramp (FRAME, FSR)
/* For HP-UX on PA-RISC we have an implementation
for the exception handling target op (in hppa-tdep.c) */

View File

@ -32,12 +32,18 @@ extern initialize_file_ftype _initialize_hppa_hpux_tdep;
/* FIXME: brobecker 2002-12-25. The following functions will eventually
become static, after the multiarching conversion is done. */
int hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name);
void hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp);
void hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp);
void hppa_hpux_frame_find_saved_regs_in_sigtramp
(struct frame_info *fi, CORE_ADDR *fsr);
void hppa32_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp);
void hppa32_hpux_frame_base_before_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp);
void hppa32_hpux_frame_find_saved_regs_in_sigtramp (struct frame_info *fi,
CORE_ADDR *fsr);
void hppa64_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp);
void hppa64_hpux_frame_base_before_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp);
void hppa64_hpux_frame_find_saved_regs_in_sigtramp (struct frame_info *fi,
CORE_ADDR *fsr);
int
hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name)
@ -48,9 +54,9 @@ hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name)
return (name && (strcmp ("_sigreturn", name) == 0));
}
/* For hppa_hpux_frame_saved_pc_in_sigtramp,
hppa_hpux_frame_base_before_sigtramp and
hppa_hpux_frame_find_saved_regs_in_sigtramp:
/* For hppa32_hpux_frame_saved_pc_in_sigtramp,
hppa32_hpux_frame_base_before_sigtramp and
hppa32_hpux_frame_find_saved_regs_in_sigtramp:
The signal context structure pointer is always saved at the base
of the frame which "calls" the signal handler. We only want to find
@ -67,21 +73,21 @@ hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name)
written. */
void
hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi, CORE_ADDR *tmp)
hppa32_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi, CORE_ADDR *tmp)
{
*tmp = read_memory_integer (get_frame_base (fi) + (43 * 4), 4);
}
void
hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp)
hppa32_hpux_frame_base_before_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp)
{
*tmp = read_memory_integer (get_frame_base (fi) + (40 * 4), 4);
}
void
hppa_hpux_frame_find_saved_regs_in_sigtramp (struct frame_info *fi,
CORE_ADDR *fsr)
hppa32_hpux_frame_find_saved_regs_in_sigtramp (struct frame_info *fi,
CORE_ADDR *fsr)
{
int i;
const CORE_ADDR tmp = get_frame_base (fi) + (10 * 4);
@ -95,6 +101,53 @@ hppa_hpux_frame_find_saved_regs_in_sigtramp (struct frame_info *fi,
}
}
/* For hppa64_hpux_frame_saved_pc_in_sigtramp,
hppa64_hpux_frame_base_before_sigtramp and
hppa64_hpux_frame_find_saved_regs_in_sigtramp:
These functions are the PA64 ABI equivalents of the 32bits counterparts
above. See the comments there.
For PA64, the save_state structure is at an offset of 24 32-bit words
from the sigcontext structure. The 64 bit general registers are at an
offset of 640 bytes from the beginning of the save_state structure,
and the floating pointer register are at an offset of 256 bytes from
the beginning of the save_state structure. */
void
hppa64_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi, CORE_ADDR *tmp)
{
*tmp = read_memory_integer
(get_frame_base (fi) + (24 * 4) + 640 + (33 * 8), 8);
}
void
hppa64_hpux_frame_base_before_sigtramp (struct frame_info *fi,
CORE_ADDR *tmp)
{
*tmp = read_memory_integer
(get_frame_base (fi) + (24 * 4) + 640 + (30 * 8), 8);
}
void
hppa64_hpux_frame_find_saved_regs_in_sigtramp (struct frame_info *fi,
CORE_ADDR *fsr)
{
int i;
const CORE_ADDR tmp1 = get_frame_base (fi) + (24 * 4) + 640;
const CORE_ADDR tmp2 = get_frame_base (fi) + (24 * 4) + 256;
for (i = 0; i < NUM_REGS; i++)
{
if (i == SP_REGNUM)
fsr[SP_REGNUM] = read_memory_integer (tmp1 + SP_REGNUM * 8, 8);
else if (i >= FP0_REGNUM)
fsr[i] = tmp2 + (i - FP0_REGNUM) * 8;
else
fsr[i] = tmp1 + i * 8;
}
}
static void
hppa_hpux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{

View File

@ -64,9 +64,20 @@
#include "target.h"
#include "symfile.h"
#include "objfiles.h"
#include "hppa-tdep.h"
/* Some local constants. */
static const int hppa_num_regs = 128;
static const int hppa32_num_regs = 128;
static const int hppa64_num_regs = 96;
static const int hppa64_call_dummy_breakpoint_offset = 22 * 4;
/* DEPRECATED_CALL_DUMMY_LENGTH is computed based on the size of a
word on the target machine, not the size of an instruction. Since
a word on this target holds two instructions we have to divide the
instruction size by two to get the word size of the dummy. */
static const int hppa32_call_dummy_length = INSTRUCTION_SIZE * 28;
static const int hppa64_call_dummy_length = INSTRUCTION_SIZE * 26 / 2;
/* Get at various relevent fields of an instruction word. */
#define MASK_5 0x1f
@ -164,16 +175,23 @@ int hppa_in_solib_call_trampoline (CORE_ADDR pc, char *name);
int hppa_in_solib_return_trampoline (CORE_ADDR pc, char *name);
CORE_ADDR hppa_saved_pc_after_call (struct frame_info *frame);
int hppa_inner_than (CORE_ADDR lhs, CORE_ADDR rhs);
CORE_ADDR hppa_stack_align (CORE_ADDR sp);
CORE_ADDR hppa32_stack_align (CORE_ADDR sp);
CORE_ADDR hppa64_stack_align (CORE_ADDR sp);
int hppa_pc_requires_run_before_use (CORE_ADDR pc);
int hppa_instruction_nullified (void);
int hppa_register_raw_size (int reg_nr);
int hppa_register_byte (int reg_nr);
struct type * hppa_register_virtual_type (int reg_nr);
struct type * hppa32_register_virtual_type (int reg_nr);
struct type * hppa64_register_virtual_type (int reg_nr);
void hppa_store_struct_return (CORE_ADDR addr, CORE_ADDR sp);
void hppa_extract_return_value (struct type *type, char *regbuf, char *valbuf);
int hppa_use_struct_convention (int gcc_p, struct type *type);
void hppa_store_return_value (struct type *type, char *valbuf);
void hppa32_extract_return_value (struct type *type, char *regbuf,
char *valbuf);
void hppa64_extract_return_value (struct type *type, char *regbuf,
char *valbuf);
int hppa32_use_struct_convention (int gcc_p, struct type *type);
int hppa64_use_struct_convention (int gcc_p, struct type *type);
void hppa32_store_return_value (struct type *type, char *valbuf);
void hppa64_store_return_value (struct type *type, char *valbuf);
CORE_ADDR hppa_extract_struct_value_address (char *regbuf);
int hppa_cannot_store_register (int regnum);
void hppa_init_extra_frame_info (int fromleaf, struct frame_info *frame);
@ -182,7 +200,6 @@ int hppa_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe);
int hppa_frameless_function_invocation (struct frame_info *frame);
CORE_ADDR hppa_frame_saved_pc (struct frame_info *frame);
CORE_ADDR hppa_frame_args_address (struct frame_info *fi);
CORE_ADDR hppa_frame_locals_address (struct frame_info *fi);
int hppa_frame_num_args (struct frame_info *frame);
void hppa_push_dummy_frame (void);
void hppa_pop_frame (void);
@ -217,11 +234,19 @@ extern int exception_catchpoints_are_fragile;
/* Should call_function allocate stack space for a struct return? */
int
hppa_use_struct_convention (int gcc_p, struct type *type)
hppa32_use_struct_convention (int gcc_p, struct type *type)
{
return (TYPE_LENGTH (type) > 2 * DEPRECATED_REGISTER_SIZE);
}
/* Same as hppa32_use_struct_convention() for the PA64 ABI. */
int
hppa64_use_struct_convention (int gcc_p, struct type *type)
{
/* RM: struct upto 128 bits are returned in registers */
return TYPE_LENGTH (type) > 16;
}
/* Routines to extract various sized constants out of hppa
instructions. */
@ -681,7 +706,7 @@ hppa_breakpoint_from_pc (CORE_ADDR *pc, int *len)
/* Return the name of a register. */
const char *
hppa_register_name (int i)
hppa32_register_name (int i)
{
static char *names[] = {
"flags", "r1", "rp", "r3",
@ -4782,7 +4807,7 @@ hppa_skip_permanent_breakpoint (void)
Called only in the context of the "return" command. */
void
hppa_store_return_value (struct type *type, char *valbuf)
hppa32_store_return_value (struct type *type, char *valbuf)
{
/* For software floating point, the return value goes into the
integer registers. But we do not have any flag to key this on,
@ -4800,6 +4825,32 @@ hppa_store_return_value (struct type *type, char *valbuf)
valbuf, TYPE_LENGTH (type));
}
/* Same as hppa32_store_return_value(), but for the PA64 ABI. */
void
hppa64_store_return_value (struct type *type, char *valbuf)
{
if (TYPE_CODE (type) == TYPE_CODE_FLT)
deprecated_write_register_bytes
(REGISTER_BYTE (FP4_REGNUM)
+ DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (type),
valbuf, TYPE_LENGTH (type));
else if (is_integral_type(type))
deprecated_write_register_bytes
(REGISTER_BYTE (28)
+ DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (type),
valbuf, TYPE_LENGTH (type));
else if (TYPE_LENGTH (type) <= 8)
deprecated_write_register_bytes
(REGISTER_BYTE (28),valbuf, TYPE_LENGTH (type));
else if (TYPE_LENGTH (type) <= 16)
{
deprecated_write_register_bytes (REGISTER_BYTE (28),valbuf, 8);
deprecated_write_register_bytes
(REGISTER_BYTE (29), valbuf + 8, TYPE_LENGTH (type) - 8);
}
}
/* Copy the function's return value into VALBUF.
This function is called only in the context of "target function calls",
@ -4808,15 +4859,13 @@ hppa_store_return_value (struct type *type, char *valbuf)
"return" command. */
void
hppa_extract_return_value (struct type *type, char *regbuf, char *valbuf)
hppa32_extract_return_value (struct type *type, char *regbuf, char *valbuf)
{
if (TYPE_CODE (type) == TYPE_CODE_FLT)
memcpy (valbuf,
(char *)regbuf + REGISTER_BYTE (FP4_REGNUM),
TYPE_LENGTH (type));
memcpy (valbuf, regbuf + REGISTER_BYTE (FP4_REGNUM), TYPE_LENGTH (type));
else
memcpy (valbuf,
((char *)regbuf
(regbuf
+ REGISTER_BYTE (28)
+ (TYPE_LENGTH (type) > 4
? (8 - TYPE_LENGTH (type))
@ -4824,6 +4873,34 @@ hppa_extract_return_value (struct type *type, char *regbuf, char *valbuf)
TYPE_LENGTH (type));
}
/* Same as hppa32_extract_return_value but for the PA64 ABI case. */
void
hppa64_extract_return_value (struct type *type, char *regbuf, char *valbuf)
{
/* RM: Floats are returned in FR4R, doubles in FR4.
Integral values are in r28, padded on the left.
Aggregates less that 65 bits are in r28, right padded.
Aggregates upto 128 bits are in r28 and r29, right padded. */
if (TYPE_CODE (type) == TYPE_CODE_FLT)
memcpy (valbuf,
regbuf + REGISTER_BYTE (FP4_REGNUM)
+ DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (type),
TYPE_LENGTH (type));
else if (is_integral_type(type))
memcpy (valbuf,
regbuf + REGISTER_BYTE (28)
+ DEPRECATED_REGISTER_SIZE - TYPE_LENGTH (type),
TYPE_LENGTH (type));
else if (TYPE_LENGTH (type) <= 8)
memcpy (valbuf, regbuf + REGISTER_BYTE (28), TYPE_LENGTH (type));
else if (TYPE_LENGTH (type) <= 16)
{
memcpy (valbuf, regbuf + REGISTER_BYTE (28), 8);
memcpy (valbuf + 8, regbuf + REGISTER_BYTE (29), TYPE_LENGTH (type) - 8);
}
}
int
hppa_reg_struct_has_addr (int gcc_p, struct type *type)
{
@ -4840,7 +4917,7 @@ hppa_inner_than (CORE_ADDR lhs, CORE_ADDR rhs)
}
CORE_ADDR
hppa_stack_align (CORE_ADDR sp)
hppa32_stack_align (CORE_ADDR sp)
{
/* elz: adjust the quantity to the next highest value which is
64-bit aligned. This is used in valops.c, when the sp is adjusted.
@ -4848,6 +4925,13 @@ hppa_stack_align (CORE_ADDR sp)
return ((sp % 8) ? (sp + 7) & -8 : sp);
}
CORE_ADDR
hppa64_stack_align (CORE_ADDR sp)
{
/* The PA64 ABI mandates a 16 byte stack alignment. */
return ((sp % 16) ? (sp + 15) & -16 : sp);
}
int
hppa_pc_requires_run_before_use (CORE_ADDR pc)
{
@ -4901,14 +4985,16 @@ hppa_register_raw_size (int reg_nr)
int
hppa_register_byte (int reg_nr)
{
return reg_nr * 4;
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
return reg_nr * tdep->bytes_per_address;
}
/* Return the GDB type object for the "standard" data type of data
in register N. */
struct type *
hppa_register_virtual_type (int reg_nr)
hppa32_register_virtual_type (int reg_nr)
{
if (reg_nr < FP4_REGNUM)
return builtin_type_int;
@ -4916,6 +5002,18 @@ hppa_register_virtual_type (int reg_nr)
return builtin_type_float;
}
/* Return the GDB type object for the "standard" data type of data
in register N. hppa64 version. */
struct type *
hppa64_register_virtual_type (int reg_nr)
{
if (reg_nr < FP4_REGNUM)
return builtin_type_unsigned_long_long;
else
return builtin_type_double;
}
/* Store the address of the place in which to copy the structure the
subroutine will return. This is called from call_function. */
@ -4979,6 +5077,7 @@ hppa_fetch_pointer_argument (struct frame_info *frame, int argi,
static struct gdbarch *
hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
struct gdbarch_tdep *tdep;
struct gdbarch *gdbarch;
/* Try to determine the ABI of the object we are loading. */
@ -4995,9 +5094,70 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
return (arches->gdbarch);
/* If none found, then allocate and initialize one. */
gdbarch = gdbarch_alloc (&info, NULL);
tdep = XMALLOC (struct gdbarch_tdep);
gdbarch = gdbarch_alloc (&info, tdep);
set_gdbarch_reg_struct_has_addr (gdbarch, hppa_reg_struct_has_addr);
/* Determine from the bfd_arch_info structure if we are dealing with
a 32 or 64 bits architecture. If the bfd_arch_info is not available,
then default to a 32bit machine. */
if (info.bfd_arch_info != NULL)
tdep->bytes_per_address =
info.bfd_arch_info->bits_per_address / info.bfd_arch_info->bits_per_byte;
else
tdep->bytes_per_address = 4;
/* Some parts of the gdbarch vector depend on whether we are running
on a 32 bits or 64 bits target. */
switch (tdep->bytes_per_address)
{
case 4:
set_gdbarch_num_regs (gdbarch, hppa32_num_regs);
set_gdbarch_register_name (gdbarch, hppa32_register_name);
set_gdbarch_deprecated_register_virtual_type
(gdbarch, hppa32_register_virtual_type);
set_gdbarch_deprecated_call_dummy_length
(gdbarch, hppa32_call_dummy_length);
set_gdbarch_stack_align (gdbarch, hppa32_stack_align);
set_gdbarch_reg_struct_has_addr (gdbarch, hppa_reg_struct_has_addr);
set_gdbarch_deprecated_extract_return_value
(gdbarch, hppa32_extract_return_value);
set_gdbarch_use_struct_convention
(gdbarch, hppa32_use_struct_convention);
set_gdbarch_deprecated_store_return_value
(gdbarch, hppa32_store_return_value);
break;
case 8:
set_gdbarch_num_regs (gdbarch, hppa64_num_regs);
set_gdbarch_register_name (gdbarch, hppa64_register_name);
set_gdbarch_deprecated_register_virtual_type
(gdbarch, hppa64_register_virtual_type);
set_gdbarch_deprecated_call_dummy_breakpoint_offset
(gdbarch, hppa64_call_dummy_breakpoint_offset);
set_gdbarch_deprecated_call_dummy_length
(gdbarch, hppa64_call_dummy_length);
set_gdbarch_stack_align (gdbarch, hppa64_stack_align);
set_gdbarch_deprecated_extract_return_value
(gdbarch, hppa64_extract_return_value);
set_gdbarch_use_struct_convention
(gdbarch, hppa64_use_struct_convention);
set_gdbarch_deprecated_store_return_value
(gdbarch, hppa64_store_return_value);
break;
default:
internal_error (__FILE__, __LINE__, "Unsupported address size: %d",
tdep->bytes_per_address);
}
/* The following gdbarch vector elements depend on other parts of this
vector which have been set above, depending on the ABI. */
set_gdbarch_deprecated_register_bytes
(gdbarch, gdbarch_num_regs (gdbarch) * tdep->bytes_per_address);
set_gdbarch_long_bit (gdbarch, tdep->bytes_per_address * TARGET_CHAR_BIT);
set_gdbarch_long_long_bit (gdbarch, 64);
set_gdbarch_ptr_bit (gdbarch, tdep->bytes_per_address * TARGET_CHAR_BIT);
/* The following gdbarch vector elements do not depend on the address
size, or in any other gdbarch element previously set. */
set_gdbarch_function_start_offset (gdbarch, 0);
set_gdbarch_skip_prologue (gdbarch, hppa_skip_prologue);
set_gdbarch_skip_trampoline_code (gdbarch, hppa_skip_trampoline_code);
@ -5006,28 +5166,19 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
hppa_in_solib_return_trampoline);
set_gdbarch_deprecated_saved_pc_after_call (gdbarch, hppa_saved_pc_after_call);
set_gdbarch_inner_than (gdbarch, hppa_inner_than);
set_gdbarch_stack_align (gdbarch, hppa_stack_align);
set_gdbarch_decr_pc_after_break (gdbarch, 0);
set_gdbarch_deprecated_register_size (gdbarch, 4);
set_gdbarch_num_regs (gdbarch, hppa_num_regs);
set_gdbarch_deprecated_register_size (gdbarch, tdep->bytes_per_address);
set_gdbarch_deprecated_fp_regnum (gdbarch, 3);
set_gdbarch_sp_regnum (gdbarch, 30);
set_gdbarch_fp0_regnum (gdbarch, 64);
set_gdbarch_pc_regnum (gdbarch, PCOQ_HEAD_REGNUM);
set_gdbarch_npc_regnum (gdbarch, PCOQ_TAIL_REGNUM);
set_gdbarch_deprecated_register_raw_size (gdbarch, hppa_register_raw_size);
set_gdbarch_deprecated_register_bytes (gdbarch, hppa_num_regs * 4);
set_gdbarch_deprecated_register_byte (gdbarch, hppa_register_byte);
set_gdbarch_deprecated_register_virtual_size (gdbarch, hppa_register_raw_size);
set_gdbarch_deprecated_max_register_raw_size (gdbarch, 4);
set_gdbarch_deprecated_max_register_raw_size (gdbarch, tdep->bytes_per_address);
set_gdbarch_deprecated_max_register_virtual_size (gdbarch, 8);
set_gdbarch_deprecated_register_virtual_type (gdbarch, hppa_register_virtual_type);
set_gdbarch_register_name (gdbarch, hppa_register_name);
set_gdbarch_deprecated_store_struct_return (gdbarch, hppa_store_struct_return);
set_gdbarch_deprecated_extract_return_value (gdbarch,
hppa_extract_return_value);
set_gdbarch_use_struct_convention (gdbarch, hppa_use_struct_convention);
set_gdbarch_deprecated_store_return_value (gdbarch, hppa_store_return_value);
set_gdbarch_deprecated_extract_struct_value_address
(gdbarch, hppa_extract_struct_value_address);
set_gdbarch_cannot_store_register (gdbarch, hppa_cannot_store_register);
@ -5040,7 +5191,6 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_frame_args_skip (gdbarch, 0);
set_gdbarch_deprecated_push_dummy_frame (gdbarch, hppa_push_dummy_frame);
set_gdbarch_deprecated_pop_frame (gdbarch, hppa_pop_frame);
set_gdbarch_deprecated_call_dummy_length (gdbarch, INSTRUCTION_SIZE * 28);
/* set_gdbarch_deprecated_fix_call_dummy (gdbarch, hppa_fix_call_dummy); */
set_gdbarch_deprecated_push_arguments (gdbarch, hppa_push_arguments);
set_gdbarch_addr_bits_remove (gdbarch, hppa_smash_text_address);

32
gdb/hppa-tdep.h Normal file
View File

@ -0,0 +1,32 @@
/* Common target dependent code for GDB on HPPA systems.
Copyright 2003 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef HPPA_TDEP_H
#define HPPA_TDEP_H
/* Target-dependent structure in gdbarch. */
struct gdbarch_tdep
{
/* The number of bytes in an address. For now, this field is designed
to allow us to differentiate hppa32 from hppa64 targets. */
int bytes_per_address;
};
#endif /* HPPA_TDEP_H */