Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: [PATCH] PR threads/10729: x86 hw watchpoints and non-stop mode
Date: Wed, 14 Dec 2011 17:42:00 -0000	[thread overview]
Message-ID: <201112141734.43226.pedro@codesourcery.com> (raw)
In-Reply-To: <201112141722.27572.pedro@codesourcery.com>

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  <pedro@codesourcery.com>

	* 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);


  reply	other threads:[~2011-12-14 17:35 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-05 16:46 Pedro Alves
2011-12-05 17:06 ` Eli Zaretskii
2011-12-09 16:30   ` New tests to watch regions larger than a machine word (Re: [PATCH] PR threads/10729: x86 hw watchpoints and non-stop mode) Pedro Alves
2011-12-09 19:11     ` Eli Zaretskii
2011-12-13 16:12       ` Pedro Alves
2011-12-05 21:24 ` [PATCH] PR threads/10729: x86 hw watchpoints and non-stop mode Jan Kratochvil
2011-12-09 16:45   ` Pedro Alves
2011-12-09 16:47     ` Tristan Gingold
2011-12-09 19:23     ` Eli Zaretskii
2011-12-13 16:26       ` Pedro Alves
2011-12-11 23:39     ` Jan Kratochvil
2011-12-12 11:53       ` Pedro Alves
2011-12-12 14:49         ` Jan Kratochvil
2011-12-12  0:14     ` Jan Kratochvil
2011-12-12 17:23       ` Pedro Alves
2011-12-12 18:38         ` Jan Kratochvil
2011-12-12 20:14           ` Jan Kratochvil
2011-12-12 20:30             ` Pedro Alves
2011-12-13 17:24               ` Jan Kratochvil
2011-12-13 18:49                 ` Pedro Alves
2011-12-13 19:25                   ` Jan Kratochvil
2011-12-16 16:16                     ` Pedro Alves
2012-01-20 19:51                       ` testsuite: native/non-extended/extended modes [Re: [PATCH] PR threads/10729: x86 hw watchpoints and non-stop mode] Jan Kratochvil
2012-01-20 19:53                         ` Pedro Alves
2012-01-20 19:57                           ` Jan Kratochvil
2011-12-12 20:34             ` [PATCH] PR threads/10729: x86 hw watchpoints and non-stop mode Pedro Alves
2011-12-12 21:39               ` Jan Kratochvil
2011-12-13 16:21                 ` Fix PR remote/13492 (Re: [PATCH] PR threads/10729: x86 hw watchpoints and non-stop mode) Pedro Alves
2011-12-13 17:23                   ` Fix PR remote/13492 Jan Kratochvil
2011-12-13 16:33                 ` [PATCH] PR threads/10729: x86 hw watchpoints and non-stop mode Pedro Alves
2011-12-13 18:57                   ` Jan Kratochvil
2011-12-14 17:35                     ` Pedro Alves
2011-12-14 17:42                       ` Pedro Alves [this message]
2011-12-15  8:48                         ` Regression for T (Stopped) processes [Re: [PATCH] PR threads/10729: x86 hw watchpoints and non-stop mode] Jan Kratochvil
2011-12-15 12:44                           ` Pedro Alves
2011-12-15 15:33                             ` Jan Kratochvil
2011-12-13 22:27                   ` [PATCH] PR threads/10729: x86 hw watchpoints and non-stop mode Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201112141734.43226.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox