From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4013 invoked by alias); 19 Nov 2001 19:58:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.cygnus.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 3898 invoked from network); 19 Nov 2001 19:57:57 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sourceware.cygnus.com with SMTP; 19 Nov 2001 19:57:57 -0000 Received: from cse.cygnus.com (cse.cygnus.com [205.180.230.236]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id LAA23960 for ; Mon, 19 Nov 2001 11:57:55 -0800 (PST) Received: (from kev@localhost) by cse.cygnus.com (8.9.3/8.9.3) id MAA16447 for gdb-patches@sources.redhat.com; Mon, 19 Nov 2001 12:57:35 -0700 Date: Wed, 07 Nov 2001 16:06:00 -0000 From: Kevin Buettner Message-Id: <1011119195735.ZM16446@ocotillo.lan> X-Mailer: Z-Mail (4.0.1 13Jan97 Caldera) To: gdb-patches@sources.redhat.com Subject: [PATCH RFA] lin-lwp.c: Mark main thread as stopped when attaching MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2001-11/txt/msg00124.txt.bz2 The patch below marks the main pid as stopped when attaching. If it is not marked as such, then it is not (re)started when continuing if the user first changes the current thread. The practical effects of this problem may be demonstrated on a Linux/x86 sytem as follows: 1) Start the linux-dp program and make note of the process id of the main thread. 2) Debug the linux-dp program and attach to PID representing the main thread. 3) Do ``info threads'' and pick out a thread other than the main one. 4) Use GDB's ``thread'' command to switch to this thread. 5) Continue the program. 6) Attempt to interrupt the program with Ctrl-C. It will be impossible to do so. (Examining the threads from another shell with the ``ps'' command is also instructive at this stage.) Jim Blandy deserves credit for arriving at the above procedure for reproducing this problem. The patch below fixes this bug. Okay to commit? * lin-lwp.c (lin_lwp_attach_lwp): Mark main thread as stopped. Index: lin-lwp.c =================================================================== RCS file: /cvs/src/src/gdb/lin-lwp.c,v retrieving revision 1.30 diff -u -p -r1.30 lin-lwp.c --- lin-lwp.c 2001/10/14 11:30:37 1.30 +++ lin-lwp.c 2001/11/19 19:08:10 @@ -381,6 +389,12 @@ lin_lwp_attach_lwp (ptid_t ptid, int ver gdb_assert (pid == GET_LWP (ptid) && WIFSTOPPED (status) && WSTOPSIG (status)); + lp->stopped = 1; + } + else + { + /* Mark original process (i.e. the one whose LWP id is equal to + the overall process id) as stopped too. */ lp->stopped = 1; } }