* 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.
This commit is contained in:
Ulrich Weigand
2009-05-05 13:24:49 +00:00
parent 738a79f669
commit fb14de7bbd
24 changed files with 143 additions and 87 deletions

View File

@ -1,3 +1,57 @@
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> 2009-05-05 Ulrich Weigand <uweigand@de.ibm.com>
* fork-child.c (startup_inferior): Move setting stop_pc ... * fork-child.c (startup_inferior): Move setting stop_pc ...

View File

@ -2712,9 +2712,15 @@ watchpoint_check (void *p)
that the watchpoint frame couldn't be found by frame_find_by_id() that the watchpoint frame couldn't be found by frame_find_by_id()
because the current PC is currently in an epilogue. Calling because the current PC is currently in an epilogue. Calling
gdbarch_in_function_epilogue_p() also when fr == NULL fixes that. */ gdbarch_in_function_epilogue_p() also when fr == NULL fixes that. */
if ((!within_current_scope || fr == get_current_frame ()) if (!within_current_scope || fr == get_current_frame ())
&& gdbarch_in_function_epilogue_p (current_gdbarch, read_pc ())) {
return WP_VALUE_NOT_CHANGED; 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 (fr && within_current_scope)
/* If we end up stopping, the current frame will get selected /* If we end up stopping, the current frame will get selected
in normal_stop. So this call to select_frame won't affect in normal_stop. So this call to select_frame won't affect

View File

@ -24,7 +24,7 @@
#include "monitor.h" #include "monitor.h"
#include "serial.h" #include "serial.h"
#include "symfile.h" /* For generic_load() */ #include "symfile.h" /* For generic_load() */
#include "inferior.h" /* For write_pc() */ #include "inferior.h"
#include "regcache.h" #include "regcache.h"
static void dink32_open (char *args, int from_tty); static void dink32_open (char *args, int from_tty);

View File

@ -1108,7 +1108,7 @@ hppa_hpux_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
CORE_ADDR pc, stubaddr; CORE_ADDR pc, stubaddr;
int argreg = 0; 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 /* Note: we don't want to pass a function descriptor here; push_dummy_call
fills in the PIC register for us. */ fills in the PIC register for us. */

View File

@ -392,7 +392,7 @@ post_create_inferior (struct target_ops *target, int from_tty)
target_find_description (); target_find_description ();
/* Now that we know the register layout, retrieve current PC. */ /* 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 /* If the solist is global across processes, there's no need to
refetch it here. */ refetch it here. */

View File

@ -152,10 +152,6 @@ extern void terminal_save_ours (void);
extern void terminal_ours (void); 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, extern CORE_ADDR unsigned_pointer_to_address (struct type *type,
const gdb_byte *buf); const gdb_byte *buf);
extern void unsigned_address_to_pointer (struct type *type, gdb_byte *buf, extern void unsigned_address_to_pointer (struct type *type, gdb_byte *buf,

View File

@ -838,7 +838,7 @@ displaced_step_fixup (ptid_t event_ptid, enum target_signal signal)
context_switch (ptid); context_switch (ptid);
actual_pc = read_pc (); actual_pc = regcache_read_pc (get_thread_regcache (ptid));
if (breakpoint_here_p (actual_pc)) if (breakpoint_here_p (actual_pc))
{ {
@ -2425,7 +2425,7 @@ handle_inferior_event (struct execution_control_state *ecs)
reinit_frame_cache (); 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); ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
@ -2454,7 +2454,7 @@ handle_inferior_event (struct execution_control_state *ecs)
reinit_frame_cache (); 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. /* This causes the eventpoints and symbol table to be reset.
Must do this now, before trying to determine whether to Must do this now, before trying to determine whether to
@ -2504,7 +2504,7 @@ handle_inferior_event (struct execution_control_state *ecs)
case TARGET_WAITKIND_NO_HISTORY: case TARGET_WAITKIND_NO_HISTORY:
/* Reverse execution: target ran out of history info. */ /* 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); print_stop_reason (NO_HISTORY, 0);
stop_stepping (ecs); stop_stepping (ecs);
return; return;
@ -2852,7 +2852,7 @@ targets should add new threads to the thread list themselves in non-stop mode.")
if (!HAVE_STEPPABLE_WATCHPOINT) if (!HAVE_STEPPABLE_WATCHPOINT)
remove_breakpoints (); remove_breakpoints ();
/* Single step */ /* 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); target_resume (ecs->ptid, hw_step, TARGET_SIGNAL_0);
registers_changed (); registers_changed ();
waiton_ptid = ecs->ptid; waiton_ptid = ecs->ptid;
@ -3083,7 +3083,7 @@ process_event_stop_test:
if (signal_program[ecs->event_thread->stop_signal] == 0) if (signal_program[ecs->event_thread->stop_signal] == 0)
ecs->event_thread->stop_signal = TARGET_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->trap_expected
&& ecs->event_thread->step_resume_breakpoint == NULL) && ecs->event_thread->step_resume_breakpoint == NULL)
{ {
@ -4032,7 +4032,8 @@ static void
keep_going (struct execution_control_state *ecs) keep_going (struct execution_control_state *ecs)
{ {
/* Save the pc before execution, to compare with pc after stop. */ /* 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 /* If we did not do break;, it means we should keep running the
inferior and not return to debugger. */ inferior and not return to debugger. */

View File

@ -250,7 +250,7 @@ fork_load_infrun_state (struct fork_info *fp)
registers_changed (); registers_changed ();
reinit_frame_cache (); reinit_frame_cache ();
stop_pc = read_pc (); stop_pc = regcache_read_pc (get_current_regcache ());
nullify_last_target_wait_ptid (); nullify_last_target_wait_ptid ();
/* Now restore the file positions of open file descriptors. */ /* Now restore the file positions of open file descriptors. */
@ -280,7 +280,7 @@ fork_save_infrun_state (struct fork_info *fp, int clobber_regs)
fp->savedregs = regcache_dup (get_current_regcache ()); fp->savedregs = regcache_dup (get_current_regcache ());
fp->clobber_regs = clobber_regs; fp->clobber_regs = clobber_regs;
fp->pc = read_pc (); fp->pc = regcache_read_pc (get_current_regcache ());
if (clobber_regs) if (clobber_regs)
{ {
@ -501,7 +501,7 @@ info_forks_command (char *arg, int from_tty)
if (ptid_equal (fp->ptid, inferior_ptid)) if (ptid_equal (fp->ptid, inferior_ptid))
{ {
printf_filtered ("* "); printf_filtered ("* ");
pc = read_pc (); pc = regcache_read_pc (get_current_regcache ());
} }
else else
{ {

View File

@ -37,7 +37,7 @@
#include <time.h> /* for time_t */ #include <time.h> /* for time_t */
#include "gdb_string.h" #include "gdb_string.h"
#include "objfiles.h" /* for ALL_OBJFILES etc. */ #include "objfiles.h" /* for ALL_OBJFILES etc. */
#include "inferior.h" /* for write_pc() */ #include "inferior.h"
#include <ctype.h> #include <ctype.h>
#include "regcache.h" #include "regcache.h"
@ -175,7 +175,8 @@ m32r_load (char *filename, int from_tty)
/* Finally, make the PC point at the start address */ /* Finally, make the PC point at the start address */
if (exec_bfd) 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 */ inferior_ptid = null_ptid; /* No process now */
@ -532,7 +533,8 @@ m32r_upload_command (char *args, int from_tty)
gdb_flush (gdb_stdout); gdb_flush (gdb_stdout);
} }
/* Finally, make the PC point at the start address */ /* 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", printf_filtered ("Start address 0x%lx\n",
(unsigned long) bfd_get_start_address (abfd)); (unsigned long) bfd_get_start_address (abfd));
print_transfer_performance (gdb_stdout, data_count, 0, &start_time, print_transfer_performance (gdb_stdout, data_count, 0, &start_time,

View File

@ -5796,7 +5796,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
reg_names = mips_generic_reg_names; reg_names = mips_generic_reg_names;
} }
/* FIXME: cagney/2003-11-15: For MIPS, hasn't gdbarch_pc_regnum been /* 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_pc_regnum (gdbarch, regnum->pc + num_regs);
set_gdbarch_sp_regnum (gdbarch, MIPS_SP_REGNUM + num_regs); set_gdbarch_sp_regnum (gdbarch, MIPS_SP_REGNUM + num_regs);
set_gdbarch_fp0_regnum (gdbarch, regnum->fp0); set_gdbarch_fp0_regnum (gdbarch, regnum->fp0);

View File

@ -2007,7 +2007,8 @@ monitor_create_inferior (struct target_ops *ops, char *exec_file,
first_time = 1; first_time = 1;
clear_proceed_status (); 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. /* Clean up when a program exits.
@ -2155,7 +2156,8 @@ monitor_load (char *file, int from_tty)
/* Finally, make the PC point at the start address */ /* Finally, make the PC point at the start address */
if (exec_bfd) 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 /* There used to be code here which would clear inferior_ptid and
call clear_symtab_users. None of that should be necessary: call clear_symtab_users. None of that should be necessary:

View File

@ -4278,7 +4278,8 @@ wait_again:
then remove it. See comments in procfs_init_inferior() then remove it. See comments in procfs_init_inferior()
for more details. */ for more details. */
if (dbx_link_bpt_addr != 0 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 (); remove_dbx_link_breakpoint ();
wstat = (SIGTRAP << 8) | 0177; wstat = (SIGTRAP << 8) | 0177;

View File

@ -608,7 +608,7 @@ record_wait (struct target_ops *ops,
{ {
/* Check if there is a breakpoint. */ /* Check if there is a breakpoint. */
registers_changed (); registers_changed ();
tmp_pc = read_pc (); tmp_pc = regcache_read_pc (get_current_regcache ());
if (breakpoint_inserted_here_p (tmp_pc)) if (breakpoint_inserted_here_p (tmp_pc))
{ {
/* There is a breakpoint. */ /* There is a breakpoint. */

View File

@ -841,12 +841,6 @@ regcache_read_pc (struct regcache *regcache)
return pc_val; return pc_val;
} }
CORE_ADDR
read_pc (void)
{
return regcache_read_pc (get_current_regcache ());
}
void void
regcache_write_pc (struct regcache *regcache, CORE_ADDR pc) regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
{ {
@ -862,12 +856,6 @@ regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
_("regcache_write_pc: Unable to update PC")); _("regcache_write_pc: Unable to update PC"));
} }
void
write_pc (CORE_ADDR pc)
{
regcache_write_pc (get_current_regcache (), pc);
}
static void static void
reg_flush_command (char *command, int from_tty) reg_flush_command (char *command, int from_tty)

View File

@ -348,7 +348,7 @@ m32r_create_inferior (struct target_ops *ops, char *execfile,
/* Install inferior's terminal modes. */ /* Install inferior's terminal modes. */
target_terminal_inferior (); target_terminal_inferior ();
write_pc (entry_pt); regcache_write_pc (get_current_regcache (), entry_pt);
} }
/* Open a connection to a remote debugger. /* Open a connection to a remote debugger.
@ -464,7 +464,7 @@ m32r_resume (struct target_ops *ops,
check_mmu_status (); check_mmu_status ();
pc_addr = read_pc (); pc_addr = regcache_read_pc (get_current_regcache ());
if (remote_debug) if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "pc <= 0x%lx\n", pc_addr); fprintf_unfiltered (gdb_stdlog, "pc <= 0x%lx\n", pc_addr);
@ -1355,7 +1355,8 @@ m32r_load (char *args, int from_tty)
/* Make the PC point at the start address */ /* Make the PC point at the start address */
if (exec_bfd) 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 */ inferior_ptid = null_ptid; /* No process now */
delete_thread_silent (remote_m32r_ptid); delete_thread_silent (remote_m32r_ptid);

View File

@ -1573,7 +1573,7 @@ device is attached to the target board (e.g., /dev/ttya).\n"
reinit_frame_cache (); reinit_frame_cache ();
registers_changed (); 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); print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
xfree (serial_port_name); xfree (serial_port_name);
} }
@ -1792,7 +1792,7 @@ mips_wait (struct target_ops *ops,
fetch breakpoint, not a data watchpoint. FIXME when PMON fetch breakpoint, not a data watchpoint. FIXME when PMON
provides some way to tell us what type of breakpoint it is. */ provides some way to tell us what type of breakpoint it is. */
int i; int i;
CORE_ADDR pc = read_pc (); CORE_ADDR pc = regcache_read_pc (get_current_regcache ());
hit_watchpoint = 1; hit_watchpoint = 1;
for (i = 0; i < MAX_LSI_BREAKPOINTS; i++) for (i = 0; i < MAX_LSI_BREAKPOINTS; i++)
@ -1843,7 +1843,7 @@ mips_wait (struct target_ops *ops,
{ {
char *func_name; char *func_name;
CORE_ADDR func_start; 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); find_pc_partial_function (pc, &func_name, &func_start, NULL);
if (func_name != NULL && strcmp (func_name, "_exit") == 0 if (func_name != NULL && strcmp (func_name, "_exit") == 0
@ -2204,7 +2204,7 @@ Can't pass arguments to remote MIPS board; arguments ignored.");
/* FIXME: Should we set inferior_ptid here? */ /* 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. */ /* Clean up after a process. Actually nothing to do. */
@ -3258,6 +3258,8 @@ pmon_load_fast (char *file)
static void static void
mips_load (char *file, int from_tty) mips_load (char *file, int from_tty)
{ {
struct regcache *regcache;
/* Get the board out of remote debugging mode. */ /* Get the board out of remote debugging mode. */
if (mips_exit_debug ()) if (mips_exit_debug ())
error ("mips_load: Couldn't get into monitor mode."); error ("mips_load: Couldn't get into monitor mode.");
@ -3270,17 +3272,17 @@ mips_load (char *file, int from_tty)
mips_initialize (); mips_initialize ();
/* Finally, make the PC point at the start address */ /* Finally, make the PC point at the start address */
regcache = get_current_regcache ();
if (mips_monitor != MON_IDT) if (mips_monitor != MON_IDT)
{ {
/* Work around problem where PMON monitor updates the PC after a load /* Work around problem where PMON monitor updates the PC after a load
to a different value than GDB thinks it has. The following ensures to a different value than GDB thinks it has. The following ensures
that the write_pc() WILL update the PC value: */ that the regcache_write_pc() WILL update the PC value: */
struct regcache *regcache = get_current_regcache ();
regcache_invalidate (regcache, regcache_invalidate (regcache,
gdbarch_pc_regnum (get_regcache_arch (regcache))); gdbarch_pc_regnum (get_regcache_arch (regcache)));
} }
if (exec_bfd) 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 */ inferior_ptid = null_ptid; /* No process now */

View File

@ -130,7 +130,7 @@ static int objfile_symbol_add (void *);
static void vmap_symtab (struct vmap *); 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); extern void fixup_breakpoints (CORE_ADDR low, CORE_ADDR high, CORE_ADDR delta);
@ -267,7 +267,7 @@ fetch_register (struct regcache *regcache, int regno)
/* Store register REGNO back into the inferior. */ /* Store register REGNO back into the inferior. */
static void static void
store_register (const struct regcache *regcache, int regno) store_register (struct regcache *regcache, int regno)
{ {
struct gdbarch *gdbarch = get_regcache_arch (regcache); struct gdbarch *gdbarch = get_regcache_arch (regcache);
int addr[MAX_REGISTER_SIZE]; int addr[MAX_REGISTER_SIZE];
@ -303,7 +303,7 @@ store_register (const struct regcache *regcache, int regno)
Otherwise the following ptrace(2) calls will mess up user stack Otherwise the following ptrace(2) calls will mess up user stack
since kernel will get confused about the bottom of the stack since kernel will get confused about the bottom of the stack
(%sp). */ (%sp). */
exec_one_dummy_insn (gdbarch); exec_one_dummy_insn (regcache);
/* The PT_WRITE_GPR operation is rather odd. For 32-bit inferiors, /* 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, the register's value is passed by value, but for 64-bit inferiors,
@ -577,7 +577,7 @@ rs6000_wait (struct target_ops *ops,
including u_area. */ including u_area. */
static void 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 #define DUMMY_INSN_ADDR AIX_TEXT_SEGMENT_BASE+0x200
@ -596,8 +596,8 @@ exec_one_dummy_insn (struct gdbarch *gdbarch)
on. However, rs6000-ibm-aix4.1.3 seems to have screwed this up -- on. However, rs6000-ibm-aix4.1.3 seems to have screwed this up --
the inferior never hits the breakpoint (it's also worth noting the inferior never hits the breakpoint (it's also worth noting
powerpc-ibm-aix4.1.3 works correctly). */ powerpc-ibm-aix4.1.3 works correctly). */
prev_pc = read_pc (); prev_pc = regcache_read_pc (regcache);
write_pc (DUMMY_INSN_ADDR); regcache_write_pc (regcache, DUMMY_INSN_ADDR);
if (ARCH64 ()) if (ARCH64 ())
ret = rs6000_ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL); ret = rs6000_ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL);
else else
@ -612,7 +612,7 @@ exec_one_dummy_insn (struct gdbarch *gdbarch)
} }
while (pid != PIDGET (inferior_ptid)); while (pid != PIDGET (inferior_ptid));
write_pc (prev_pc); regcache_write_pc (regcache, prev_pc);
deprecated_remove_raw_breakpoint (bp); deprecated_remove_raw_breakpoint (bp);
} }

View File

@ -26,6 +26,7 @@
#include "gdbcore.h" #include "gdbcore.h"
#include "target.h" #include "target.h"
#include "inferior.h" #include "inferior.h"
#include "regcache.h"
#include "gdbthread.h" #include "gdbthread.h"
#include "gdb_assert.h" #include "gdb_assert.h"
@ -332,7 +333,8 @@ darwin_solib_create_inferior_hook (void)
/* We find the dynamic linker's base address by examining /* We find the dynamic linker's base address by examining
the current pc (which should point at the entry point for the the current pc (which should point at the entry point for the
dynamic linker) and subtracting the offset of the entry point. */ 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 else
{ {

View File

@ -36,6 +36,7 @@
#include "gdbcore.h" #include "gdbcore.h"
#include "target.h" #include "target.h"
#include "inferior.h" #include "inferior.h"
#include "regcache.h"
#include "hppa-tdep.h" #include "hppa-tdep.h"
#include "solist.h" #include "solist.h"
@ -421,7 +422,8 @@ pa64_solib_create_inferior_hook (void)
Also note the breakpoint is the second instruction in the Also note the breakpoint is the second instruction in the
routine. */ 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 = bfd_lookup_symbol (tmp_bfd, "__dld_break");
sym_addr = load_addr + sym_addr + 4; sym_addr = load_addr + sym_addr + 4;

View File

@ -791,7 +791,7 @@ sunos_solib_create_inferior_hook (void)
if (gdbarch_decr_pc_after_break (target_gdbarch)) if (gdbarch_decr_pc_after_break (target_gdbarch))
{ {
stop_pc -= 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 ()) if (!disable_break ())

View File

@ -32,6 +32,7 @@
#include "gdbcore.h" #include "gdbcore.h"
#include "target.h" #include "target.h"
#include "inferior.h" #include "inferior.h"
#include "regcache.h"
#include "gdbthread.h" #include "gdbthread.h"
#include "gdb_assert.h" #include "gdb_assert.h"
@ -1289,8 +1290,11 @@ enable_break (void)
fallback method because it has actually been working well in fallback method because it has actually been working well in
most cases. */ most cases. */
if (!load_addr_found) 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) if (!loader_found_in_list)
{ {
@ -1424,7 +1428,8 @@ static void
svr4_relocate_main_executable (void) svr4_relocate_main_executable (void)
{ {
asection *interp_sect; 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, /* Decide if the objfile needs to be relocated. As indicated above,
we will only be here when execution is stopped at the beginning we will only be here when execution is stopped at the beginning

View File

@ -37,7 +37,8 @@
#include "language.h" #include "language.h"
#include "complaints.h" #include "complaints.h"
#include "demangle.h" #include "demangle.h"
#include "inferior.h" /* for write_pc */ #include "inferior.h"
#include "regcache.h"
#include "filenames.h" /* for DOSish file names */ #include "filenames.h" /* for DOSish file names */
#include "gdb-stabs.h" #include "gdb-stabs.h"
#include "gdb_obstack.h" #include "gdb_obstack.h"
@ -1986,7 +1987,7 @@ generic_load (char *args, int from_tty)
ui_out_text (uiout, "\n"); ui_out_text (uiout, "\n");
/* We were doing this in remote-mips.c, I suspect it is right /* We were doing this in remote-mips.c, I suspect it is right
for other targets too. */ 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 /* 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 to a comment from remote-mips.c (where a call to symbol_file_add

View File

@ -852,7 +852,7 @@ switch_to_thread (ptid_t ptid)
if (!ptid_equal (inferior_ptid, null_ptid) if (!ptid_equal (inferior_ptid, null_ptid)
&& !is_exited (ptid) && !is_exited (ptid)
&& !is_executing (ptid)) && !is_executing (ptid))
stop_pc = read_pc (); stop_pc = regcache_read_pc (get_thread_regcache (ptid));
else else
stop_pc = ~(CORE_ADDR) 0; stop_pc = ~(CORE_ADDR) 0;
} }

View File

@ -224,15 +224,17 @@ set_tracepoint_num (int num)
the traceframe context (line, function, file) */ the traceframe context (line, function, file) */
static void 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_string, *file_string;
static struct type *func_range, *file_range; static struct type *func_range, *file_range;
struct value *func_val; struct value *func_val;
struct value *file_val; struct value *file_val;
int len; int len;
if (trace_pc == -1) /* Cease debugging any trace buffers. */ if (trace_frame == NULL) /* Cease debugging any trace buffers. */
{ {
traceframe_fun = 0; traceframe_fun = 0;
traceframe_sal.pc = traceframe_sal.line = 0; traceframe_sal.pc = traceframe_sal.line = 0;
@ -248,6 +250,7 @@ set_traceframe_context (CORE_ADDR trace_pc)
} }
/* Save as globals for internal use. */ /* Save as globals for internal use. */
trace_pc = get_frame_pc (trace_frame);
traceframe_sal = find_pc_line (trace_pc, 0); traceframe_sal = find_pc_line (trace_pc, 0);
traceframe_fun = find_pc_function (trace_pc); traceframe_fun = find_pc_function (trace_pc);
@ -1319,7 +1322,7 @@ trace_start_command (char *args, int from_tty)
error (_("Bogus reply from target: %s"), target_buf); error (_("Bogus reply from target: %s"), target_buf);
set_traceframe_num (-1); /* All old traceframes invalidated. */ set_traceframe_num (-1); /* All old traceframes invalidated. */
set_tracepoint_num (-1); set_tracepoint_num (-1);
set_traceframe_context (-1); set_traceframe_context (NULL);
trace_running_p = 1; trace_running_p = 1;
if (deprecated_trace_start_stop_hook) if (deprecated_trace_start_stop_hook)
deprecated_trace_start_stop_hook (1, from_tty); deprecated_trace_start_stop_hook (1, from_tty);
@ -1447,12 +1450,10 @@ finish_tfind_command (char **msg,
int from_tty) int from_tty)
{ {
int target_frameno = -1, target_tracept = -1; int target_frameno = -1, target_tracept = -1;
CORE_ADDR old_frame_addr; struct frame_id old_frame_id;
struct symbol *old_func;
char *reply; char *reply;
old_frame_addr = get_frame_base (get_current_frame ()); old_frame_id = get_frame_id (get_current_frame ());
old_func = find_pc_function (read_pc ());
putpkt (*msg); putpkt (*msg);
reply = remote_get_noisy_reply (msg, sizeof_msg); reply = remote_get_noisy_reply (msg, sizeof_msg);
@ -1517,9 +1518,9 @@ finish_tfind_command (char **msg,
set_traceframe_num (target_frameno); set_traceframe_num (target_frameno);
set_tracepoint_num (target_tracept); set_tracepoint_num (target_tracept);
if (target_frameno == -1) if (target_frameno == -1)
set_traceframe_context (-1); set_traceframe_context (NULL);
else else
set_traceframe_context (read_pc ()); set_traceframe_context (get_current_frame ());
if (from_tty) if (from_tty)
{ {
@ -1529,18 +1530,10 @@ finish_tfind_command (char **msg,
whether we have made a transition from one function to whether we have made a transition from one function to
another. If so, we'll print the "stack frame" (ie. the new another. If so, we'll print the "stack frame" (ie. the new
function and it's arguments) -- otherwise we'll just show the function and it's arguments) -- otherwise we'll just show the
new source line. new source line. */
This determination is made by checking (1) whether the if (frame_id_eq (old_frame_id,
current function has changed, and (2) whether the current FP get_frame_id (get_current_frame ())))
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 ())))
print_what = SRC_LINE; print_what = SRC_LINE;
else else
print_what = SRC_AND_LOC; print_what = SRC_AND_LOC;
@ -1635,7 +1628,7 @@ trace_find_pc_command (char *args, int from_tty)
if (target_is_remote ()) if (target_is_remote ())
{ {
if (args == 0 || *args == 0) if (args == 0 || *args == 0)
pc = read_pc (); /* default is current pc */ pc = regcache_read_pc (get_current_regcache ());
else else
pc = parse_and_eval_address (args); pc = parse_and_eval_address (args);