Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [4/4] RFC: implement catch load and catch unload
Date: Fri, 20 Jan 2012 17:40:00 -0000	[thread overview]
Message-ID: <4F1996E6.2030707@redhat.com> (raw)
In-Reply-To: <m3d3afxweq.fsf@fleche.redhat.com>

Handling this piecemeal.

On 01/19/2012 08:35 PM, Tom Tromey wrote:

> * There is a change in internal_bkpt_check_status that is somewhat
>   hacky.  This was the simplest way I could find to make it so that
>   "catch load" reported the catchpoint; without this, bpstat_print would
>   find the internal bp_shlib_event bpstat and print it instead, even if
>   stop-on-solib-events was not set.

Hmm.  Should we ever print if the breakpoint does not cause a stop?  IOW,
can't we make that unconditional if we're also clearing bs->stop?

Related, it looks like there's a bug here:

bpstat_stop_status:

      if (bs->stop)
	{
...
	  /* Print nothing for this entry if we don't stop or don't print.  */
	  if (bs->stop == 0 || bs->print == 0)
	    bs->print_it = print_it_noop;
	}

That "Print nothing" only triggers if we think to stop, and then the
conditions evaluate false, or the breakpoint is silent.  That should
probably be moved out of the `if (bs->stop) condition' above.

Having said that, I've put it in patch form, on top of mainline.  WDYT?

	* breakpoint.c (bpstat_stop_status): Moving clearing print_it
	outside `bs->stop' block.
	(bpstat_what): Rework bp_shlib_event handling.
	(internal_bkpt_check_status): If the breakpoint is a
	bp_shlib_event, then set bs->stop and bs->print if
	stop_on_solib_events is set.
---

 gdb/breakpoint.c |   37 ++++++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f6a0276..3f3a417 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4257,10 +4257,12 @@ bpstat_stop_status (struct address_space *aspace,
 		bs->print = 0;
 	    }

-	  /* Print nothing for this entry if we don't stop or don't print.  */
-	  if (bs->stop == 0 || bs->print == 0)
-	    bs->print_it = print_it_noop;
 	}
+
+      /* Print nothing for this entry if we don't stop or don't
+	 print.  */
+      if (!bs->stop || !bs->print)
+	bs->print_it = print_it_noop;
     }

   /* If we aren't stopping, the value of some hardware watchpoint may
@@ -4341,6 +4343,9 @@ bpstat_what (bpstat bs_head)
       else
 	bptype = bs->breakpoint_at->type;

+      if (bptype == bp_shlib_event)
+	shlib_event = 1;
+
       switch (bptype)
 	{
 	case bp_none:
@@ -4349,6 +4354,7 @@ bpstat_what (bpstat bs_head)
 	case bp_hardware_breakpoint:
 	case bp_until:
 	case bp_finish:
+	case bp_shlib_event:
 	  if (bs->stop)
 	    {
 	      if (bs->print)
@@ -4426,18 +4432,6 @@ bpstat_what (bpstat bs_head)
 		 This requires no further action.  */
 	    }
 	  break;
-	case bp_shlib_event:
-	  shlib_event = 1;
-
-	  /* If requested, stop when the dynamic linker notifies GDB
-	     of events.  This allows the user to get control and place
-	     breakpoints in initializer routines for dynamically
-	     loaded objects (among other things).  */
-	  if (stop_on_solib_events)
-	    this_action = BPSTAT_WHAT_STOP_NOISY;
-	  else
-	    this_action = BPSTAT_WHAT_SINGLE;
-	  break;
 	case bp_jit_event:
 	  jit_event = 1;
 	  this_action = BPSTAT_WHAT_SINGLE;
@@ -11144,8 +11138,17 @@ internal_bkpt_re_set (struct breakpoint *b)
 static void
 internal_bkpt_check_status (bpstat bs)
 {
-  /* We do not stop for these.  */
-  bs->stop = 0;
+  if (bs->breakpoint_at->type == bp_shlib_event)
+    {
+      /* If requested, stop when the dynamic linker notifies GDB of
+	 events.  This allows the user to get control and place
+	 breakpoints in initializer routines for dynamically loaded
+	 objects (among other things).  */
+      bs->stop = stop_on_solib_events;
+      bs->print = stop_on_solib_events;
+    }
+  else
+    bs->stop = 0;
 }

 static enum print_stop_action


  parent reply	other threads:[~2012-01-20 16:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-19 21:03 Tom Tromey
2012-01-19 22:04 ` Eli Zaretskii
2012-01-20 15:12   ` Tom Tromey
2012-01-20 17:40 ` Pedro Alves [this message]
2012-01-24 17:31   ` Tom Tromey
2012-01-24 19:40     ` Pedro Alves
2012-01-20 17:44 ` Yao Qi
2012-01-20 19:45 ` Pedro Alves
2012-01-24 17:07   ` Tom Tromey
2012-01-24 17:28     ` Marc Khouzam
2012-01-24 18:25       ` Tom Tromey
2012-01-24 18:32         ` Marc Khouzam
2012-01-24 19:15           ` Tom Tromey
2012-01-24 20:36             ` Marc Khouzam
2012-01-24 17:22   ` Tom Tromey
2012-01-24 19:17     ` Pedro Alves
2012-01-24 22:11 ` Tom Tromey
2012-01-25 11:06   ` Regression for gdb.mi/mi-nsmoribund.exp [Re: [4/4] RFC: implement catch load and catch unload] Jan Kratochvil
2012-01-25 11:18     ` Regression for gdb.base/solib-disc.exp [Re: Regression for gdb.mi/mi-nsmoribund.exp] Jan Kratochvil
2012-01-25 17:09       ` Tom Tromey
2012-01-25 17:27         ` Jan Kratochvil
2012-01-25 16:20     ` Regression for gdb.mi/mi-nsmoribund.exp [Re: [4/4] RFC: implement catch load and catch unload] Tom Tromey
2012-02-20  8:28   ` [commit] catch-load.exp: Fix racy FAILs " 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=4F1996E6.2030707@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@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