From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>,
Tom Tromey <tromey@redhat.com>
Subject: Re: [unavailable values part 1, 01/17] base support for unavailable value contents
Date: Mon, 14 Feb 2011 13:18:00 -0000 [thread overview]
Message-ID: <201102141259.11583.pedro@codesourcery.com> (raw)
In-Reply-To: <20110214115919.GA2454@host1.dyn.jankratochvil.net>
Hi Jan. Thanks for thorough review of the whole series.
As you'll see, I checked it in just before you sent
your comments. :-/
On Monday 14 February 2011 11:59:19, Jan Kratochvil wrote:
> On Thu, 10 Feb 2011 20:30:26 +0100, Pedro Alves wrote:
> > +/* Defines an [OFFSET, OFFSET + LENGTH) range. */
> > +
> > +struct range
> > +{
> > + /* Lowest offset in the range. */
> > + int offset;
> > +
> > + /* Length of the range. */
> > + int length;
> > +};
>
> I would find [LOW, HIGH) fields more readable as the code now still calculates
> offset + length back and forth all over the code. FYI, not trying to require
> it, though.
Maybe. I just picked an option and sticked to it. I don't
know if [LOW, HIGH] wouldn't make `high - low' appear all over.
>
> > +/* Returns true if RANGES contains any range that overlaps [OFFSET,
> > + OFFSET+LENGTH). */
> > +
> > +static int
> > +ranges_contain_p (VEC(range_s) *ranges, int offset, int length)
>
> Couldn't even this function stick with the `overlap' term?
I guess it could. There's already a ranges_overlap function
though. I'm open to concrete suggestions, though IMO this
isn't worth the bother.
>
> `contain' associates to me:
> Returns true if each byte of [OFFSET, OFFSET+LENGTH) is overlapping with any
> range in the RANGES list.
>
> (My English association may not be right, though.)
>
>
> > @@ -206,6 +310,11 @@ struct value
> > + /* Unavailable ranges in CONTENTS. We mark unavailable ranges,
> > + rather than available, since the common and default case is for a
> > + value to be available. This is filled in at value read time. */
> > + VEC(range_s) *unavailable;
>
> Was there considered the opposite way to have a list of available ranges?
As is written on the comment above, the default and most common case,
which is whenever you are not inspecting a value that came from
a traceframe, you'll have the value wholly available. That means
we can just leave the value->unavailable VEC empty/NULL in most cases.
If we switch the logic, we need to always allocate the VEC with a single
range covering the whole contents, and then punch holes as we
find them. As that's more wasteful in terms of memory, I opted
for the current logic. Or maybe we could special case the empty
case as meaning all-available? It might work. Not sure it'd end
up looking simpler, given the punch-holes need.
> it would also enable storing discontiguous memory with
> a value.
Can't see why you can't keep the "unavailable" ranges logic
even if we store discontiguous memory in values. I haven't
looked at your code yet though.
> > + i = VEC_lower_bound (range_s, value->unavailable, &newr, range_lessthan);
> > + if (i > 0)
> > + {
> > + struct range *bef = VEC_index (range_s, value->unavailable, i - i);
>
> While this patch revisiou fixed two bugs
> it has introduced a new bug - "i - i" -> "i - 1".
Bummer. I did a bunch of unit testing with a hack
that called mark_value_bytes_unavailable in different combinations
and then checked the VEC for expected results, and this still made
it through....
Fixed now, as below...
--
Pedro Alves
2011-02-14 Pedro Alves <pedro@codesourcery.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
gdb/
* value.c (mark_value_bytes_unavailable): Fix indexing the `bef'
range.
---
gdb/value.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: src/gdb/value.c
===================================================================
--- src.orig/gdb/value.c 2011-02-14 11:51:57.000000000 +0000
+++ src/gdb/value.c 2011-02-14 12:43:22.691772006 +0000
@@ -439,7 +439,7 @@ mark_value_bytes_unavailable (struct val
i = VEC_lower_bound (range_s, value->unavailable, &newr, range_lessthan);
if (i > 0)
{
- struct range *bef = VEC_index (range_s, value->unavailable, i - i);
+ struct range *bef = VEC_index (range_s, value->unavailable, i - 1);
if (ranges_overlap (bef->offset, bef->length, offset, length))
{
next prev parent reply other threads:[~2011-02-14 12:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-07 14:28 Pedro Alves
2011-02-07 15:47 ` Tom Tromey
2011-02-10 18:46 ` Pedro Alves
2011-02-10 19:30 ` Pedro Alves
2011-02-14 11:59 ` Jan Kratochvil
2011-02-14 13:18 ` Pedro Alves [this message]
2011-02-14 17:28 ` Jan Kratochvil
2011-02-11 21:11 ` Tom Tromey
2011-02-14 11:45 ` Pedro Alves
2011-02-08 4:17 ` Joel Brobecker
2011-02-10 18:53 ` 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=201102141259.11583.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--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