From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13647 invoked by alias); 26 Jun 2002 10:09:29 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 13539 invoked from network); 26 Jun 2002 10:09:22 -0000 Received: from unknown (HELO c000.snv.cp.net) (209.228.32.71) by sources.redhat.com with SMTP; 26 Jun 2002 10:09:22 -0000 Received: (cpmta 22989 invoked from network); 26 Jun 2002 03:09:21 -0700 Received: from 80.63.166.106 (HELO madsen) by smtp.madsen.org (209.228.32.71) with SMTP; 26 Jun 2002 03:09:21 -0700 X-Sent: 26 Jun 2002 10:09:21 GMT From: "Tonny Madsen" To: Cc: Subject: Patch that provides true single step for multi-threaded /proc based processes (Tru64 5.1A) Date: Wed, 26 Jun 2002 03:09:00 -0000 Message-ID: <000001c21cf9$8f15a4f0$0601a8c0@madsen> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01C21D0A.529FFB90" X-Priority: 3 (Normal) X-MSMail-Priority: Normal Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-SW-Source: 2002-06/txt/msg00533.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01C21D0A.529FFB90 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-length: 2200 Howdy everybody, In the company I work for, we use Tru64 5.1A as the main development and deployment platform. The rather poor support for this platform in gdb is the cause of problems and we have devoted some resources to find a solve the most serious og these (as seem by us). Currently we use the mdebugread patch as weel to handle the special sections in native Tru64 5.1A shared libraties. One problem we have been bitten by a number of times was the lack of true single step support for multi-threaded processes. As Tru64 5.1A is /proc based, the functions in question are proc_run_process and procfs_resume. In these functions single step support is only implemented for the new /proc API. Please note that we use multi-CPU machine so we are bitten by this often! The following patch will add support for the ioctl PIOCTRUN (if defined) in proc_run_process. Please comment on this if you see anything wrong with it. I don't know if the patch is general for all /proc based architectures, but I currently expect so. /tonny --- gdb/procfs.c-orig 2002-02-14 02:57:36.000000000 +0100 +++ gdb/procfs.c 2002-06-26 10:16:34.000000000 +0200 @@ -1748,6 +1748,30 @@ win = (write (pi->ctl_fd, (char *) &cmd, sizeof (cmd)) == sizeof (cmd)); } #else /* ioctl method */ +#ifdef PIOCTRUN + /* + * If we single step AND the PIOCTRUN ioctl is supported, then use + * this. This cures the problem when single stepping a + * multi-threaded program, when all the other threads (than the + * current single stepped one), may run free while single stepping. + * + * Note that only the PRSTEP flag is of interrest here (PRCFAULT and + * PRCSIG are not allowed). + */ + if (step) { + /* Structure from proc(4) on Tru64 5.1A. */ + struct { + long pr_count; /* number of threads to run */ + tid_t pr_error_thread; /* set by kernel if error is detected */ + struct prrun thread_1; /* prrun struct, containing thread ID of 1st thread to run in thread_1.pr_tid */ + } prrun; + memset(&prrun, 0, sizeof (prrun)); + prrun.pr_count = 1; + prrun.thread_1.pr_flags = PRSTEP; + prrun.thread_1.pr_tid = pi->prstatus.pr_tid; + win = (ioctl (pi->ctl_fd, PIOCTRUN, &prrun) >= 0); + } else +#endif { prrun_t prrun; ------=_NextPart_000_0001_01C21D0A.529FFB90 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-length: 6112 Message
Howdy=20 everybody,
 
In the co= mpany I=20 work for, we use Tru64 5.1A as the main development and deployment platform= . The=20 rather poor support for this platform in gdb is the cause of problems = and=20 we have devoted some resources to find a solve the most serious og=20 these (as seem by us).
 
Currently= we use the=20 mdebugread patch as weel to handle the special sections in native Tru64 5.1= A=20 shared libraties.
 
One probl= em we have=20 been bitten by a number of times was the lack of true single step support f= or=20 multi-threaded processes. As Tru64 5.1A is /proc based, the functions = in=20 question are proc_run_process and procfs_resume. In these functions single = step=20 support is only implemented for the new /proc API. Please note that we use= =20 multi-CPU machine so we are bitten by this often!
 
The follo= wing patch=20 will add support for the ioctl PIOCTRUN (if defined) in=20 proc_run_process.
 
Please co= mment on=20 this if you see anything wrong with it.
 
I don't k= now if the=20 patch is general for all /proc based architectures, but I currently expect= =20 so.
 
/tonny
 
--- gdb/procfs.c-orig 2002-02-14= =20 02:57:36.000000000 +0100
+++ gdb/procfs.c 2002-06-26=20 10:16:34.000000000 +0200
@@ -1748,6 +1748,30 @@
win =3D (write (pi->ctl_fd, (= char *)=20 &cmd, sizeof (cmd)) =3D=3D sizeof (cmd));
}
#else /* ioctl method */<= /DIV>
+#ifdef PIOCTRUN
+ /*
+ * If we single step AND the PI= OCTRUN=20 ioctl is supported, then use
+ * this. This cures the problem= when=20 single stepping a
+ * multi-threaded program, when= all the=20 other threads (than the
+ * current single stepped one),= may run=20 free while single stepping.
+ *
+ * Note that only the PRSTEP fl= ag is of=20 interrest here (PRCFAULT and
+ * PRCSIG are not allowed).
+ */
+ if (step) {
+ /* Structure from proc(4) on T= ru64=20 5.1A. */
+ struct {
+ long pr_count; /* number of th= reads to=20 run */
+ tid_t pr_error_thread; /* set = by kernel=20 if error is detected */
+ struct prrun thread_1; /* prru= n struct,=20 containing thread ID of 1st thread to run in thread_1.pr_tid */
+ } prrun;
+ memset(&prrun, 0, sizeof=20 (prrun));
+ prrun.pr_count =3D 1;
+ prrun.thread_1.pr_flags =3D=20 PRSTEP;
+ prrun.thread_1.pr_tid =3D=20 pi->prstatus.pr_tid;
+ win =3D (ioctl (pi->ctl_fd,= PIOCTRUN,=20 &prrun) >=3D 0);
+ } else
+#endif
{
prrun_t=20 prrun;

------=_NextPart_000_0001_01C21D0A.529FFB90--