OSDN Git Service

Fix thread related problem for am33 software singlestep.
authorkevinb <kevinb>
Wed, 9 Nov 2005 02:08:12 +0000 (02:08 +0000)
committerkevinb <kevinb>
Wed, 9 Nov 2005 02:08:12 +0000 (02:08 +0000)
rda/unix/ChangeLog
rda/unix/linux-target.c

index 50562eb..0ab1a71 100644 (file)
@@ -1,5 +1,11 @@
 2005-11-08  Kevin Buettner  <kevinb@redhat.com>
 
+       * linux-target.c (am33_singlestep_okay): Use `pid', not
+       `process->pid' when reading and writing memory since the
+       latter may refer to an already running thread.
+
+2005-11-08  Kevin Buettner  <kevinb@redhat.com>
+
        * diagnostics.h: New file.
        * gdbserv-thread-db.h (debug_get_pc): Move declaration to new
        file diagnostics.h.
index 609dca8..a2bcdf6 100644 (file)
@@ -3694,6 +3694,7 @@ am33_singlestep (struct gdbserv *serv, pid_t pid, int sig)
   int displ;
   static char bp_inst = 0xff;
   static int hw_singlestep_okay = 1;
+  pid_t save_pid;
 
   if (hw_singlestep_okay)
     {
@@ -3719,6 +3720,12 @@ am33_singlestep (struct gdbserv *serv, pid_t pid, int sig)
       /* Fall through into software singlestep code.  */
     }
 
+  /* In a multi-threaded program, process->pid might be a running thread
+     and we can't read / write into running threads.  So set process->pid
+     to the lwp.  */
+  save_pid = process->pid;
+  process->pid = pid;
+
   pc = am33_get_register (serv, pid, PC_REGNUM);
   opcode = am33_read_byte (serv, pc);
 
@@ -3910,6 +3917,9 @@ am33_singlestep (struct gdbserv *serv, pid_t pid, int sig)
   if (errno)
     fprintf (stderr, "PTRACE_CONT (am33) error: %s in %d\n",
             strerror (errno), pid);
+
+  /* Restore the saved pid.  */
+  process->pid = save_pid;
 }
 #endif