/* Target-dependent code for HP-UX on PA-RISC.
- Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008
+ 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
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
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., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "arch-utils.h"
used in dynamic executables. */
static CORE_ADDR
-hppa_hpux_skip_trampoline_code (CORE_ADDR pc)
+hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
long orig_pc = pc;
long prev_inst, curr_inst, loc;
struct minimal_symbol *msym;
of the function. So we may have to do something special. */
if (pc == hppa_symbol_address("$$dyncall"))
{
- pc = (CORE_ADDR) read_register (22);
+ pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
/* If bit 30 (counting from the left) is on, then pc is the address of
the PLT entry for this function, not the address of the function
itself. Bit 31 has meaning too, but only for MPE. */
if (pc & 0x2)
- pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8);
+ pc = (CORE_ADDR) read_memory_integer
+ (pc & ~0x3, gdbarch_ptr_bit (gdbarch) / 8);
}
if (pc == hppa_symbol_address("$$dyncall_external"))
{
- pc = (CORE_ADDR) read_register (22);
- pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8);
+ pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
+ pc = (CORE_ADDR) read_memory_integer
+ (pc & ~0x3, gdbarch_ptr_bit (gdbarch) / 8);
}
else if (pc == hppa_symbol_address("_sr4export"))
- pc = (CORE_ADDR) (read_register (22));
+ pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
/* Get the unwind descriptor corresponding to PC, return zero
if no unwind was found. */
ALL_MSYMBOLS (objfile, msymbol)
{
if (MSYMBOL_TYPE (msymbol) == mst_text
- && DEPRECATED_STREQ (DEPRECATED_SYMBOL_NAME (msymbol), DEPRECATED_SYMBOL_NAME (msym)))
+ && strcmp (DEPRECATED_SYMBOL_NAME (msymbol),
+ DEPRECATED_SYMBOL_NAME (msym)) == 0)
{
function_found = 1;
break;
/* Yup. See if the previous instruction loaded
rp from sp - 8. */
if (prev_inst == 0x4bc23ff1)
- return (read_memory_integer
- (read_register (HPPA_SP_REGNUM) - 8, 4)) & ~0x3;
+ {
+ CORE_ADDR sp;
+ sp = get_frame_register_unsigned (frame, HPPA_SP_REGNUM);
+ return read_memory_integer (sp - 8, 4) & ~0x3;
+ }
else
{
warning (_("Unable to find restore of %%rp before bv (%%rp)."));
else if ((curr_inst & 0xffe0f000) == 0xe840d000)
{
return (read_memory_integer
- (read_register (HPPA_SP_REGNUM) - 24, TARGET_PTR_BIT / 8)) & ~0x3;
+ (get_frame_register_unsigned (frame, HPPA_SP_REGNUM) - 24,
+ gdbarch_ptr_bit (gdbarch) / 8)) & ~0x3;
}
/* What about be,n 0(sr0,%rp)? It's just another way we return to
I guess we could check for the previous instruction being
mtsp %r1,%sr0 if we want to do sanity checking. */
return (read_memory_integer
- (read_register (HPPA_SP_REGNUM) - 24, TARGET_PTR_BIT / 8)) & ~0x3;
+ (get_frame_register_unsigned (frame, HPPA_SP_REGNUM) - 24,
+ gdbarch_ptr_bit (gdbarch) / 8)) & ~0x3;
}
/* Haven't found the branch yet, but we're still in the stub.
}
static CORE_ADDR
-hppa32_hpux_find_global_pointer (struct value *function)
+hppa32_hpux_find_global_pointer (struct gdbarch *gdbarch,
+ struct value *function)
{
CORE_ADDR faddr;
return extract_unsigned_integer (buf, sizeof (buf));
}
- return gdbarch_tdep (current_gdbarch)->solib_get_got_by_pc (faddr);
+ return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
}
static CORE_ADDR
-hppa64_hpux_find_global_pointer (struct value *function)
+hppa64_hpux_find_global_pointer (struct gdbarch *gdbarch,
+ struct value *function)
{
CORE_ADDR faddr;
char buf[32];
}
else
{
- return gdbarch_tdep (current_gdbarch)->solib_get_got_by_pc (faddr);
+ return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
}
}
}
static int
-hppa_hpux_sr_for_addr (CORE_ADDR addr)
+hppa_hpux_sr_for_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
{
int sr;
/* The space register to use is encoded in the top 2 bits of the address. */
- sr = addr >> (gdbarch_tdep (current_gdbarch)->bytes_per_address * 8 - 2);
+ sr = addr >> (gdbarch_tdep (gdbarch)->bytes_per_address * 8 - 2);
return sr + 4;
}
static CORE_ADDR
hppa_hpux_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
- CORE_ADDR funcaddr, int using_gcc,
+ CORE_ADDR funcaddr,
struct value **args, int nargs,
struct type *value_type,
- CORE_ADDR *real_pc, CORE_ADDR *bp_addr)
+ CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
+ struct regcache *regcache)
{
CORE_ADDR pc, stubaddr;
int argreg = 0;
/* The simple case is where we call a function in the same space that we are
currently in; in that case we don't really need to do anything. */
- if (hppa_hpux_sr_for_addr (pc) == hppa_hpux_sr_for_addr (funcaddr))
+ if (hppa_hpux_sr_for_addr (gdbarch, pc)
+ == hppa_hpux_sr_for_addr (gdbarch, funcaddr))
{
/* Intraspace call. */
*bp_addr = hppa_hpux_find_dummy_bpaddr (pc);
*real_pc = funcaddr;
- regcache_cooked_write_unsigned (current_regcache, HPPA_RP_REGNUM, *bp_addr);
+ regcache_cooked_write_unsigned (regcache, HPPA_RP_REGNUM, *bp_addr);
return sp;
}
if (stubaddr == 0)
error (_("Cannot call external function not referenced by application "
"(no import stub).\n"));
- regcache_cooked_write_unsigned (current_regcache, 22, stubaddr);
+ regcache_cooked_write_unsigned (regcache, 22, stubaddr);
write_memory (sp, (char *)&hppa32_tramp, sizeof (hppa32_tramp));
*bp_addr = hppa_hpux_find_dummy_bpaddr (pc);
- regcache_cooked_write_unsigned (current_regcache, 31, *bp_addr);
+ regcache_cooked_write_unsigned (regcache, 31, *bp_addr);
*real_pc = hppa32_hpux_search_dummy_call_sequence (gdbarch, pc, &argreg);
if (*real_pc == 0)
error (_("Cannot make interspace call from here."));
- regcache_cooked_write_unsigned (current_regcache, argreg, sp);
+ regcache_cooked_write_unsigned (regcache, argreg, sp);
sp += sizeof (hppa32_tramp);
}
/* for hppa64, we don't need to call through a stub; all functions
return via a bve. */
- regcache_cooked_write_unsigned (current_regcache, 22, funcaddr);
+ regcache_cooked_write_unsigned (regcache, 22, funcaddr);
write_memory (sp, (char *)&hppa64_tramp, sizeof (hppa64_tramp));
*bp_addr = pc - 4;
- regcache_cooked_write_unsigned (current_regcache, 31, *bp_addr);
+ regcache_cooked_write_unsigned (regcache, 31, *bp_addr);
*real_pc = hppa64_hpux_search_dummy_call_sequence (gdbarch, pc, &argreg);
if (*real_pc == 0)
error (_("Cannot make interspace call from here."));
- regcache_cooked_write_unsigned (current_regcache, argreg, sp);
+ regcache_cooked_write_unsigned (regcache, argreg, sp);
sp += sizeof (hppa64_tramp);
}
#define HPPA_HPUX_SS_INSYSCALL 0x02
static CORE_ADDR
-hppa_hpux_read_pc (ptid_t ptid)
+hppa_hpux_read_pc (struct regcache *regcache)
{
ULONGEST flags;
/* If we're currently in a system call return the contents of %r31. */
- flags = read_register_pid (HPPA_FLAGS_REGNUM, ptid);
+ regcache_cooked_read_unsigned (regcache, HPPA_FLAGS_REGNUM, &flags);
if (flags & HPPA_HPUX_SS_INSYSCALL)
- return read_register_pid (HPPA_R31_REGNUM, ptid) & ~0x3;
+ {
+ ULONGEST pc;
+ regcache_cooked_read_unsigned (regcache, HPPA_R31_REGNUM, &pc);
+ return pc & ~0x3;
+ }
- return hppa_read_pc (ptid);
+ return hppa_read_pc (regcache);
}
static void
-hppa_hpux_write_pc (CORE_ADDR pc, ptid_t ptid)
+hppa_hpux_write_pc (struct regcache *regcache, CORE_ADDR pc)
{
ULONGEST flags;
/* If we're currently in a system call also write PC into %r31. */
- flags = read_register_pid (HPPA_FLAGS_REGNUM, ptid);
+ regcache_cooked_read_unsigned (regcache, HPPA_FLAGS_REGNUM, &flags);
if (flags & HPPA_HPUX_SS_INSYSCALL)
- write_register_pid (HPPA_R31_REGNUM, pc | 0x3, ptid);
+ regcache_cooked_write_unsigned (regcache, HPPA_R31_REGNUM, pc | 0x3);
- return hppa_write_pc (pc, ptid);
+ return hppa_write_pc (regcache, pc);
}
static CORE_ADDR
hppa_hpux_unwind_adjust_stub (struct frame_info *next_frame, CORE_ADDR base,
struct trad_frame_saved_reg *saved_regs)
{
+ struct gdbarch *gdbarch = get_frame_arch (next_frame);
int optimized, realreg;
enum lval_type lval;
CORE_ADDR addr;
u = find_unwind_entry (val);
if (u && u->stub_unwind.stub_type == EXPORT)
{
- stubpc = read_memory_integer (base - 24, TARGET_PTR_BIT / 8);
+ stubpc = read_memory_integer
+ (base - 24, gdbarch_ptr_bit (gdbarch) / 8);
trad_frame_set_value (saved_regs, HPPA_PCOQ_HEAD_REGNUM, stubpc);
}
else if (hppa_symbol_address ("__gcc_plt_call")
== get_pc_function_start (val))
{
- stubpc = read_memory_integer (base - 8, TARGET_PTR_BIT / 8);
+ stubpc = read_memory_integer
+ (base - 8, gdbarch_ptr_bit (gdbarch) / 8);
trad_frame_set_value (saved_regs, HPPA_PCOQ_HEAD_REGNUM, stubpc);
}
}
tdep->find_global_pointer = hppa32_hpux_find_global_pointer;
hppa_hpux_init_abi (info, gdbarch);
- som_solib_select (tdep);
+ som_solib_select (gdbarch);
}
static void
tdep->find_global_pointer = hppa64_hpux_find_global_pointer;
hppa_hpux_init_abi (info, gdbarch);
- pa64_solib_select (tdep);
+ pa64_solib_select (gdbarch);
}
static enum gdb_osabi