From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21682 invoked by alias); 6 Jan 2003 23:44:22 -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 21675 invoked from network); 6 Jan 2003 23:44:20 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by 209.249.29.67 with SMTP; 6 Jan 2003 23:44:20 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h06NGYB04331 for ; Mon, 6 Jan 2003 18:16:34 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h06Ni6n24432; Mon, 6 Jan 2003 18:44:06 -0500 Received: from redhat.com (reddwarf.sfbay.redhat.com [172.16.24.50]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id h06Ni5n23239; Mon, 6 Jan 2003 15:44:05 -0800 Message-ID: <3E1A14C5.77F6C2DF@redhat.com> Date: Mon, 06 Jan 2003 23:44:00 -0000 From: Michael Snyder Organization: Red Hat, Inc. X-Accept-Language: en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com CC: drow@mvista.com, kettenis@chello.nl, jimb@redhat.com, kevinb@redhat.com Subject: [RFC] lin-lwp.c prelim changes for new thread model Content-Type: multipart/mixed; boundary="------------E3F700E6AD301BF008EE6A52" X-SW-Source: 2003-01/txt/msg00244.txt.bz2 This is a multi-part message in MIME format. --------------E3F700E6AD301BF008EE6A52 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-length: 1380 Hi folks, The up and coming kernel (2.4.20, I believe?) and the next glibc (2.3.1) both bring some drastic changes to linux threads. The current gdb thread debugging code will not handle them as is. This is a smallish change that I propose as a preliminary step; it'll get things partly working in the new world, without breaking them in the old. Here's the rationalle. In the old/current model, when one thread gets a signal (such as TRAP), we (gdb) have to call kill (SIGSTOP, pid) for every other thread (excepting the event thread), and then do a waitpid on each of them. In the new model, when one thread gets a signal, we only have to send kill(SIGSTOP, pid) to _one_ thread, and the kernel will then propagate the signal to all of them (_including_ the one that has already stopped with eg. SIGTRAP). We must still do a waitpid on each and every thread -- however, that now _includes_ the one that stopped in the first place (and which we've already done one waitpid on). I know, you're thinking "wasn't this supposed to get simpler?" The minimal change I propose below is as follows: When we send kill(SIGSTOP) to all the threads, we now include the event thread, where previously we had made him a special case. That way, whether in the new model or the old one, we can now do a waitpid on every thread including the event thread. What do you think? Michael --------------E3F700E6AD301BF008EE6A52 Content-Type: text/plain; charset=us-ascii; name="kill.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="kill.diff" Content-length: 2371 2003-01-06 Michael Snyder * lin-lwp.c (lin_lwp_wait): Allow the event thread to receive kill (SIGSTOP) along with everyone else, and do a corresponding waitpid on the event thread. This will help us adapt gdb to work with the new kernel and its different thread model. Index: lin-lwp.c =================================================================== RCS file: /cvs/src/src/gdb/lin-lwp.c,v retrieving revision 1.40 diff -p -r1.40 lin-lwp.c *** lin-lwp.c 6 Jan 2003 23:12:29 -0000 1.40 --- lin-lwp.c 6 Jan 2003 23:14:44 -0000 *************** lin_lwp_wait (ptid_t ptid, struct target *** 1358,1377 **** } } ! /* This LWP is stopped now. */ ! lp->stopped = 1; ! if (debug_lin_lwp) ! fprintf_unfiltered (gdb_stdlog, "LLW: Candidate event %s in %s.\n", ! status_to_str (status), ! target_pid_to_str (lp->ptid)); ! /* Now stop all other LWP's ... */ ! iterate_over_lwps (stop_callback, NULL); ! /* ... and wait until all of them have reported back that they're no ! longer running. */ ! iterate_over_lwps (stop_wait_callback, &flush_mask); /* If we're not waiting for a specific LWP, choose an event LWP from among those that have had events. Giving equal priority to all --- 1358,1388 ---- } } ! /* Stop all other LWPs, if any. */ ! if (!WIFEXITED (status)) /* Can't stop it if it's exited... */ ! { ! if (debug_lin_lwp) ! fprintf_unfiltered (gdb_stdlog, "LLW: Candidate event %s in %s.\n", ! status_to_str (status), ! target_pid_to_str (lp->ptid)); ! /* Now stop all other LWP's ... */ ! iterate_over_lwps (stop_callback, NULL); ! /* The event thread must now be continued, before it can be ! waited again. */ ! errno = 0; ! ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0); ! if (debug_lin_lwp) ! fprintf_unfiltered (gdb_stdlog, ! "LLW: PTRACE_CONT %s, 0, 0 (%s)\n", ! target_pid_to_str (lp->ptid), ! errno ? safe_strerror (errno) : "OK"); ! /* ... and wait until all of them have reported back that they're no ! longer running. */ ! iterate_over_lwps (stop_wait_callback, &flush_mask); ! } /* If we're not waiting for a specific LWP, choose an event LWP from among those that have had events. Giving equal priority to all --------------E3F700E6AD301BF008EE6A52--