This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc] Eliminate read_pc and write_pc


Hello,

the previous patch reminded me that read_pc and write_pc are on the list of
obsolete routines to be removed anyway, because they make use of hidden
global state.

The following patch eliminated those two routines; at call sites where an
appropriate regcache or frame is available anyway, its access routines are
used; elsewhere, we fall back to the current regcache (use of which is now
at least explicit at the call sites).

Tested on powerpc64-linux.

Any comments or objections to this?   Otherwise, I'm planning on
committing this patch within the next couple of days.

Bye,
Ulrich

ChangeLog:

	* 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): 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.
	* 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.



Index: gdb-head/gdb/breakpoint.c
===================================================================
--- gdb-head.orig/gdb/breakpoint.c
+++ gdb-head/gdb/breakpoint.c
@@ -2712,9 +2712,15 @@ watchpoint_check (void *p)
 	 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
Index: gdb-head/gdb/dink32-rom.c
===================================================================
--- gdb-head.orig/gdb/dink32-rom.c
+++ gdb-head/gdb/dink32-rom.c
@@ -24,7 +24,7 @@
 #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);
Index: gdb-head/gdb/hppa-hpux-tdep.c
===================================================================
--- gdb-head.orig/gdb/hppa-hpux-tdep.c
+++ gdb-head/gdb/hppa-hpux-tdep.c
@@ -1108,7 +1108,7 @@ hppa_hpux_push_dummy_code (struct gdbarc
   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.  */
Index: gdb-head/gdb/inferior.h
===================================================================
--- gdb-head.orig/gdb/inferior.h
+++ gdb-head/gdb/inferior.h
@@ -152,10 +152,6 @@ extern void terminal_save_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,
 					      const gdb_byte *buf);
 extern void unsigned_address_to_pointer (struct type *type, gdb_byte *buf,
Index: gdb-head/gdb/infrun.c
===================================================================
--- gdb-head.orig/gdb/infrun.c
+++ gdb-head/gdb/infrun.c
@@ -836,7 +836,7 @@ displaced_step_fixup (ptid_t event_ptid,
 
       context_switch (ptid);
 
-      actual_pc = read_pc ();
+      actual_pc = regcache_read_pc (get_thread_regcache (ptid));
 
       if (breakpoint_here_p (actual_pc))
 	{
@@ -2416,7 +2416,7 @@ handle_inferior_event (struct execution_
 	  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);
 
@@ -2445,7 +2445,7 @@ handle_inferior_event (struct execution_
 	  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
@@ -2495,7 +2495,7 @@ handle_inferior_event (struct execution_
 
     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;
@@ -2843,7 +2843,7 @@ targets should add new threads to the th
       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;
@@ -3074,7 +3074,7 @@ process_event_stop_test:
       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)
 	{
@@ -4023,7 +4023,8 @@ static void
 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.  */
Index: gdb-head/gdb/linux-fork.c
===================================================================
--- gdb-head.orig/gdb/linux-fork.c
+++ gdb-head/gdb/linux-fork.c
@@ -250,7 +250,7 @@ fork_load_infrun_state (struct fork_info
   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.  */
@@ -280,7 +280,7 @@ fork_save_infrun_state (struct fork_info
 
   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)
     {
@@ -501,7 +501,7 @@ info_forks_command (char *arg, int from_
       if (ptid_equal (fp->ptid, inferior_ptid))
 	{
 	  printf_filtered ("* ");
-	  pc = read_pc ();
+	  pc = regcache_read_pc (get_current_regcache ());
 	}
       else
 	{
Index: gdb-head/gdb/m32r-rom.c
===================================================================
--- gdb-head.orig/gdb/m32r-rom.c
+++ gdb-head/gdb/m32r-rom.c
@@ -37,7 +37,7 @@
 #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"
 
@@ -175,7 +175,8 @@ m32r_load (char *filename, int from_tty)
 
   /* 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 */
 
@@ -532,7 +533,8 @@ m32r_upload_command (char *args, int fro
 	    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,
Index: gdb-head/gdb/mips-tdep.c
===================================================================
--- gdb-head.orig/gdb/mips-tdep.c
+++ gdb-head/gdb/mips-tdep.c
@@ -5796,7 +5796,7 @@ mips_gdbarch_init (struct gdbarch_info i
 	  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);
Index: gdb-head/gdb/monitor.c
===================================================================
--- gdb-head.orig/gdb/monitor.c
+++ gdb-head/gdb/monitor.c
@@ -2007,7 +2007,8 @@ monitor_create_inferior (struct target_o
 
   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.
@@ -2155,7 +2156,8 @@ monitor_load (char *file, int from_tty)
 
   /* 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:
Index: gdb-head/gdb/procfs.c
===================================================================
--- gdb-head.orig/gdb/procfs.c
+++ gdb-head/gdb/procfs.c
@@ -4278,7 +4278,8 @@ wait_again:
                      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;
Index: gdb-head/gdb/regcache.c
===================================================================
--- gdb-head.orig/gdb/regcache.c
+++ gdb-head/gdb/regcache.c
@@ -841,12 +841,6 @@ regcache_read_pc (struct regcache *regca
   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)
 {
@@ -862,12 +856,6 @@ regcache_write_pc (struct regcache *regc
 		    _("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)
Index: gdb-head/gdb/remote-m32r-sdi.c
===================================================================
--- gdb-head.orig/gdb/remote-m32r-sdi.c
+++ gdb-head/gdb/remote-m32r-sdi.c
@@ -348,7 +348,7 @@ m32r_create_inferior (struct target_ops 
   /* 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.
@@ -464,7 +464,7 @@ m32r_resume (struct target_ops *ops,
 
   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);
 
@@ -1355,7 +1355,8 @@ m32r_load (char *args, int from_tty)
 
   /* 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);
Index: gdb-head/gdb/remote-mips.c
===================================================================
--- gdb-head.orig/gdb/remote-mips.c
+++ gdb-head/gdb/remote-mips.c
@@ -1573,7 +1573,7 @@ device is attached to the target board (
 
   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);
 }
@@ -1792,7 +1792,7 @@ mips_wait (struct target_ops *ops,
          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++)
@@ -1843,7 +1843,7 @@ mips_wait (struct target_ops *ops,
 	{
 	  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
@@ -2204,7 +2204,7 @@ Can't pass arguments to remote MIPS boar
 
   /* 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.  */
@@ -3258,6 +3258,8 @@ pmon_load_fast (char *file)
 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.");
@@ -3270,17 +3272,17 @@ mips_load (char *file, int from_tty)
   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 */
 
Index: gdb-head/gdb/rs6000-nat.c
===================================================================
--- gdb-head.orig/gdb/rs6000-nat.c
+++ gdb-head/gdb/rs6000-nat.c
@@ -130,7 +130,7 @@ static int objfile_symbol_add (void *);
 
 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);
 
@@ -303,7 +303,7 @@ store_register (const struct regcache *r
 	   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,
@@ -577,7 +577,7 @@ rs6000_wait (struct target_ops *ops,
    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
 
@@ -596,8 +596,8 @@ exec_one_dummy_insn (struct gdbarch *gdb
      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
@@ -612,7 +612,7 @@ exec_one_dummy_insn (struct gdbarch *gdb
     }
   while (pid != PIDGET (inferior_ptid));
 
-  write_pc (prev_pc);
+  regcache_write_pc (regcache, prev_pc);
   deprecated_remove_raw_breakpoint (bp);
 }
 
Index: gdb-head/gdb/solib-darwin.c
===================================================================
--- gdb-head.orig/gdb/solib-darwin.c
+++ gdb-head/gdb/solib-darwin.c
@@ -26,6 +26,7 @@
 #include "gdbcore.h"
 #include "target.h"
 #include "inferior.h"
+#include "regcache.h"
 #include "gdbthread.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
 	 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
     {
Index: gdb-head/gdb/solib-pa64.c
===================================================================
--- gdb-head.orig/gdb/solib-pa64.c
+++ gdb-head/gdb/solib-pa64.c
@@ -36,6 +36,7 @@
 #include "gdbcore.h"
 #include "target.h"
 #include "inferior.h"
+#include "regcache.h"
 
 #include "hppa-tdep.h"
 #include "solist.h"
@@ -421,7 +422,8 @@ pa64_solib_create_inferior_hook (void)
 
 	 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;
       
Index: gdb-head/gdb/solib-sunos.c
===================================================================
--- gdb-head.orig/gdb/solib-sunos.c
+++ gdb-head/gdb/solib-sunos.c
@@ -791,7 +791,7 @@ sunos_solib_create_inferior_hook (void)
   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 ())
Index: gdb-head/gdb/solib-svr4.c
===================================================================
--- gdb-head.orig/gdb/solib-svr4.c
+++ gdb-head/gdb/solib-svr4.c
@@ -32,6 +32,7 @@
 #include "gdbcore.h"
 #include "target.h"
 #include "inferior.h"
+#include "regcache.h"
 #include "gdbthread.h"
 
 #include "gdb_assert.h"
@@ -1289,8 +1290,11 @@ enable_break (void)
          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)
 	{
@@ -1424,7 +1428,8 @@ static void
 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
Index: gdb-head/gdb/symfile.c
===================================================================
--- gdb-head.orig/gdb/symfile.c
+++ gdb-head/gdb/symfile.c
@@ -37,7 +37,8 @@
 #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"
@@ -1986,7 +1987,7 @@ generic_load (char *args, int from_tty)
   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
Index: gdb-head/gdb/thread.c
===================================================================
--- gdb-head.orig/gdb/thread.c
+++ gdb-head/gdb/thread.c
@@ -852,7 +852,7 @@ switch_to_thread (ptid_t ptid)
   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;
 }
Index: gdb-head/gdb/tracepoint.c
===================================================================
--- gdb-head.orig/gdb/tracepoint.c
+++ gdb-head/gdb/tracepoint.c
@@ -224,15 +224,17 @@ set_tracepoint_num (int num)
    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;
@@ -248,6 +250,7 @@ set_traceframe_context (CORE_ADDR trace_
     }
 
   /* 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);
 
@@ -1319,7 +1322,7 @@ trace_start_command (char *args, int fro
 	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);
@@ -1447,12 +1450,10 @@ finish_tfind_command (char **msg,
 		      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);
@@ -1517,9 +1518,9 @@ finish_tfind_command (char **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)
     {
@@ -1529,18 +1530,10 @@ finish_tfind_command (char **msg,
          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.
+         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 ())))
+      if (frame_id_eq (old_frame_id,
+		       get_frame_id (get_current_frame ())))
 	print_what = SRC_LINE;
       else
 	print_what = SRC_AND_LOC;
@@ -1635,7 +1628,7 @@ trace_find_pc_command (char *args, int f
   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);
 
Index: gdb-head/gdb/infcmd.c
===================================================================
--- gdb-head.orig/gdb/infcmd.c
+++ gdb-head/gdb/infcmd.c
@@ -392,7 +392,7 @@ post_create_inferior (struct target_ops 
   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.  */
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]