Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org, Ulrich Weigand <uweigand@de.ibm.com>
Subject: Re: RFC: don't set the pspace on ordinary breakpoints
Date: Thu, 03 Nov 2011 16:02:00 -0000	[thread overview]
Message-ID: <201111031601.51221.pedro@codesourcery.com> (raw)
In-Reply-To: <m3ehxpuwy8.fsf@fleche.redhat.com>

On Thursday 03 November 2011 14:01:19, Tom Tromey wrote:
> >>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:
> 
> Pedro> Thanks.  IMO, the executing_startup change IMO could go in
> Pedro> separately, as soon as it is correct, it looks quite independent.
> Pedro> What prompted it, BTW?
> 
> It seemed wrong to mark an entire breakpoint as "startup disabled" in
> the case where the breakpoint has locations in multiple inferiors.

Ah, indeed.

>  static void
>  bkpt_re_set (struct breakpoint *b)
>  {
> -  /* Do not attempt to re-set breakpoints disabled during startup.  */
> -  if (b->enable_state == bp_startup_disabled)
> -    return;
> -

I'm looking at this one, and thinking that if we simply remove the
guard, we'll allow re-set to go through while we can't trust
symbols/sections in the program space, because they haven't been
relocated yet, but this is wrong (as opposed to just inneficient)
because GDB will actually read memory from the wrong addresses
(prologue skipping, breakpoint shadow, at least).

We can't just make bp_startup_disabled be per-location,
because a re-set could find new locations, defeating the guard.

So I think we'll maybe want this:

 static void
 bkpt_re_set (struct breakpoint *b)
 {
-  /* Do not attempt to re-set breakpoints disabled during startup.  */
-  if (b->enable_state == bp_startup_disabled)
-    return;
+  if (current_program_space->executing_startup)
+    return 0;

And adjust the `current_program_space' reference in the
ambiguous linespec patch to whatever will be necessary then.

and:

@@ -1578,6 +1578,9 @@ should_be_inserted (struct bp_location *bl)
   if (!bl->enabled || bl->shlib_disabled || bl->duplicate)
     return 0;

+   if (!bl->owner->ops->should_be_inserted (bl))
+     return 0;

With the regular breakpoint's (or any other breakpoint that
uses linespecs) implementation of the new should_be_inserted hook
being:

static int
bkpt_should_be_inserted (struct bp_location *bl)
{
  return !bl->pspace->executing_startup;
}

It seems to me that watchpoints shouldn't be
inserted during startup either (can't trust symbols
for the watchpoint's expression either), so maybe my
previous suggestion is indeed good enough:

 @@ -1578,6 +1578,9 @@ should_be_inserted (struct bp_location *bl)
    if (!bl->enabled || bl->shlib_disabled || bl->duplicate)
      return 0;
 
-+  if (bl->pspace->executing_startup)
++  if (user_breakpoint_p (bl->owner) && bl->pspace->executing_startup)
 +    return 0;

Unless we have some user breakpoint kind that would want to 
be inserted in the startup phase.  One such example may simply be
a breakpoint set at a specific address, to debug exactly the
startup phase.  So we'd need:

static int
bkpt_should_be_inserted (struct bp_location *bl)
{
  if (!bl->pspace->executing_startup)
   {
      struct breakpoint *b = bl->owner;

      if (!linespec_is_address (b->addr_string))
        return 0;

      if (b->addr_string_range_end != NULL
          && !linespec_is_address (b->addr_string_range_end))
        return 0;
    }

  return 1;
}

linespec_is_address would return true to linespecs of "*NUMBER" form.
(or if we have a linespec struct, we'd record address-ness there).

-- 
Pedro Alves


  reply	other threads:[~2011-11-03 16:02 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-27 15:32 Tom Tromey
2011-10-31  1:03 ` Jan Kratochvil
2011-10-31 12:07 ` Yao Qi
2011-11-02 18:55 ` Pedro Alves
2011-11-02 19:47   ` Tom Tromey
2011-11-02 20:21     ` Pedro Alves
2011-11-03 14:01       ` Tom Tromey
2011-11-03 16:02         ` Pedro Alves [this message]
2011-11-03 19:33           ` Ulrich Weigand
2011-11-08 19:32           ` Tom Tromey
2011-11-08 20:23             ` Tom Tromey
2011-11-09 18:24               ` Tom Tromey
2011-11-09 18:30               ` Pedro Alves
2011-11-09 18:41                 ` Tom Tromey
2011-11-10 16:53                   ` Tom Tromey
2011-11-10 17:49                     ` Pedro Alves
2011-11-10 17:57                     ` Ulrich Weigand
2011-11-10 19:27                       ` Tom Tromey
2011-11-10 20:23                         ` Tom Tromey
2011-11-11 12:56                           ` Ulrich Weigand
2011-11-11 14:47                             ` Tom Tromey
2011-11-14 21:12                               ` Tom Tromey
2011-11-16 18:37                               ` Ulrich Weigand
2011-11-16 21:24                                 ` Tom Tromey
2011-11-18 18:31                                   ` Ulrich Weigand
2012-01-02 18:18                                     ` [7.4 regression] Stand-alone Cell debugging broken (Re: RFC: don't set the pspace on ordinary breakpoints) Ulrich Weigand
2012-01-03  3:15                                       ` Joel Brobecker
2012-01-03 20:29                                       ` Tom Tromey
2012-01-04 12:36                                         ` Ulrich Weigand

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=201111031601.51221.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    --cc=uweigand@de.ibm.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