From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31556 invoked by alias); 9 Nov 2005 02:10:53 -0000 Mailing-List: contact rda-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: rda-owner@sourceware.org Received: (qmail 31537 invoked by uid 22791); 9 Nov 2005 02:10:49 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 09 Nov 2005 02:10:49 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id jA92AmDM012901 for ; Tue, 8 Nov 2005 21:10:48 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id jA92AmV03303 for ; Tue, 8 Nov 2005 21:10:48 -0500 Received: from localhost.localdomain (vpn50-70.rdu.redhat.com [172.16.50.70]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id jA92AlU4010777 for ; Tue, 8 Nov 2005 21:10:47 -0500 Received: from ironwood.lan (ironwood.lan [192.168.64.8]) by localhost.localdomain (8.12.11/8.12.10) with ESMTP id jA92AgAg009356 for ; Tue, 8 Nov 2005 19:10:42 -0700 Date: Wed, 09 Nov 2005 02:10:00 -0000 From: Kevin Buettner To: rda@sources.redhat.com Subject: [commit] Fix thread related problem for am33 software singlestep Message-ID: <20051108191041.2a994728@ironwood.lan> Organization: Red Hat X-Mailer: Sylpheed-Claws 0.9.12cvs173.1 (GTK+ 2.4.14; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SW-Source: 2005-q4/txt/msg00003.txt.bz2 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; } #endif