public inbox for
 help / color / mirror / Atom feed
From: Kevin Buettner <>
Subject: [commit] Fix thread related problem for am33 software singlestep
Date: Wed, 09 Nov 2005 02:10:00 -0000	[thread overview]
Message-ID: <20051108191041.2a994728@ironwood.lan> (raw)

I've just committed the patch below.  As indicated by the ChangeLog message,
the am33 software singlestep code was occasionally trying to use the pid
associated with an already running thread for accessing memory.  The
associated ptrace() call would fail when this was attempted.

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

Index: linux-target.c
RCS file: /cvs/src/src/rda/unix/linux-target.c,v
retrieving revision 1.20
diff -u -p -r1.20 linux-target.c
--- linux-target.c	8 Nov 2005 21:58:36 -0000	1.20
+++ linux-target.c	8 Nov 2005 22:19:39 -0000
@@ -3694,6 +3694,7 @@ am33_singlestep (struct gdbserv *serv, p
   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, p
       /* 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, p
   if (errno)
     fprintf (stderr, "PTRACE_CONT (am33) error: %s in %d\n",
 	     strerror (errno), pid);
+  /* Restore the saved pid.  */
+  process->pid = save_pid;

                 reply	other threads:[~2005-11-09  2:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051108191041.2a994728@ironwood.lan \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).