/* Target-dependent code for the HP PA-RISC architecture.
Copyright (C) 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
- 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
+ 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
Free Software Foundation, Inc.
Contributed by the Center for Software Science at the
#define UNWIND_ENTRY_SIZE 16
#define STUB_UNWIND_ENTRY_SIZE 8
-/* FIXME: brobecker 2002-11-07: We will likely be able to make the
- following functions static, once we hppa is partially multiarched. */
-int hppa_pc_requires_run_before_use (CORE_ADDR pc);
-
/* Routines to extract various sized constants out of hppa
instructions. */
char buf[4];
int off;
- status = read_memory_nobpt (pc, buf, 4);
+ status = target_read_memory (pc, buf, 4);
if (status != 0)
return 0;
}
static const unsigned char *
-hppa_breakpoint_from_pc (CORE_ADDR *pc, int *len)
+hppa_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
{
static const unsigned char breakpoint[] = {0x00, 0x01, 0x00, 0x04};
(*len) = sizeof (breakpoint);
/* Return the name of a register. */
static const char *
-hppa32_register_name (int i)
+hppa32_register_name (struct gdbarch *gdbarch, int i)
{
static char *names[] = {
"flags", "r1", "rp", "r3",
}
static const char *
-hppa64_register_name (int i)
+hppa64_register_name (struct gdbarch *gdbarch, int i)
{
static char *names[] = {
"flags", "r1", "rp", "r3",
}
static int
-hppa64_dwarf_reg_to_regnum (int reg)
+hppa64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
{
/* r0-r31 and sar map one-to-one. */
if (reg <= 32)
if (struct_return)
regcache_cooked_write_unsigned (regcache, 28, struct_addr);
- gp = tdep->find_global_pointer (function);
+ gp = tdep->find_global_pointer (gdbarch, function);
if (gp != 0)
regcache_cooked_write_unsigned (regcache, 19, gp);
regcache_cooked_write_unsigned (regcache, HPPA_RET0_REGNUM, struct_addr);
/* Set up GR27 (%dp) to hold the global pointer (gp). */
- gp = tdep->find_global_pointer (function);
+ gp = tdep->find_global_pointer (gdbarch, function);
if (gp != 0)
regcache_cooked_write_unsigned (regcache, HPPA_DP_REGNUM, gp);
/* Handle 32/64-bit struct return conventions. */
static enum return_value_convention
-hppa32_return_value (struct gdbarch *gdbarch,
+hppa32_return_value (struct gdbarch *gdbarch, struct type *func_type,
struct type *type, struct regcache *regcache,
gdb_byte *readbuf, const gdb_byte *writebuf)
{
}
static enum return_value_convention
-hppa64_return_value (struct gdbarch *gdbarch,
+hppa64_return_value (struct gdbarch *gdbarch, struct type *func_type,
struct type *type, struct regcache *regcache,
gdb_byte *readbuf, const gdb_byte *writebuf)
{
static CORE_ADDR
-skip_prologue_hard_way (CORE_ADDR pc, int stop_before_branch)
+skip_prologue_hard_way (struct gdbarch *gdbarch, CORE_ADDR pc,
+ int stop_before_branch)
{
char buf[4];
CORE_ADDR orig_pc = pc;
old_save_sp = save_sp;
old_stack_remaining = stack_remaining;
- status = read_memory_nobpt (pc, buf, 4);
+ status = target_read_memory (pc, buf, 4);
inst = extract_unsigned_integer (buf, 4);
/* Yow! */
FIXME. Can still die if we have a mix of GR and FR argument
stores! */
- if (reg_num >= (gdbarch_ptr_bit (current_gdbarch) == 64 ? 19 : 23)
+ if (reg_num >= (gdbarch_ptr_bit (gdbarch) == 64 ? 19 : 23)
&& reg_num <= 26)
{
- while (reg_num >= (gdbarch_ptr_bit (current_gdbarch) == 64 ? 19 : 23)
+ while (reg_num >= (gdbarch_ptr_bit (gdbarch) == 64 ? 19 : 23)
&& reg_num <= 26)
{
pc += 4;
- status = read_memory_nobpt (pc, buf, 4);
+ status = target_read_memory (pc, buf, 4);
inst = extract_unsigned_integer (buf, 4);
if (status != 0)
return pc;
reg_num = inst_saves_fr (inst);
save_fr &= ~(1 << reg_num);
- status = read_memory_nobpt (pc + 4, buf, 4);
+ status = target_read_memory (pc + 4, buf, 4);
next_inst = extract_unsigned_integer (buf, 4);
/* Yow! */
if ((inst & 0xfc000000) == 0x34000000
&& inst_saves_fr (next_inst) >= 4
&& inst_saves_fr (next_inst)
- <= (gdbarch_ptr_bit (current_gdbarch) == 64 ? 11 : 7))
+ <= (gdbarch_ptr_bit (gdbarch) == 64 ? 11 : 7))
{
/* So we drop into the code below in a reasonable state. */
reg_num = inst_saves_fr (next_inst);
never does prologue scheduling. So once we see one, skip past
all of them. */
if (reg_num >= 4
- && reg_num <= (gdbarch_ptr_bit (current_gdbarch) == 64 ? 11 : 7))
+ && reg_num <= (gdbarch_ptr_bit (gdbarch) == 64 ? 11 : 7))
{
while (reg_num >= 4
&& reg_num
- <= (gdbarch_ptr_bit (current_gdbarch) == 64 ? 11 : 7))
+ <= (gdbarch_ptr_bit (gdbarch) == 64 ? 11 : 7))
{
pc += 8;
- status = read_memory_nobpt (pc, buf, 4);
+ status = target_read_memory (pc, buf, 4);
inst = extract_unsigned_integer (buf, 4);
if (status != 0)
return pc;
if ((inst & 0xfc000000) != 0x34000000)
break;
- status = read_memory_nobpt (pc + 4, buf, 4);
+ status = target_read_memory (pc + 4, buf, 4);
next_inst = extract_unsigned_integer (buf, 4);
if (status != 0)
return pc;
skip over the branch in that case. */
static CORE_ADDR
-hppa_skip_prologue (CORE_ADDR pc)
+hppa_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
unsigned long inst;
int offset;
if (post_prologue_pc != 0)
return max (pc, post_prologue_pc);
else
- return (skip_prologue_hard_way (pc, 1));
+ return (skip_prologue_hard_way (gdbarch, pc, 1));
}
/* Return an unwind entry that falls within the frame's code block. */
static struct hppa_frame_cache *
hppa_frame_cache (struct frame_info *next_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (next_frame);
struct hppa_frame_cache *cache;
long saved_gr_mask;
long saved_fr_mask;
else
start_pc = frame_func_unwind (next_frame, NORMAL_FRAME);
- prologue_end = skip_prologue_hard_way (start_pc, 0);
+ prologue_end = skip_prologue_hard_way (gdbarch, start_pc, 0);
end_pc = frame_pc_unwind (next_frame);
if (prologue_end != 0 && end_pc > prologue_end)
saved. The entry SP value is saved at this frame's SP
address. */
cache->base = read_memory_integer
- (this_sp, gdbarch_ptr_bit (current_gdbarch) / 8);
+ (this_sp, gdbarch_ptr_bit (gdbarch) / 8);
if (hppa_debug)
fprintf_unfiltered (gdb_stdlog, " (base=0x%s) [saved]",
{
/* Convert all the offsets into addresses. */
int reg;
- for (reg = 0; reg < gdbarch_num_regs (current_gdbarch); reg++)
+ for (reg = 0; reg < gdbarch_num_regs (gdbarch); reg++)
{
if (trad_frame_addr_p (cache->saved_regs, reg))
cache->saved_regs[reg].addr += cache->base;
}
{
- struct gdbarch *gdbarch;
struct gdbarch_tdep *tdep;
- gdbarch = get_frame_arch (next_frame);
tdep = gdbarch_tdep (gdbarch);
if (tdep->unwind_adjust_stub)
if (pc == 0
|| (tdep->in_solib_call_trampoline != NULL
&& tdep->in_solib_call_trampoline (pc, NULL))
- || gdbarch_in_solib_return_trampoline (current_gdbarch, pc, NULL))
+ || gdbarch_in_solib_return_trampoline (gdbarch, pc, NULL))
return &hppa_stub_frame_unwind;
return NULL;
}
}
}
-int
-hppa_pc_requires_run_before_use (CORE_ADDR pc)
-{
- /* Sometimes we may pluck out a minimal symbol that has a negative address.
-
- An example of this occurs when an a.out is linked against a foo.sl.
- The foo.sl defines a global bar(), and the a.out declares a signature
- for bar(). However, the a.out doesn't directly call bar(), but passes
- its address in another call.
-
- If you have this scenario and attempt to "break bar" before running,
- gdb will find a minimal symbol for bar() in the a.out. But that
- symbol's address will be negative. What this appears to denote is
- an index backwards from the base of the procedure linkage table (PLT)
- into the data linkage table (DLT), the end of which is contiguous
- with the start of the PLT. This is clearly not a valid address for
- us to set a breakpoint on.
-
- Note that one must be careful in how one checks for a negative address.
- 0xc0000000 is a legitimate address of something in a shared text
- segment, for example. Since I don't know what the possible range
- is of these "really, truly negative" addresses that come from the
- minimal symbols, I'm resorting to the gross hack of checking the
- top byte of the address for all 1's. Sigh. */
-
- return (!target_has_stack && (pc & 0xFF000000) == 0xFF000000);
-}
-
/* Return the GDB type object for the "standard" data type of data in
register REGNUM. */
through ptrace/ttrace. */
static int
-hppa32_cannot_store_register (int regnum)
+hppa32_cannot_store_register (struct gdbarch *gdbarch, int regnum)
{
return (regnum == 0
|| regnum == HPPA_PCSQ_HEAD_REGNUM
}
static int
-hppa32_cannot_fetch_register (int regnum)
+hppa32_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
{
/* cr26 and cr27 are readable (but not writable) from userspace. */
if (regnum == HPPA_CR26_REGNUM || regnum == HPPA_CR27_REGNUM)
return 0;
else
- return hppa32_cannot_store_register (regnum);
+ return hppa32_cannot_store_register (gdbarch, regnum);
}
static int
-hppa64_cannot_store_register (int regnum)
+hppa64_cannot_store_register (struct gdbarch *gdbarch, int regnum)
{
return (regnum == 0
|| regnum == HPPA_PCSQ_HEAD_REGNUM
}
static int
-hppa64_cannot_fetch_register (int regnum)
+hppa64_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
{
/* cr26 and cr27 are readable (but not writable) from userspace. */
if (regnum == HPPA_CR26_REGNUM || regnum == HPPA_CR27_REGNUM)
return 0;
else
- return hppa64_cannot_store_register (regnum);
+ return hppa64_cannot_store_register (gdbarch, regnum);
}
static CORE_ADDR
}
static CORE_ADDR
-hppa_find_global_pointer (struct value *function)
+hppa_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
{
return 0;
}
{
gdb_byte buf[HPPA_INSN_SIZE];
- read_memory_nobpt (npc, buf, HPPA_INSN_SIZE);
+ target_read_memory (npc, buf, HPPA_INSN_SIZE);
insn[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE);
if ((insn[i] & pattern[i].mask) == pattern[i].data)
npc += 4;
}
static void
-hppa_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
+hppa_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
fprintf_unfiltered (file, "bytes_per_address = %d\n",
tdep->bytes_per_address);