This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [unavailable values part 1, 01/17] base support for unavailable value contents
- From: Tom Tromey <tromey at redhat dot com>
- To: Pedro Alves <pedro at codesourcery dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 07 Feb 2011 08:47:29 -0700
- Subject: Re: [unavailable values part 1, 01/17] base support for unavailable value contents
- References: <201102071427.55970.pedro@codesourcery.com>
>>>>> "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