From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21261 invoked by alias); 14 Dec 2011 17:35:08 -0000 Received: (qmail 21073 invoked by uid 22791); 14 Dec 2011 17:35:06 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Dec 2011 17:34:50 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=EU1-MAIL.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1RasjB-0002s0-6l from pedro_alves@mentor.com ; Wed, 14 Dec 2011 09:34:49 -0800 Received: from scottsdale.localnet ([172.16.63.104]) by EU1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 14 Dec 2011 17:34:47 +0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [PATCH] PR threads/10729: x86 hw watchpoints and non-stop mode Date: Wed, 14 Dec 2011 17:42:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-13-generic; KDE/4.7.2; x86_64; ; ) Cc: Jan Kratochvil References: <201112051601.59664.pedro@codesourcery.com> <20111213184923.GA27244@host2.jankratochvil.net> <201112141722.27572.pedro@codesourcery.com> In-Reply-To: <201112141722.27572.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201112141734.43226.pedro@codesourcery.com> 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: 2011-12/txt/msg00458.txt.bz2 On Wednesday 14 December 2011 17:22:27, Pedro Alves wrote: > > On Tue, 13 Dec 2011 17:26:03 +0100, Pedro Alves wrote: > > > +amd64_linux_prepare_to_resume (struct lwp_info *lwp) > > > { > > > - struct lwp_info *lp; > > > + int clear_status = 0; > > > > > > - ALL_LWPS (lp) > > > + if (lwp->arch_private->debug_registers_changed) > > > { > > > - unsigned long value; > > > - > > > - value = amd64_linux_dr_get (lp->ptid, DR_STATUS); > > > - value &= ~mask; > > > - amd64_linux_dr_set (lp->ptid, DR_STATUS, value); > > > + struct i386_debug_reg_state *state = i386_debug_reg_state (); > > > + int i; > > > + > > > + for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++) > > > + if (state->dr_ref_count[i] > 0) > > > + { > > > + amd64_linux_dr_set (lwp->ptid, i, state->dr_mirror[i]); > > > > FYI this way it will leave non-zero DR_FIRSTADDR...DR_LASTADDR after detaching > > from the inferior. This is not a bug, just that it may look as a sort of > > regression. I do not think a fix - clearing them - is required. > > Agreed. But there's actually a related bug here, that I had thought > of fixing, then forgot. GDBserver has this bug too; I'll fix it in a bit. Like below. Now applied. > We need to call prepare_to_resume just before detaching, to clear > the previously active debug registers in DR_CONTROL, otherwise, the > inferior dies with SIGTRAP just after detaching. > > That is: > > (gdb) watch j > or > (gdb) hbreak foo > (gdb) si > watchpoints inserted > (gdb) delete > *deletes the watchpoints from global mirror, but doesn't update the threads' copies.* > (gdb) detach > *inferior trips on old watchpoints -> SIGTRAP death * > gdb/gdbserver/ 2011-12-14 Pedro Alves * linux-low.c (linux_detach_one_lwp): Call the_low_target.prepare_to_resume before detaching. --- gdb/gdbserver/linux-low.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 8afbc8b..43d88fa 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -918,6 +918,8 @@ linux_detach_one_lwp (struct inferior_list_entry *entry, void *args) get_lwp_thread (lwp)); /* Finally, let it resume. */ + if (the_low_target.prepare_to_resume != NULL) + the_low_target.prepare_to_resume (lwp); ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, 0); delete_lwp (lwp);