From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26627 invoked by alias); 7 Feb 2011 15:47:47 -0000 Received: (qmail 26619 invoked by uid 22791); 7 Feb 2011 15:47:46 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 Feb 2011 15:47:41 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p17FlVWQ011386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 7 Feb 2011 10:47:31 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p17FlVZm003111; Mon, 7 Feb 2011 10:47:31 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p17FlUoc020431; Mon, 7 Feb 2011 10:47:30 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id D5798378326; Mon, 7 Feb 2011 08:47:29 -0700 (MST) From: Tom Tromey To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [unavailable values part 1, 01/17] base support for unavailable value contents References: <201102071427.55970.pedro@codesourcery.com> Date: Mon, 07 Feb 2011 15:47:00 -0000 In-Reply-To: <201102071427.55970.pedro@codesourcery.com> (Pedro Alves's message of "Mon, 7 Feb 2011 14:27:55 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00161.txt.bz2 >>>>> "Pedro" == Pedro Alves 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