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] Do not call read_pc in startup_inferior


Hello,

a while ago, I committed a patch to avoid calling wait_for_inferior
in startup_inferior, so as to avoid accessing inferior register state
at a time where the target's actual register layout has not yet been
determined (via target_find_description).

However, startup_inferior still contains a read_pc call to retrieve
the initial value of stop_pc -- this of course runs into the same
problem.

The patch below removes the read_pc call from startup_inferior, and
instead determines the initial stop_pc value in post_create_inferior,
after the register layout has been finalized.

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:

	* fork-child.c (startup_inferior): Move setting stop_pc ...
	* infcmd.c (post_create_inferior): ... to here.


Index: gdb-head/gdb/fork-child.c
===================================================================
--- gdb-head.orig/gdb/fork-child.c
+++ gdb-head/gdb/fork-child.c
@@ -530,8 +530,6 @@ startup_inferior (int ntraps)
 
   /* Mark all threads non-executing.  */
   set_executing (pid_to_ptid (-1), 0);
-
-  stop_pc = read_pc ();
 }
 
 /* Implement the "unset exec-wrapper" command.  */
Index: gdb-head/gdb/infcmd.c
===================================================================
--- gdb-head.orig/gdb/infcmd.c
+++ gdb-head/gdb/infcmd.c
@@ -391,6 +391,9 @@ post_create_inferior (struct target_ops 
      don't need to.  */
   target_find_description ();
 
+  /* Now that we know the register layout, retrieve current PC.  */
+  stop_pc = read_pc ();
+
   /* If the solist is global across processes, there's no need to
      refetch it here.  */
   if (exec_bfd && !gdbarch_has_global_solist (target_gdbarch))
-- 
  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]