Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: Thiago Jung Bauermann <bauerman@br.ibm.com>
Cc: gdb-patches@sourceware.org,
	Jan Kratochvil <jan.kratochvil@redhat.com>,
	Joel Brobecker <brobecker@adacore.com>,
	Eli Zaretskii <eliz@gnu.org>
Subject: Re: [patch 2/3] Implement support for PowerPC BookE ranged watchpoints
Date: Tue, 28 Dec 2010 16:10:00 -0000	[thread overview]
Message-ID: <201012281529.18162.pedro@codesourcery.com> (raw)
In-Reply-To: <1293484743.1544.78.camel@hactar>

On Monday 27 December 2010 21:19:03, Thiago Jung Bauermann wrote:

> @@ -1394,25 +1397,33 @@ update_watchpoint (struct breakpoint *b, int reparse)
>         if ((b->type == bp_watchpoint || b->type == bp_hardware_watchpoint)
>             && reparse)
>           {
> -           int i, mem_cnt, other_type_used;
> -
> -           /* We need to determine how many resources are already used
> -              for all other hardware watchpoints to see if we still have
> -              enough resources to also fit this watchpoint in as well.
> -              To avoid the hw_watchpoint_used_count call below from counting
> -              this watchpoint, make sure that it is marked as a software
> -              watchpoint.  */
> -           b->type = bp_watchpoint;
> -           i = hw_watchpoint_used_count (bp_hardware_watchpoint,
> -                                         &other_type_used);
> -           mem_cnt = can_use_hardware_watchpoint (val_chain);
> -
> -           if (!mem_cnt)
> +           int reg_cnt;
> +
> +           reg_cnt = can_use_hardware_watchpoint (val_chain, b->exact);
> +
> +           if (!reg_cnt)
>               b->type = bp_watchpoint;
>             else
>               {
> -               int target_resources_ok = target_can_use_hardware_watchpoint
> -                 (bp_hardware_watchpoint, i + mem_cnt, other_type_used);
> +               int i, other_type_used, target_resources_ok;
> +               enum bptype orig_type;
> +
> +               if (b->ops && b->ops->extra_resources_needed)
> +                 reg_cnt += b->ops->extra_resources_needed (b, NULL);

I'm taking a look at the resource accounting changes, which I
mostly ignored before, and I'm confused.  can_use_hardware_watchpoint
(above) calls target_region_ok_for_hw_watchpoint, which has been changed
to return the number of resources normally necessary.  Yet,
extra_resources_needed_watchpoint calls target_region_ok_for_hw_watchpoint
as well (discounting 1, it seems).  Aren't we ending up with gdb
thinking it needs more resources than are really necessary?

> +
> +               /* We need to determine how many resources are already used
> +                  for all other hardware watchpoints to see if we still have
> +                  enough resources to also fit this watchpoint in as well.
> +                  To avoid the hw_watchpoint_used_count call below from
> +                  counting this watchpoint, make sure that it is marked as a
> +                  software watchpoint.  */
> +               orig_type = b->type;
> +               b->type = bp_watchpoint;

Something I notice: It sounds like if you remove this hack above, 

> +               i = hw_watchpoint_used_count (bp_hardware_watchpoint,
> +                                             &other_type_used);

then this above accounts for the new watchpoint too, so...

> +
> +               target_resources_ok = target_can_use_hardware_watchpoint
> +                 (bp_hardware_watchpoint, i + reg_cnt, other_type_used)

... this would just be ", i,", instead of ", i + reg_cnt,".

>                 if (target_resources_ok <= 0)
>                   b->type = bp_watchpoint;
>                 else

> > What does the "TYPE_NFIELDS (t) == 1" do ?
> 
> TYPE_NFIELDS (t) == 1 && TYPE_CODE (TYPE_INDEX_TYPE (t)) == TYPE_CODE_RANGE
> is a way to determine that the given array type has known bounds.

Didn't know about that.  I thought TYPE_NFIELDS only made sense
for structs/classes/unions.  My grep foo isn't finding other similar uses.

I tried:

 compunit1.c:
 extern int array[];

 void foo ()
 {
 ...
 }

 compunit2.c:

 int array[];

and in foo, ptype array gave me array[0], TYPE_NFIELDS==1.

> > Should be "Use of exact watchpoints is ...", I think?  Thus getting rid
> > of the small lie that not all watchpoints (in the user perspective) will
> > use just one debug register, leaving the just one debug register
> > issue explanation to the help string (as you already have).
> 
> Good point. Changed to:

(...)

Thanks.

-- 
Pedro Alves


  parent reply	other threads:[~2010-12-28 15:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-23 21:52 Thiago Jung Bauermann
2010-11-23 23:17 ` Pedro Alves
2010-11-24 21:06   ` Thiago Jung Bauermann
2010-11-25 17:32     ` Pedro Alves
2010-11-26 11:09       ` Eli Zaretskii
2010-11-27 13:25         ` Thiago Jung Bauermann
2010-11-27 15:28           ` Eli Zaretskii
2010-11-26 21:15       ` Thiago Jung Bauermann
2010-11-27 17:47         ` Pedro Alves
2010-11-27 18:01           ` Pedro Alves
2010-12-09  1:44           ` Thiago Jung Bauermann
2010-12-23 19:07           ` Thiago Jung Bauermann
2010-12-23 19:13             ` Eli Zaretskii
2010-12-23 20:17               ` Thiago Jung Bauermann
2010-12-23 22:18             ` Pedro Alves
2010-12-24  5:10               ` Joel Brobecker
2010-12-25 14:13               ` Eli Zaretskii
2010-12-27 20:18                 ` Thiago Jung Bauermann
2010-12-28  2:30               ` Thiago Jung Bauermann
2010-12-28  5:47                 ` Joel Brobecker
2010-12-28 16:42                   ` Pedro Alves
2010-12-28 16:10                 ` Pedro Alves [this message]
2010-12-29  1:00                   ` Thiago Jung Bauermann
2010-11-26 10:59 ` Eli Zaretskii

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=201012281529.18162.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=bauerman@br.ibm.com \
    --cc=brobecker@adacore.com \
    --cc=eliz@gnu.org \
    --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