From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17041 invoked by alias); 21 Sep 2010 23:43:35 -0000 Received: (qmail 17032 invoked by uid 22791); 21 Sep 2010 23:43:35 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Sep 2010 23:43:30 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8LNhTWT020860 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 21 Sep 2010 19:43:29 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8LNhQCt016250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 21 Sep 2010 19:43:28 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o8LNhQvN024685 for ; Wed, 22 Sep 2010 01:43:26 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o8LNhPA8024683 for gdb-patches@sourceware.org; Wed, 22 Sep 2010 01:43:25 +0200 Date: Wed, 22 Sep 2010 09:43:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [rfc] linux-nat: Never PTRACE_CONT a stepping thread Message-ID: <20100921234325.GA31267@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00367.txt.bz2 Hi, as referenced in: [patch 3/4]#3 linux-nat: Do not respawn signals http://sourceware.org/ml/gdb-patches/2010-09/msg00360.html If multiple signals happen besides SIGTRAP GDB still may switch from thread A away (as not considering it stepping) to thread B for SIGUSR1 and accidentally PTRACE_CONT thread A while resignalling SIGUSR1. It probably could have its own testcase. I will code one depending on the resolution of the #3 series above. No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. Thanks, Jan gdb/ 2010-09-20 Jan Kratochvil * gdbthread.h (currently_stepping): New declaration. * infrun.c (currently_stepping): Remove the forward declaration. (currently_stepping): Make it global. * linux-nat.c (resume_callback) stopped && lp->status == 0>: New variables tp and step, initialized them. Pass STEP to to_resume. Print also possibly "PTRACE_SINGLESTEP" if STEP. Initialize LP->STEP. diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index cd24eaf..e89e88d 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -352,4 +352,6 @@ extern struct thread_info* inferior_thread (void); extern void update_thread_list (void); +extern int currently_stepping (struct thread_info *tp); + #endif /* GDBTHREAD_H */ diff --git a/gdb/infrun.c b/gdb/infrun.c index 0720b31..8afdd77 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -74,8 +74,6 @@ static int follow_fork (void); static void set_schedlock_func (char *args, int from_tty, struct cmd_list_element *c); -static int currently_stepping (struct thread_info *tp); - static int currently_stepping_or_nexting_callback (struct thread_info *tp, void *data); @@ -4842,7 +4840,7 @@ infrun: not switching back to stepped thread, it has vanished\n"); /* Is thread TP in the middle of single-stepping? */ -static int +int currently_stepping (struct thread_info *tp) { return ((tp->step_range_end && tp->step_resume_breakpoint == NULL) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index a0eca0e..69b9a5f 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1820,20 +1820,26 @@ resume_callback (struct lwp_info *lp, void *data) } else if (lp->stopped && lp->status == 0) { + struct thread_info *tp = find_thread_ptid (lp->ptid); + /* lp->step may already contain a stale value. */ + int step = tp ? currently_stepping (tp) : 0; + if (debug_linux_nat) fprintf_unfiltered (gdb_stdlog, - "RC: PTRACE_CONT %s, 0, 0 (resuming sibling)\n", + "RC: %s %s, 0, 0 (resuming sibling)\n", + step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT", target_pid_to_str (lp->ptid)); linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), - 0, TARGET_SIGNAL_0); + step, TARGET_SIGNAL_0); if (debug_linux_nat) fprintf_unfiltered (gdb_stdlog, - "RC: PTRACE_CONT %s, 0, 0 (resume sibling)\n", + "RC: %s %s, 0, 0 (resume sibling)\n", + step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT", target_pid_to_str (lp->ptid)); lp->stopped = 0; - lp->step = 0; + lp->step = step; memset (&lp->siginfo, 0, sizeof (lp->siginfo)); lp->stopped_by_watchpoint = 0; }