Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@codesourcery.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Doug Evans <dje@google.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH] testsuite: Add (extensive) hardware breakpoint testing
Date: Fri, 11 Nov 2011 18:59:00 -0000	[thread overview]
Message-ID: <alpine.DEB.1.10.1111111812040.4191@tp.orcam.me.uk> (raw)
In-Reply-To: <20111111174247.GF5390@adacore.com>

On Fri, 11 Nov 2011, Joel Brobecker wrote:

> > >  The consistency of failures between i686-linux-gnu and i686-mingw makes
> > > me fairly sure that's a bug in x86 support in GDB of some sort rather than
> > > a problem with my setup -- is that a known bug?
> > 
> > OOC, have you tried amd64-linux?

 I have now, and the result is the same -- breakpoints silently missed.

> > {i386,amd64}-linux are important enough targets that I think this
> > should be fixed for 7.4. Joel?
> 
> I think we should look at the context as well before making a decision:
>   - Is that a regression? If it's been like that in previous versions,
>     then maybe it's OK for it to fail for another version...
>   - Are hardware breakpoints used much? Probably by the people who
>     debug programs in ROM(/flash?).

 Plus self-modifying code -- although I agree that hardware execution 
breakpoints are less needed with hosted systems than on bare-iron targets.  

> We should probably try to investigate the problem quickly and determine
> the extent of the problem. If we think we should fix that for 7.4, and
> someone is willing to take responsibility for it, then let's make it
> a high priority item on our list, and not release 7.4 without the fix.

 Well, OOC I looked at the relevant source and the bug (and consequently 
the fix) is quite obvious -- the debug registers are only actually pushed 
down to hardware on data breakpoints and not execution breakpoints.

 I'm getting:

# of expected passes            69
# of unexpected failures        2

now on x86_64-linux-gnu.  The two failures are some matching problems with 
my hbreak2.exp -- I'll investigate and fix that up.

 OK to apply?

2011-11-11  Maciej W. Rozycki  <macro@codesourcery.com>

	gdb/
	* i386-nat.c (i386_insert_hw_breakpoint): Call 
	i386_update_inferior_debug_regs.
	(i386_remove_hw_breakpoint): Likewise.

  Maciej

gdb-i386-hbreak.diff
Index: gdb-fsf-trunk-quilt/gdb/i386-nat.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/i386-nat.c	2011-11-07 13:42:30.000000000 +0000
+++ gdb-fsf-trunk-quilt/gdb/i386-nat.c	2011-11-11 18:47:40.555635587 +0000
@@ -684,9 +684,15 @@ i386_insert_hw_breakpoint (struct gdbarc
 {
   unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
   CORE_ADDR addr = bp_tgt->placed_address;
-  int retval = i386_insert_aligned_watchpoint (&dr_mirror,
+  /* Work on a local copy of the debug registers, and on success,
+     commit the change back to the inferior.  */
+  struct i386_debug_reg_state local_state = dr_mirror;
+  int retval = i386_insert_aligned_watchpoint (&local_state,
 					       addr, len_rw) ? EBUSY : 0;
 
+  if (retval == 0)
+    i386_update_inferior_debug_regs (&local_state);
+
   if (maint_show_dr)
     i386_show_dr (&dr_mirror, "insert_hwbp", addr, 1, hw_execute);
 
@@ -702,9 +708,15 @@ i386_remove_hw_breakpoint (struct gdbarc
 {
   unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
   CORE_ADDR addr = bp_tgt->placed_address;
-  int retval = i386_remove_aligned_watchpoint (&dr_mirror,
+  /* Work on a local copy of the debug registers, and on success,
+     commit the change back to the inferior.  */
+  struct i386_debug_reg_state local_state = dr_mirror;
+  int retval = i386_remove_aligned_watchpoint (&local_state,
 					       addr, len_rw);
 
+  if (retval == 0)
+    i386_update_inferior_debug_regs (&local_state);
+
   if (maint_show_dr)
     i386_show_dr (&dr_mirror, "remove_hwbp", addr, 1, hw_execute);
 


  reply	other threads:[~2011-11-11 18:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-11 12:13 Maciej W. Rozycki
2011-11-11 17:08 ` Doug Evans
2011-11-11 17:43   ` Joel Brobecker
2011-11-11 18:59     ` Maciej W. Rozycki [this message]
2011-11-12  0:08       ` Pedro Alves
2011-11-14 13:18         ` Maciej W. Rozycki
2011-11-11 20:12   ` Maciej W. Rozycki
2011-12-08 15:33     ` Maciej W. Rozycki
2012-02-27 21:30       ` Ping: " Maciej W. Rozycki
2012-02-28 17:27         ` Pedro Alves
2012-02-28 19:49           ` Maciej W. Rozycki
2012-03-01 11:42             ` Pedro Alves
2012-03-01 21:02               ` Maciej W. Rozycki

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=alpine.DEB.1.10.1111111812040.4191@tp.orcam.me.uk \
    --to=macro@codesourcery.com \
    --cc=brobecker@adacore.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /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