displaced_step_clear ();
- original = read_pc_pid (ptid);
+ original = regcache_read_pc (regcache);
copy = gdbarch_displaced_step_location (gdbarch);
len = gdbarch_max_insn_length (gdbarch);
make_cleanup (cleanup_displaced_step_closure, closure);
/* Resume execution at the copy. */
- write_pc_pid (copy, ptid);
+ regcache_write_pc (regcache, copy);
discard_cleanups (old_cleanups);
{
/* Since the instruction didn't complete, all we can do is
relocate the PC. */
- CORE_ADDR pc = read_pc_pid (event_ptid);
+ struct regcache *regcache = get_thread_regcache (event_ptid);
+ CORE_ADDR pc = regcache_read_pc (regcache);
pc = displaced_step_original + (pc - displaced_step_copy);
- write_pc_pid (pc, event_ptid);
+ regcache_write_pc (regcache, pc);
}
do_cleanups (old_cleanups);
{
int should_resume = 1;
struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0);
- CORE_ADDR pc = read_pc ();
+ struct regcache *regcache = get_current_regcache ();
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ CORE_ADDR pc = regcache_read_pc (regcache);
QUIT;
if (debug_infrun)
breakpoints can't be removed. So we have to test for it here. */
if (breakpoint_here_p (pc) == permanent_breakpoint_here)
{
- if (gdbarch_skip_permanent_breakpoint_p (current_gdbarch))
- gdbarch_skip_permanent_breakpoint (current_gdbarch,
- get_current_regcache ());
+ if (gdbarch_skip_permanent_breakpoint_p (gdbarch))
+ gdbarch_skip_permanent_breakpoint (gdbarch, regcache);
else
error (_("\
The program is stopped at a permanent breakpoint, but GDB does not know\n\
the comments for displaced_step_prepare explain why. The
comments in the handle_inferior event for dealing with 'random
signals' explain what we do instead. */
- if (use_displaced_stepping (current_gdbarch)
+ if (use_displaced_stepping (gdbarch)
&& stepping_over_breakpoint
&& sig == TARGET_SIGNAL_0)
{
return;
}
- if (step && gdbarch_software_single_step_p (current_gdbarch))
+ if (step && gdbarch_software_single_step_p (gdbarch))
{
/* Do it the hard way, w/temp breakpoints */
- if (gdbarch_software_single_step (current_gdbarch, get_current_frame ()))
+ if (gdbarch_software_single_step (gdbarch, get_current_frame ()))
{
/* ...and don't ask hardware to do it. */
step = 0;
resume_ptid = inferior_ptid;
}
- if (gdbarch_cannot_step_breakpoint (current_gdbarch))
+ if (gdbarch_cannot_step_breakpoint (gdbarch))
{
/* Most targets can step a breakpoint instruction, thus
executing it normally. But if this one cannot, just
}
if (debug_displaced
- && use_displaced_stepping (current_gdbarch)
+ && use_displaced_stepping (gdbarch)
&& stepping_over_breakpoint)
{
- CORE_ADDR actual_pc = read_pc_pid (resume_ptid);
+ struct regcache *resume_regcache = get_thread_regcache (resume_ptid);
+ CORE_ADDR actual_pc = regcache_read_pc (resume_regcache);
gdb_byte buf[4];
fprintf_unfiltered (gdb_stdlog, "displaced: run 0x%s: ",
/* Switched over from WAIT_PID. */
if (!ptid_equal (wait_ptid, minus_one_ptid)
- && !ptid_equal (inferior_ptid, wait_ptid)
- && breakpoint_here_p (read_pc_pid (wait_ptid)))
+ && !ptid_equal (inferior_ptid, wait_ptid))
{
- /* If stepping, remember current thread to switch back to. */
- if (step)
+ struct regcache *regcache = get_thread_regcache (wait_ptid);
+
+ if (breakpoint_here_p (regcache_read_pc (regcache)))
{
- deferred_step_ptid = inferior_ptid;
- }
+ /* If stepping, remember current thread to switch back to. */
+ if (step)
+ deferred_step_ptid = inferior_ptid;
- /* Switch back to WAIT_PID thread. */
- switch_to_thread (wait_ptid);
+ /* Switch back to WAIT_PID thread. */
+ switch_to_thread (wait_ptid);
- /* We return 1 to indicate that there is a breakpoint here,
- so we need to step over it before continuing to avoid
- hitting it straight away. */
- return 1;
+ /* We return 1 to indicate that there is a breakpoint here,
+ so we need to step over it before continuing to avoid
+ hitting it straight away. */
+ return 1;
+ }
}
return 0;
void
proceed (CORE_ADDR addr, enum target_signal siggnal, int step)
{
+ struct regcache *regcache = get_current_regcache ();
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ CORE_ADDR pc = regcache_read_pc (regcache);
int oneproc = 0;
if (step > 0)
- step_start_function = find_pc_function (read_pc ());
+ step_start_function = find_pc_function (pc);
if (step < 0)
stop_after_trap = 1;
if (addr == (CORE_ADDR) -1)
{
- if (read_pc () == stop_pc && breakpoint_here_p (read_pc ()))
+ if (pc == stop_pc && breakpoint_here_p (pc))
/* There is a breakpoint at the address we will resume at,
step one instruction before inserting breakpoints so that
we do not stop right away (and report a second hit at this
breakpoint). */
oneproc = 1;
- else if (gdbarch_single_step_through_delay_p (current_gdbarch)
- && gdbarch_single_step_through_delay (current_gdbarch,
- get_current_frame ()))
+ else if (gdbarch_single_step_through_delay_p (gdbarch)
+ && gdbarch_single_step_through_delay (gdbarch,
+ get_current_frame ()))
/* We stepped onto an instruction that needs to be stepped
again before re-inserting the breakpoint, do so. */
oneproc = 1;
}
else
{
- write_pc (addr);
+ regcache_write_pc (regcache, addr);
}
if (debug_infrun)
inserted. Otherwise we need to disable all breakpoints, step
one instruction, and then re-add them when that step is
finished. */
- if (!use_displaced_stepping (current_gdbarch))
+ if (!use_displaced_stepping (gdbarch))
remove_breakpoints ();
}
/* We can insert breakpoints if we're not trying to step over one,
or if we are stepping over one but we're using displaced stepping
to do so. */
- if (! stepping_over_breakpoint || use_displaced_stepping (current_gdbarch))
+ if (! stepping_over_breakpoint || use_displaced_stepping (gdbarch))
insert_breakpoints ();
if (siggnal != TARGET_SIGNAL_DEFAULT)
the prev_pc value before calculating the line number. This approach
did not work because on platforms that use ptrace, the pc register
cannot be read unless the inferior is stopped. At that point, we
- are not guaranteed the inferior is stopped and so the read_pc ()
+ are not guaranteed the inferior is stopped and so the regcache_read_pc ()
call can fail. Setting the prev_pc value here ensures the value is
updated correctly when the inferior is stopped. */
- prev_pc = read_pc ();
+ prev_pc = regcache_read_pc (get_current_regcache ());
/* Resume inferior. */
resume (oneproc || step || bpstat_should_step (), stop_signal);
static void
adjust_pc_after_break (struct execution_control_state *ecs)
{
+ struct regcache *regcache = get_thread_regcache (ecs->ptid);
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR breakpoint_pc;
/* If this target does not decrement the PC after breakpoints, then
we have nothing to do. */
- if (gdbarch_decr_pc_after_break (current_gdbarch) == 0)
+ if (gdbarch_decr_pc_after_break (gdbarch) == 0)
return;
/* If we've hit a breakpoint, we'll normally be stopped with SIGTRAP. If
/* Find the location where (if we've hit a breakpoint) the
breakpoint would be. */
- breakpoint_pc = read_pc_pid (ecs->ptid) - gdbarch_decr_pc_after_break
- (current_gdbarch);
+ breakpoint_pc = regcache_read_pc (regcache)
+ - gdbarch_decr_pc_after_break (gdbarch);
/* Check whether there actually is a software breakpoint inserted
at that location. */
|| !ptid_equal (ecs->ptid, inferior_ptid)
|| !currently_stepping (ecs)
|| prev_pc == breakpoint_pc)
- write_pc_pid (breakpoint_pc, ecs->ptid);
+ regcache_write_pc (regcache, breakpoint_pc);
}
}
follow_exec (PIDGET (inferior_ptid), pending_follow.execd_pathname);
xfree (pending_follow.execd_pathname);
- stop_pc = read_pc_pid (ecs->ptid);
+ stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
ecs->saved_inferior_ptid = inferior_ptid;
inferior_ptid = ecs->ptid;
it here, before we set stop_pc.) */
displaced_step_fixup (ecs->ptid, stop_signal);
- stop_pc = read_pc_pid (ecs->ptid);
+ stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
if (debug_infrun)
{
when they stop, or to re-poll the remote looking for
this particular thread (i.e. temporarily enable
schedlock). */
- if (read_pc_pid (singlestep_ptid) != singlestep_pc)
+
+ CORE_ADDR new_singlestep_pc
+ = regcache_read_pc (get_thread_regcache (singlestep_ptid));
+
+ if (new_singlestep_pc != singlestep_pc)
{
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: unexpected thread,"
the context we want to use. Just fudge our
state and continue. */
ecs->ptid = singlestep_ptid;
- stop_pc = read_pc_pid (ecs->ptid);
+ stop_pc = new_singlestep_pc;
}
else
{
}
-/* read_pc, write_pc, etc. Special handling for register PC. */
-
-/* NOTE: cagney/2001-02-18: The functions read_pc_pid(), read_pc() and
- read_sp(), will eventually be replaced by per-frame methods.
- Instead of relying on the global INFERIOR_PTID, they will use the
- contextual information provided by the FRAME. These functions do
- not belong in the register cache. */
-
-/* NOTE: cagney/2003-06-07: The functions generic_target_write_pc(),
- write_pc_pid() and write_pc(), all need to be replaced by something
- that does not rely on global state. But what? */
+/* Special handling for register PC. */
CORE_ADDR
-read_pc_pid (ptid_t ptid)
+regcache_read_pc (struct regcache *regcache)
{
- struct regcache *regcache = get_thread_regcache (ptid);
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR pc_val;
pc_val = gdbarch_addr_bits_remove (gdbarch, raw_val);
}
else
- internal_error (__FILE__, __LINE__, _("read_pc_pid: Unable to find PC"));
-
+ internal_error (__FILE__, __LINE__,
+ _("regcache_read_pc: Unable to find PC"));
return pc_val;
}
CORE_ADDR
read_pc (void)
{
- return read_pc_pid (inferior_ptid);
+ return regcache_read_pc (get_current_regcache ());
}
void
-write_pc_pid (CORE_ADDR pc, ptid_t ptid)
+regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
{
- struct regcache *regcache = get_thread_regcache (ptid);
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (gdbarch_write_pc_p (gdbarch))
gdbarch_pc_regnum (gdbarch), pc);
else
internal_error (__FILE__, __LINE__,
- _("write_pc_pid: Unable to update PC"));
+ _("regcache_write_pc: Unable to update PC"));
}
void
write_pc (CORE_ADDR pc)
{
- write_pc_pid (pc, inferior_ptid);
+ regcache_write_pc (get_current_regcache (), pc);
}