From: Tom Tromey <tromey@redhat.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [unavailable values part 1, 01/17] base support for unavailable value contents
Date: Mon, 07 Feb 2011 15:47:00 -0000 [thread overview]
Message-ID: <m3y65rzw1a.fsf@fleche.redhat.com> (raw)
In-Reply-To: <201102071427.55970.pedro@codesourcery.com> (Pedro Alves's message of "Mon, 7 Feb 2011 14:27:55 +0000")
>>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:
Pedro> Python pretty-printing does not yet know what to do
Pedro> to unavailable values, so this disables it. Does not mean
Pedro> someone can't add it later.
Could you file a bug report for this?
I think it may be fine to just leave out this change, but I am not
positive.
Pedro> +/* Returns true if RANGES contains any range that overlaps [OFFSET,
Pedro> + OFFSET+LENGTH). */
Pedro> +
Pedro> +static int
Pedro> +ranges_contain_p (VEC(range_s) *ranges, int offset, int length)
Pedro> +{
Pedro> + int i;
Pedro> + range_s *r;
Pedro> +
Pedro> + for (i = 0; VEC_iterate (range_s, ranges, i, r); i++)
Pedro> + if (ranges_overlap (r->offset, r->length,
Pedro> + offset, length))
Pedro> + return 1;
Pedro> +
Pedro> + return 0;
Pedro> +}
Pedro> +
It seems to me that since the ranges are sorted by starting address, and
coalesced overlap, then you could use a binary search here, aka
VEC_lower_bound. It may not be worth doing though.
Pedro> +static VEC(range_s) *
Pedro> +ranges_copy (VEC(range_s) *ranges)
Pedro> +{
Pedro> + int i;
Pedro> + range_s *r;
Pedro> + VEC(range_s) *copy = NULL;
Pedro> +
Pedro> + for (i = 0; VEC_iterate (range_s, ranges, i, r); i++)
Pedro> + VEC_safe_push (range_s, copy, r);
It is slightly more memory-efficient to grow the copy vector to the
right size and then quick_push the elements.
Pedro> + /* Insert the range sorted. If there's overlap or the new range
Pedro> + would be contiguous with an existing range, merge. */
This could also use a binary search. Again, maybe not worth the effort.
Tom
next prev parent reply other threads:[~2011-02-07 15:47 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 [this message]
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
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=m3y65rzw1a.fsf@fleche.redhat.com \
--to=tromey@redhat.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