Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: pedro@codesourcery.com (Pedro Alves)
Cc: gdb-patches@sourceware.org
Subject: Watchpoint resource accounting broken (Re: [5/6] breakpoints_ops for all kinds of breakpoints: new watchpoints instance type)
Date: Mon, 12 Sep 2011 15:06:00 -0000	[thread overview]
Message-ID: <201109121503.p8CF3JCD003396@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <201107221645.06432.pedro@codesourcery.com> from "Pedro Alves" at Jul 22, 2011 04:45:06 PM

Pedro Alves wrote:

> 	(watch_command_1): Allocate and initialize a struct watchpoint
> 	instead of a struct breakpoint.  Use install_breakpoint.

>    /* Now set up the breakpoint.  */
> +
> +  w = XCNEW (struct watchpoint);
> +  b = &w->base;
>    if (use_mask)
> -    b = set_raw_breakpoint_without_location (NULL, bp_type,
> -					     &masked_watchpoint_breakpoint_ops);
> +    init_raw_breakpoint_without_location (b, NULL, bp_type,
> +					  &masked_watchpoint_breakpoint_ops);
>    else
> -    b = set_raw_breakpoint_without_location (NULL, bp_type,
> -					     &watchpoint_breakpoint_ops);
> +    init_raw_breakpoint_without_location (b, NULL, bp_type,
> +					  &watchpoint_breakpoint_ops);
[snip]
> @@ -9153,7 +9247,7 @@ watch_command_1 (char *arg, int accessfl
>      {
>        /* Finally update the new watchpoint.  This creates the locations
>  	 that should be inserted.  */
> -      update_watchpoint (b, 1);
> +      update_watchpoint (w, 1);
>      }
>    if (e.reason < 0)
>      {
> @@ -9161,15 +9255,7 @@ watch_command_1 (char *arg, int accessfl
>        throw_exception (e);
>      }
>  
> -  set_breakpoint_number (internal, b);
> -
> -  /* Do not mention breakpoints with a negative number, but do
> -     notify observers.  */
> -  if (!internal)
> -    mention (b);
> -  observer_notify_breakpoint_created (b);
> -
> -  update_global_location_list (1);
> +  install_breakpoint (internal, b);
>  }

Unfortunately this change breaks watchpoint resource accounting.
Note that in the old version, the watchpoint had already been
added to the breakpoint list (by set_raw_breakpoint_without_location)
*before* the call to update_watchpoint, while in the new version
the watchpoint is added *after* that call (by install_breakpoint).

However, update_watchpoint relies on having the watchpoint under
investigation be on the breakpoint list; see the comment:

              /* We need to determine how many resources are already
                 used for all other hardware watchpoints plus this one
                 to see if we still have enough resources to also fit
                 this watchpoint in as well.  To guarantee the
                 hw_watchpoint_used_count call below counts this
                 watchpoint, make sure that it is marked as a hardware
                 watchpoint.  */
              if (b->base.type == bp_watchpoint)
                b->base.type = bp_hardware_watchpoint;

              i = hw_watchpoint_used_count (b->base.type, &other_type_used);
              target_resources_ok = target_can_use_hardware_watchpoint
                    (b->base.type, i, other_type_used);

Note how just "i", the result of hw_watchpoint_used_count, is passed to
target_can_use_hardware_watchpoint -- this works only if the current
watchpoint is on the list that hw_watchpoint_used_count iterates over.

(You cannot just consider the current watchpoint in addition to the
result of hw_watchpoint_used_count either, because for other callers
to update_watchpoint, the current watchpoint *is* on the list.)

I'm sure sure how best to fix this; maybe go back to adding the
watchpoint to the breakpoint list earlier?

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


  parent reply	other threads:[~2011-09-12 15:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-22 15:58 [5/6] breakpoints_ops for all kinds of breakpoints: new watchpoints instance type Pedro Alves
2011-07-27 10:11 ` Edjunior Barbosa Machado
2011-09-12 15:06 ` Ulrich Weigand [this message]
2011-09-12 15:17   ` Watchpoint resource accounting broken (Re: [5/6] breakpoints_ops for all kinds of breakpoints: new watchpoints instance type) Pedro Alves
2011-09-12 15:23   ` Edjunior Barbosa Machado
2011-09-13 14:16     ` Pedro Alves
2011-09-13 14:42       ` Edjunior Barbosa Machado
2011-09-13 14:54         ` Pedro Alves
2011-09-13 16:49       ` Watchpoint resource accounting broken (Re: [5/6] breakpoints_ops for all kinds of breakpoints: new watchpoints instance type Ulrich Weigand
2011-09-13 17:20         ` Pedro Alves

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=201109121503.p8CF3JCD003396@d06av02.portsmouth.uk.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.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