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 "inferior.h"
#include "rs6000-tdep.h"
#include "exec.h"
#include "gdb_stdint.h"
+#include "observer.h"
#include <sys/ptrace.h>
#include <sys/reg.h>
*isfloat = 1;
return regno - tdep->ppc_fp0_regnum + FPR0;
}
- else if (regno == PC_REGNUM)
+ else if (regno == gdbarch_pc_regnum (current_gdbarch))
return IAR;
else if (regno == tdep->ppc_ps_regnum)
return MSR;
/* Fetch register REGNO from the inferior. */
static void
-fetch_register (int regno)
+fetch_register (struct regcache *regcache, int regno)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
int addr[MAX_REGISTER_SIZE];
int nr, isfloat;
/* Bogus register number. */
else if (nr < 0)
{
- if (regno >= NUM_REGS)
+ if (regno >= gdbarch_num_regs (gdbarch))
fprintf_unfiltered (gdb_stderr,
"gdb error: register no %d not implemented.\n",
regno);
even if the register is really only 32 bits. */
long long buf;
rs6000_ptrace64 (PT_READ_GPR, PIDGET (inferior_ptid), nr, 0, &buf);
- if (register_size (current_gdbarch, regno) == 8)
+ if (register_size (gdbarch, regno) == 8)
memcpy (addr, &buf, 8);
else
*addr = buf;
}
if (!errno)
- regcache_raw_supply (current_regcache, regno, (char *) addr);
+ regcache_raw_supply (regcache, regno, (char *) addr);
else
{
#if 0
/* Store register REGNO back into the inferior. */
static void
-store_register (int regno)
+store_register (const struct regcache *regcache, int regno)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
int addr[MAX_REGISTER_SIZE];
int nr, isfloat;
/* Fetch the register's value from the register cache. */
- regcache_raw_collect (current_regcache, regno, addr);
+ regcache_raw_collect (regcache, regno, addr);
/* -1 can be a successful return value, so infer errors from errno. */
errno = 0;
/* Bogus register number. */
else if (nr < 0)
{
- if (regno >= NUM_REGS)
+ if (regno >= gdbarch_num_regs (gdbarch))
fprintf_unfiltered (gdb_stderr,
"gdb error: register no %d not implemented.\n",
regno);
/* Fixed-point registers. */
else
{
- if (regno == SP_REGNUM)
+ if (regno == gdbarch_sp_regnum (gdbarch))
/* Execute one dummy instruction (which is a breakpoint) in inferior
process to give kernel a chance to do internal housekeeping.
Otherwise the following ptrace(2) calls will mess up user stack
/* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte
area, even if the register is really only 32 bits. */
long long buf;
- if (register_size (current_gdbarch, regno) == 8)
+ if (register_size (gdbarch, regno) == 8)
memcpy (&buf, addr, 8);
else
buf = *addr;
REGNO otherwise. */
static void
-rs6000_fetch_inferior_registers (int regno)
+rs6000_fetch_inferior_registers (struct regcache *regcache, int regno)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regno != -1)
- fetch_register (regno);
+ fetch_register (regcache, regno);
else
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* Read 32 general purpose registers. */
for (regno = tdep->ppc_gp0_regnum;
regno < tdep->ppc_gp0_regnum + ppc_num_gprs;
regno++)
{
- fetch_register (regno);
+ fetch_register (regcache, regno);
}
/* Read general purpose floating point registers. */
if (tdep->ppc_fp0_regnum >= 0)
for (regno = 0; regno < ppc_num_fprs; regno++)
- fetch_register (tdep->ppc_fp0_regnum + regno);
+ fetch_register (regcache, tdep->ppc_fp0_regnum + regno);
/* Read special registers. */
- fetch_register (PC_REGNUM);
- fetch_register (tdep->ppc_ps_regnum);
- fetch_register (tdep->ppc_cr_regnum);
- fetch_register (tdep->ppc_lr_regnum);
- fetch_register (tdep->ppc_ctr_regnum);
- fetch_register (tdep->ppc_xer_regnum);
+ fetch_register (regcache, gdbarch_pc_regnum (gdbarch));
+ fetch_register (regcache, tdep->ppc_ps_regnum);
+ fetch_register (regcache, tdep->ppc_cr_regnum);
+ fetch_register (regcache, tdep->ppc_lr_regnum);
+ fetch_register (regcache, tdep->ppc_ctr_regnum);
+ fetch_register (regcache, tdep->ppc_xer_regnum);
if (tdep->ppc_fpscr_regnum >= 0)
- fetch_register (tdep->ppc_fpscr_regnum);
+ fetch_register (regcache, tdep->ppc_fpscr_regnum);
if (tdep->ppc_mq_regnum >= 0)
- fetch_register (tdep->ppc_mq_regnum);
+ fetch_register (regcache, tdep->ppc_mq_regnum);
}
}
Otherwise, REGNO specifies which register (so we can save time). */
static void
-rs6000_store_inferior_registers (int regno)
+rs6000_store_inferior_registers (struct regcache *regcache, int regno)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regno != -1)
- store_register (regno);
+ store_register (regcache, regno);
else
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* Write general purpose registers first. */
for (regno = tdep->ppc_gp0_regnum;
regno < tdep->ppc_gp0_regnum + ppc_num_gprs;
regno++)
{
- store_register (regno);
+ store_register (regcache, regno);
}
/* Write floating point registers. */
if (tdep->ppc_fp0_regnum >= 0)
for (regno = 0; regno < ppc_num_fprs; regno++)
- store_register (tdep->ppc_fp0_regnum + regno);
+ store_register (regcache, tdep->ppc_fp0_regnum + regno);
/* Write special registers. */
- store_register (PC_REGNUM);
- store_register (tdep->ppc_ps_regnum);
- store_register (tdep->ppc_cr_regnum);
- store_register (tdep->ppc_lr_regnum);
- store_register (tdep->ppc_ctr_regnum);
- store_register (tdep->ppc_xer_regnum);
+ store_register (regcache, gdbarch_pc_regnum (gdbarch));
+ store_register (regcache, tdep->ppc_ps_regnum);
+ store_register (regcache, tdep->ppc_cr_regnum);
+ store_register (regcache, tdep->ppc_lr_regnum);
+ store_register (regcache, tdep->ppc_ctr_regnum);
+ store_register (regcache, tdep->ppc_xer_regnum);
if (tdep->ppc_fpscr_regnum >= 0)
- store_register (tdep->ppc_fpscr_regnum);
+ store_register (regcache, tdep->ppc_fpscr_regnum);
if (tdep->ppc_mq_regnum >= 0)
- store_register (tdep->ppc_mq_regnum);
+ store_register (regcache, tdep->ppc_mq_regnum);
}
}
/* Announce new object files. Doing this after symbol relocation
makes aix-thread.c's job easier. */
- if (deprecated_target_new_objfile_hook && vp->objfile)
- deprecated_target_new_objfile_hook (vp->objfile);
+ if (vp->objfile)
+ observer_notify_new_objfile (vp->objfile);
/* There may be more, so we don't break out of the loop. */
}
\f
/* xcoff_relocate_symtab - hook for symbol table relocation.
- also reads shared libraries. */
+
+ This is only applicable to live processes, and is a no-op when
+ debugging a core file. */
void
xcoff_relocate_symtab (unsigned int pid)
int ldisize = arch64 ? sizeof (ldi->l64) : sizeof (ldi->l32);
int size;
+ if (ptid_equal (inferior_ptid, null_ptid))
+ return;
+
do
{
size = load_segs * ldisize;
vmap_symtab (vp);
- if (deprecated_target_new_objfile_hook && vp != vmap && vp->objfile)
- deprecated_target_new_objfile_hook (vp->objfile);
+ if (vp != vmap && vp->objfile)
+ observer_notify_new_objfile (vp->objfile);
}
while (LDI_NEXT (ldi, arch64) != 0);
vmap_exec ();