This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [unavailable values part 1, 01/17] base support for unavailable value contents


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]