* regcache.c (read_pc, write_pc): Remove.
* infrun.c (displaced_step_fixup): Use regcache_read_pc instead
of read_pc.
(handle_inferior_event): Use regcache_read_pc instead of read_pc
when determining value of stop_pc. Replace subsequent uses of
read_pc by inspecting already-retrieved stop_pc value.
(keep_going): Use regcache_read_pc instead of read_pc.
* breakpoint.c (watchpoint_check): Use current frame architecture
and PC instead of current_gdbarch and read_pc ().
* tracepoint.c (set_traceframe_context): Replace PC argument
with FRAME argument.
(trace_start_command, finish_tfind_command): Update calls.
(finish_tfind_command): Compare frame IDs to identify transitions
between frames.
(trace_find_pc_command): Use regcache_read_pc instead of read_pc.
* rs6000-nat.c (exec_one_dummy_insn): Pass in regcache instead
of gdbarch. Use regcache_read_pc and regcache_write_pc instead
of read_pc and write_pc.
(store_register): Make regcache argument non-const. Update call
to exec_one_dummy_insn.
* thread.c (switch_to_thread): Use regcache_read_pc instead of read_pc.
* infcmd.c (post_create_inferior): Likewise.
* solib-darwin.c (darwin_solib_create_inferior_hook): Likewise.
* solib-pa64.c (pa64_solib_create_inferior_hook): Likewise.
* solib-sunos.c (sunos_solib_create_inferior_hook): Likewise.
* solib-svr4.c (enable_break, svr4_relocate_main_executable): Likewise.
* linux-fork.c (fork_load_infrun_state): Likewise.
* hppa-hpux-tdep.c (hppa_hpux_push_dummy_code): Likewise.
* record.c (record_wait): Likewise.
* procfs.c (procfs_wait): Likewise.
* remote-mips.c (common_open, mips_wait): Likewise.
* remote-m32r-sdi.c (m32r_resume): Likewise.
* symfile.c (generic_load): Use regcache_write_pc instead of write_pc.
* monitor.c (monitor_create_inferior, monitor_load): Likewise.
* m32r-rom.c (m32r_load, m32r_upload_command): Likewise.
* remote-m32r-sdi.c (m32r_create_inferior, m32r_load): Likewise.
* remote-mips.c (mips_create_inferior, mips_load): Likewise.
* solib-darwin.c: Include "regcache.h".
* solib-pa64.c: Include "regcache.h".
* solib-svr4.c: Include "regcache.h.".
* symfile.c: Do not mention read_pc or write_pc in comments.
* dink32-rom.c: Likewise.
* m32r-rom.c: Likewise.
* mips-tdep.c: Likewise.
+2009-05-05 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * inferior.h (read_pc, write_pc): Remove.
+ * regcache.c (read_pc, write_pc): Remove.
+
+ * infrun.c (displaced_step_fixup): Use regcache_read_pc instead
+ of read_pc.
+ (handle_inferior_event): Use regcache_read_pc instead of read_pc
+ when determining value of stop_pc. Replace subsequent uses of
+ read_pc by inspecting already-retrieved stop_pc value.
+ (keep_going): Use regcache_read_pc instead of read_pc.
+
+ * breakpoint.c (watchpoint_check): Use current frame architecture
+ and PC instead of current_gdbarch and read_pc ().
+ * tracepoint.c (set_traceframe_context): Replace PC argument
+ with FRAME argument.
+ (trace_start_command, finish_tfind_command): Update calls.
+ (finish_tfind_command): Compare frame IDs to identify transitions
+ between frames.
+ (trace_find_pc_command): Use regcache_read_pc instead of read_pc.
+ * rs6000-nat.c (exec_one_dummy_insn): Pass in regcache instead
+ of gdbarch. Use regcache_read_pc and regcache_write_pc instead
+ of read_pc and write_pc.
+ (store_register): Make regcache argument non-const. Update call
+ to exec_one_dummy_insn.
+
+ * thread.c (switch_to_thread): Use regcache_read_pc instead of read_pc.
+ * infcmd.c (post_create_inferior): Likewise.
+ * solib-darwin.c (darwin_solib_create_inferior_hook): Likewise.
+ * solib-pa64.c (pa64_solib_create_inferior_hook): Likewise.
+ * solib-sunos.c (sunos_solib_create_inferior_hook): Likewise.
+ * solib-svr4.c (enable_break, svr4_relocate_main_executable): Likewise.
+ * linux-fork.c (fork_load_infrun_state): Likewise.
+ * hppa-hpux-tdep.c (hppa_hpux_push_dummy_code): Likewise.
+ * record.c (record_wait): Likewise.
+ * procfs.c (procfs_wait): Likewise.
+ * remote-mips.c (common_open, mips_wait): Likewise.
+ * remote-m32r-sdi.c (m32r_resume): Likewise.
+
+ * symfile.c (generic_load): Use regcache_write_pc instead of write_pc.
+ * monitor.c (monitor_create_inferior, monitor_load): Likewise.
+ * m32r-rom.c (m32r_load, m32r_upload_command): Likewise.
+ * remote-m32r-sdi.c (m32r_create_inferior, m32r_load): Likewise.
+ * remote-mips.c (mips_create_inferior, mips_load): Likewise.
+
+ * solib-darwin.c: Include "regcache.h".
+ * solib-pa64.c: Include "regcache.h".
+ * solib-svr4.c: Include "regcache.h.".
+
+ * symfile.c: Do not mention read_pc or write_pc in comments.
+ * dink32-rom.c: Likewise.
+ * m32r-rom.c: Likewise.
+ * mips-tdep.c: Likewise.
+
2009-05-05 Ulrich Weigand <uweigand@de.ibm.com>
* fork-child.c (startup_inferior): Move setting stop_pc ...
that the watchpoint frame couldn't be found by frame_find_by_id()
because the current PC is currently in an epilogue. Calling
gdbarch_in_function_epilogue_p() also when fr == NULL fixes that. */
- if ((!within_current_scope || fr == get_current_frame ())
- && gdbarch_in_function_epilogue_p (current_gdbarch, read_pc ()))
- return WP_VALUE_NOT_CHANGED;
+ if (!within_current_scope || fr == get_current_frame ())
+ {
+ struct frame_info *frame = get_current_frame ();
+ struct gdbarch *frame_arch = get_frame_arch (frame);
+ CORE_ADDR frame_pc = get_frame_pc (frame);
+
+ if (gdbarch_in_function_epilogue_p (frame_arch, frame_pc))
+ return WP_VALUE_NOT_CHANGED;
+ }
if (fr && within_current_scope)
/* If we end up stopping, the current frame will get selected
in normal_stop. So this call to select_frame won't affect
#include "monitor.h"
#include "serial.h"
#include "symfile.h" /* For generic_load() */
-#include "inferior.h" /* For write_pc() */
+#include "inferior.h"
#include "regcache.h"
static void dink32_open (char *args, int from_tty);
CORE_ADDR pc, stubaddr;
int argreg = 0;
- pc = read_pc ();
+ pc = regcache_read_pc (regcache);
/* Note: we don't want to pass a function descriptor here; push_dummy_call
fills in the PIC register for us. */
target_find_description ();
/* Now that we know the register layout, retrieve current PC. */
- stop_pc = read_pc ();
+ stop_pc = regcache_read_pc (get_current_regcache ());
/* If the solist is global across processes, there's no need to
refetch it here. */
extern void terminal_ours (void);
-extern CORE_ADDR read_pc (void);
-
-extern void write_pc (CORE_ADDR);
-
extern CORE_ADDR unsigned_pointer_to_address (struct type *type,
const gdb_byte *buf);
extern void unsigned_address_to_pointer (struct type *type, gdb_byte *buf,
context_switch (ptid);
- actual_pc = read_pc ();
+ actual_pc = regcache_read_pc (get_thread_regcache (ptid));
if (breakpoint_here_p (actual_pc))
{
reinit_frame_cache ();
}
- stop_pc = read_pc ();
+ stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
reinit_frame_cache ();
}
- stop_pc = read_pc ();
+ stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
/* This causes the eventpoints and symbol table to be reset.
Must do this now, before trying to determine whether to
case TARGET_WAITKIND_NO_HISTORY:
/* Reverse execution: target ran out of history info. */
- stop_pc = read_pc ();
+ stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
print_stop_reason (NO_HISTORY, 0);
stop_stepping (ecs);
return;
if (!HAVE_STEPPABLE_WATCHPOINT)
remove_breakpoints ();
/* Single step */
- hw_step = maybe_software_singlestep (current_gdbarch, read_pc ());
+ hw_step = maybe_software_singlestep (current_gdbarch, stop_pc);
target_resume (ecs->ptid, hw_step, TARGET_SIGNAL_0);
registers_changed ();
waiton_ptid = ecs->ptid;
if (signal_program[ecs->event_thread->stop_signal] == 0)
ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
- if (ecs->event_thread->prev_pc == read_pc ()
+ if (ecs->event_thread->prev_pc == stop_pc
&& ecs->event_thread->trap_expected
&& ecs->event_thread->step_resume_breakpoint == NULL)
{
keep_going (struct execution_control_state *ecs)
{
/* Save the pc before execution, to compare with pc after stop. */
- ecs->event_thread->prev_pc = read_pc (); /* Might have been DECR_AFTER_BREAK */
+ ecs->event_thread->prev_pc
+ = regcache_read_pc (get_thread_regcache (ecs->ptid));
/* If we did not do break;, it means we should keep running the
inferior and not return to debugger. */
registers_changed ();
reinit_frame_cache ();
- stop_pc = read_pc ();
+ stop_pc = regcache_read_pc (get_current_regcache ());
nullify_last_target_wait_ptid ();
/* Now restore the file positions of open file descriptors. */
fp->savedregs = regcache_dup (get_current_regcache ());
fp->clobber_regs = clobber_regs;
- fp->pc = read_pc ();
+ fp->pc = regcache_read_pc (get_current_regcache ());
if (clobber_regs)
{
if (ptid_equal (fp->ptid, inferior_ptid))
{
printf_filtered ("* ");
- pc = read_pc ();
+ pc = regcache_read_pc (get_current_regcache ());
}
else
{
#include <time.h> /* for time_t */
#include "gdb_string.h"
#include "objfiles.h" /* for ALL_OBJFILES etc. */
-#include "inferior.h" /* for write_pc() */
+#include "inferior.h"
#include <ctype.h>
#include "regcache.h"
/* Finally, make the PC point at the start address */
if (exec_bfd)
- write_pc (bfd_get_start_address (exec_bfd));
+ regcache_write_pc (get_current_regcache (),
+ bfd_get_start_address (exec_bfd));
inferior_ptid = null_ptid; /* No process now */
gdb_flush (gdb_stdout);
}
/* Finally, make the PC point at the start address */
- write_pc (bfd_get_start_address (abfd));
+ regcache_write_pc (get_current_regcache (),
+ bfd_get_start_address (abfd));
printf_filtered ("Start address 0x%lx\n",
(unsigned long) bfd_get_start_address (abfd));
print_transfer_performance (gdb_stdout, data_count, 0, &start_time,
reg_names = mips_generic_reg_names;
}
/* FIXME: cagney/2003-11-15: For MIPS, hasn't gdbarch_pc_regnum been
- replaced by read_pc? */
+ replaced by gdbarch_read_pc? */
set_gdbarch_pc_regnum (gdbarch, regnum->pc + num_regs);
set_gdbarch_sp_regnum (gdbarch, MIPS_SP_REGNUM + num_regs);
set_gdbarch_fp0_regnum (gdbarch, regnum->fp0);
first_time = 1;
clear_proceed_status ();
- write_pc (bfd_get_start_address (exec_bfd));
+ regcache_write_pc (get_current_regcache (),
+ bfd_get_start_address (exec_bfd));
}
/* Clean up when a program exits.
/* Finally, make the PC point at the start address */
if (exec_bfd)
- write_pc (bfd_get_start_address (exec_bfd));
+ regcache_write_pc (get_current_regcache (),
+ bfd_get_start_address (exec_bfd));
/* There used to be code here which would clear inferior_ptid and
call clear_symtab_users. None of that should be necessary:
then remove it. See comments in procfs_init_inferior()
for more details. */
if (dbx_link_bpt_addr != 0
- && dbx_link_bpt_addr == read_pc ())
+ && dbx_link_bpt_addr
+ == regcache_read_pc (get_current_regcache ()))
remove_dbx_link_breakpoint ();
wstat = (SIGTRAP << 8) | 0177;
{
/* Check if there is a breakpoint. */
registers_changed ();
- tmp_pc = read_pc ();
+ tmp_pc = regcache_read_pc (get_current_regcache ());
if (breakpoint_inserted_here_p (tmp_pc))
{
/* There is a breakpoint. */
return pc_val;
}
-CORE_ADDR
-read_pc (void)
-{
- return regcache_read_pc (get_current_regcache ());
-}
-
void
regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
{
_("regcache_write_pc: Unable to update PC"));
}
-void
-write_pc (CORE_ADDR pc)
-{
- regcache_write_pc (get_current_regcache (), pc);
-}
-
static void
reg_flush_command (char *command, int from_tty)
/* Install inferior's terminal modes. */
target_terminal_inferior ();
- write_pc (entry_pt);
+ regcache_write_pc (get_current_regcache (), entry_pt);
}
/* Open a connection to a remote debugger.
check_mmu_status ();
- pc_addr = read_pc ();
+ pc_addr = regcache_read_pc (get_current_regcache ());
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "pc <= 0x%lx\n", pc_addr);
/* Make the PC point at the start address */
if (exec_bfd)
- write_pc (bfd_get_start_address (exec_bfd));
+ regcache_write_pc (get_current_regcache (),
+ bfd_get_start_address (exec_bfd));
inferior_ptid = null_ptid; /* No process now */
delete_thread_silent (remote_m32r_ptid);
reinit_frame_cache ();
registers_changed ();
- stop_pc = read_pc ();
+ stop_pc = regcache_read_pc (get_current_regcache ());
print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
xfree (serial_port_name);
}
fetch breakpoint, not a data watchpoint. FIXME when PMON
provides some way to tell us what type of breakpoint it is. */
int i;
- CORE_ADDR pc = read_pc ();
+ CORE_ADDR pc = regcache_read_pc (get_current_regcache ());
hit_watchpoint = 1;
for (i = 0; i < MAX_LSI_BREAKPOINTS; i++)
{
char *func_name;
CORE_ADDR func_start;
- CORE_ADDR pc = read_pc ();
+ CORE_ADDR pc = regcache_read_pc (get_current_regcache ());
find_pc_partial_function (pc, &func_name, &func_start, NULL);
if (func_name != NULL && strcmp (func_name, "_exit") == 0
/* FIXME: Should we set inferior_ptid here? */
- write_pc (entry_pt);
+ regcache_write_pc (get_current_regcache (), entry_pt);
}
/* Clean up after a process. Actually nothing to do. */
static void
mips_load (char *file, int from_tty)
{
+ struct regcache *regcache;
+
/* Get the board out of remote debugging mode. */
if (mips_exit_debug ())
error ("mips_load: Couldn't get into monitor mode.");
mips_initialize ();
/* Finally, make the PC point at the start address */
+ regcache = get_current_regcache ();
if (mips_monitor != MON_IDT)
{
/* Work around problem where PMON monitor updates the PC after a load
to a different value than GDB thinks it has. The following ensures
- that the write_pc() WILL update the PC value: */
- struct regcache *regcache = get_current_regcache ();
+ that the regcache_write_pc() WILL update the PC value: */
regcache_invalidate (regcache,
gdbarch_pc_regnum (get_regcache_arch (regcache)));
}
if (exec_bfd)
- write_pc (bfd_get_start_address (exec_bfd));
+ regcache_write_pc (regcache, bfd_get_start_address (exec_bfd));
inferior_ptid = null_ptid; /* No process now */
static void vmap_symtab (struct vmap *);
-static void exec_one_dummy_insn (struct gdbarch *);
+static void exec_one_dummy_insn (struct regcache *);
extern void fixup_breakpoints (CORE_ADDR low, CORE_ADDR high, CORE_ADDR delta);
/* Store register REGNO back into the inferior. */
static void
-store_register (const struct regcache *regcache, int regno)
+store_register (struct regcache *regcache, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int addr[MAX_REGISTER_SIZE];
Otherwise the following ptrace(2) calls will mess up user stack
since kernel will get confused about the bottom of the stack
(%sp). */
- exec_one_dummy_insn (gdbarch);
+ exec_one_dummy_insn (regcache);
/* The PT_WRITE_GPR operation is rather odd. For 32-bit inferiors,
the register's value is passed by value, but for 64-bit inferiors,
including u_area. */
static void
-exec_one_dummy_insn (struct gdbarch *gdbarch)
+exec_one_dummy_insn (struct regcache *regcache)
{
#define DUMMY_INSN_ADDR AIX_TEXT_SEGMENT_BASE+0x200
on. However, rs6000-ibm-aix4.1.3 seems to have screwed this up --
the inferior never hits the breakpoint (it's also worth noting
powerpc-ibm-aix4.1.3 works correctly). */
- prev_pc = read_pc ();
- write_pc (DUMMY_INSN_ADDR);
+ prev_pc = regcache_read_pc (regcache);
+ regcache_write_pc (regcache, DUMMY_INSN_ADDR);
if (ARCH64 ())
ret = rs6000_ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL);
else
}
while (pid != PIDGET (inferior_ptid));
- write_pc (prev_pc);
+ regcache_write_pc (regcache, prev_pc);
deprecated_remove_raw_breakpoint (bp);
}
\f
#include "gdbcore.h"
#include "target.h"
#include "inferior.h"
+#include "regcache.h"
#include "gdbthread.h"
#include "gdb_assert.h"
/* We find the dynamic linker's base address by examining
the current pc (which should point at the entry point for the
dynamic linker) and subtracting the offset of the entry point. */
- load_addr = (read_pc () - bfd_get_start_address (dyld_bfd));
+ load_addr = (regcache_read_pc (get_current_regcache ())
+ - bfd_get_start_address (dyld_bfd));
}
else
{
#include "gdbcore.h"
#include "target.h"
#include "inferior.h"
+#include "regcache.h"
#include "hppa-tdep.h"
#include "solist.h"
Also note the breakpoint is the second instruction in the
routine. */
- load_addr = read_pc () - tmp_bfd->start_address;
+ load_addr = regcache_read_pc (get_current_regcache ())
+ - tmp_bfd->start_address;
sym_addr = bfd_lookup_symbol (tmp_bfd, "__dld_break");
sym_addr = load_addr + sym_addr + 4;
if (gdbarch_decr_pc_after_break (target_gdbarch))
{
stop_pc -= gdbarch_decr_pc_after_break (target_gdbarch);
- write_pc (stop_pc);
+ regcache_write_pc (get_current_regcache (), stop_pc);
}
if (!disable_break ())
#include "gdbcore.h"
#include "target.h"
#include "inferior.h"
+#include "regcache.h"
#include "gdbthread.h"
#include "gdb_assert.h"
fallback method because it has actually been working well in
most cases. */
if (!load_addr_found)
- load_addr = (read_pc ()
- - exec_entry_point (tmp_bfd, tmp_bfd_target));
+ {
+ struct regcache *regcache = get_thread_regcache (inferior_ptid);
+ load_addr = (regcache_read_pc (regcache)
+ - exec_entry_point (tmp_bfd, tmp_bfd_target));
+ }
if (!loader_found_in_list)
{
svr4_relocate_main_executable (void)
{
asection *interp_sect;
- CORE_ADDR pc = read_pc ();
+ struct regcache *regcache = get_thread_regcache (inferior_ptid);
+ CORE_ADDR pc = regcache_read_pc (regcache);
/* Decide if the objfile needs to be relocated. As indicated above,
we will only be here when execution is stopped at the beginning
#include "language.h"
#include "complaints.h"
#include "demangle.h"
-#include "inferior.h" /* for write_pc */
+#include "inferior.h"
+#include "regcache.h"
#include "filenames.h" /* for DOSish file names */
#include "gdb-stabs.h"
#include "gdb_obstack.h"
ui_out_text (uiout, "\n");
/* We were doing this in remote-mips.c, I suspect it is right
for other targets too. */
- write_pc (entry);
+ regcache_write_pc (get_current_regcache (), entry);
/* FIXME: are we supposed to call symbol_file_add or not? According
to a comment from remote-mips.c (where a call to symbol_file_add
if (!ptid_equal (inferior_ptid, null_ptid)
&& !is_exited (ptid)
&& !is_executing (ptid))
- stop_pc = read_pc ();
+ stop_pc = regcache_read_pc (get_thread_regcache (ptid));
else
stop_pc = ~(CORE_ADDR) 0;
}
the traceframe context (line, function, file) */
static void
-set_traceframe_context (CORE_ADDR trace_pc)
+set_traceframe_context (struct frame_info *trace_frame)
{
+ CORE_ADDR trace_pc;
+
static struct type *func_string, *file_string;
static struct type *func_range, *file_range;
struct value *func_val;
struct value *file_val;
int len;
- if (trace_pc == -1) /* Cease debugging any trace buffers. */
+ if (trace_frame == NULL) /* Cease debugging any trace buffers. */
{
traceframe_fun = 0;
traceframe_sal.pc = traceframe_sal.line = 0;
}
/* Save as globals for internal use. */
+ trace_pc = get_frame_pc (trace_frame);
traceframe_sal = find_pc_line (trace_pc, 0);
traceframe_fun = find_pc_function (trace_pc);
error (_("Bogus reply from target: %s"), target_buf);
set_traceframe_num (-1); /* All old traceframes invalidated. */
set_tracepoint_num (-1);
- set_traceframe_context (-1);
+ set_traceframe_context (NULL);
trace_running_p = 1;
if (deprecated_trace_start_stop_hook)
deprecated_trace_start_stop_hook (1, from_tty);
int from_tty)
{
int target_frameno = -1, target_tracept = -1;
- CORE_ADDR old_frame_addr;
- struct symbol *old_func;
+ struct frame_id old_frame_id;
char *reply;
- old_frame_addr = get_frame_base (get_current_frame ());
- old_func = find_pc_function (read_pc ());
+ old_frame_id = get_frame_id (get_current_frame ());
putpkt (*msg);
reply = remote_get_noisy_reply (msg, sizeof_msg);
set_traceframe_num (target_frameno);
set_tracepoint_num (target_tracept);
if (target_frameno == -1)
- set_traceframe_context (-1);
+ set_traceframe_context (NULL);
else
- set_traceframe_context (read_pc ());
+ set_traceframe_context (get_current_frame ());
if (from_tty)
{
whether we have made a transition from one function to
another. If so, we'll print the "stack frame" (ie. the new
function and it's arguments) -- otherwise we'll just show the
- new source line.
-
- This determination is made by checking (1) whether the
- current function has changed, and (2) whether the current FP
- has changed. Hack: if the FP wasn't collected, either at the
- current or the previous frame, assume that the FP has NOT
- changed. */
-
- if (old_func == find_pc_function (read_pc ()) &&
- (old_frame_addr == 0 ||
- get_frame_base (get_current_frame ()) == 0 ||
- old_frame_addr == get_frame_base (get_current_frame ())))
+ new source line. */
+
+ if (frame_id_eq (old_frame_id,
+ get_frame_id (get_current_frame ())))
print_what = SRC_LINE;
else
print_what = SRC_AND_LOC;
if (target_is_remote ())
{
if (args == 0 || *args == 0)
- pc = read_pc (); /* default is current pc */
+ pc = regcache_read_pc (get_current_regcache ());
else
pc = parse_and_eval_address (args);