From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 999 invoked by alias); 12 Aug 2013 12:24:06 -0000 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 Received: (qmail 980 invoked by uid 89); 12 Aug 2013 12:24:06 -0000 X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_MED,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD autolearn=ham version=3.3.2 Received: from mms1.broadcom.com (HELO mms1.broadcom.com) (216.31.210.17) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 12 Aug 2013 12:24:05 +0000 Received: from [10.9.208.57] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Mon, 12 Aug 2013 05:19:58 -0700 X-Server-Uuid: 06151B78-6688-425E-9DE2-57CB27892261 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.1.438.0; Mon, 12 Aug 2013 05:23:50 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.1.438.0; Mon, 12 Aug 2013 05:23:50 -0700 Received: from [10.177.73.61] (unknown [10.177.73.61]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id AAB35F2D72 for ; Mon, 12 Aug 2013 05:23:49 -0700 (PDT) Message-ID: <5208D3D4.1080100@broadcom.com> Date: Mon, 12 Aug 2013 12:24:00 -0000 From: "Andrew Burgess" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH 05/12] Convert the unavailable to be bit based. References: <5208D1DF.1090201@broadcom.com> In-Reply-To: <5208D1DF.1090201@broadcom.com> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-08/txt/msg00305.txt.bz2 The unavailable vector currently stores byte ranges within the value. However, the optimized out interface allows for bit ranges to be optimized out. This patch changes the unavailable vector to be bit based, and at the same time moves the code that actually inserts into the vector into a helper function. OK to apply? Thanks, Andrew gdb/ChangeLog 2013-08-12 Andrew Burgess * value.c (insert_into_bit_range_vector): New function for inserting into the vector. (mark_value_bytes_unavailable): Use new function to build the unavailable vector in bits rather than bytes. (value_available_contents_eq): Take account of parameters being bytes, but the unavailable range now being in bits. (value_contents_copy_raw): Likewise, change to accommodate the unavailable vector being in bits. (value_bytes_available): Convert byte values to bits. diff --git a/gdb/value.c b/gdb/value.c index 64c9d78..e28c213 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -337,7 +337,9 @@ value_bytes_available (const struct value *value, int offset { gdb_assert (!value->lazy); - return !ranges_contain (value->unavailable, offset, length); + return !ranges_contain (value->unavailable, + offset * TARGET_CHAR_BIT, + length * TARGET_CHAR_BIT); } int @@ -353,8 +353,11 @@ value_entirely_available (struct value *value) return 0; } -void -mark_value_bytes_unavailable (struct value *value, int offset, int length) +/* Insert into the vector pointed to by VECTORP the bit range starting of + OFFSET bits, and extending for the next LENGTH bits. */ + +static void +insert_into_bit_range_vector (VEC(range_s) **vectorp, int offset, int length) { range_s newr; int i; @@ -445,10 +448,10 @@ mark_value_bytes_unavailable (struct value *value, int offset, int length) */ - i = VEC_lower_bound (range_s, value->unavailable, &newr, range_lessthan); + i = VEC_lower_bound (range_s, *vectorp, &newr, range_lessthan); if (i > 0) { - struct range *bef = VEC_index (range_s, value->unavailable, i - 1); + struct range *bef = VEC_index (range_s, *vectorp, i - 1); if (ranges_overlap (bef->offset, bef->length, offset, length)) { @@ -469,18 +472,18 @@ mark_value_bytes_unavailable (struct value *value, int offset, int length) else { /* #3 */ - VEC_safe_insert (range_s, value->unavailable, i, &newr); + VEC_safe_insert (range_s, *vectorp, i, &newr); } } else { /* #4 */ - VEC_safe_insert (range_s, value->unavailable, i, &newr); + VEC_safe_insert (range_s, *vectorp, i, &newr); } /* Check whether the ranges following the one we've just added or touched can be folded in (#5 above). */ - if (i + 1 < VEC_length (range_s, value->unavailable)) + if (i + 1 < VEC_length (range_s, *vectorp)) { struct range *t; struct range *r; @@ -488,11 +491,11 @@ mark_value_bytes_unavailable (struct value *value, int offset, int length) int next = i + 1; /* Get the range we just touched. */ - t = VEC_index (range_s, value->unavailable, i); + t = VEC_index (range_s, *vectorp, i); removed = 0; i = next; - for (; VEC_iterate (range_s, value->unavailable, i, r); i++) + for (; VEC_iterate (range_s, *vectorp, i, r); i++) if (r->offset <= t->offset + t->length) { ULONGEST l, h; @@ -514,10 +517,18 @@ mark_value_bytes_unavailable (struct value *value, int offset, int length) } if (removed != 0) - VEC_block_remove (range_s, value->unavailable, next, removed); + VEC_block_remove (range_s, *vectorp, next, removed); } } +void +mark_value_bytes_unavailable (struct value *value, int offset, int length) +{ + insert_into_bit_range_vector (&value->unavailable, + offset * TARGET_CHAR_BIT, + length * TARGET_CHAR_BIT); +} + /* Find the first range in RANGES that overlaps the range defined by OFFSET and LENGTH, starting at element POS in the RANGES vector, Returns the index into RANGES where such overlapping range was @@ -547,6 +558,12 @@ value_available_contents_eq (const struct value *val1, int offset1, /* See function description in value.h. */ gdb_assert (!val1->lazy && !val2->lazy); + /* The offsets and length parameters are all byte based, but we store the + unavailable data in a bit based list. */ + offset1 *= TARGET_CHAR_BIT; + offset2 *= TARGET_CHAR_BIT; + length *= TARGET_CHAR_BIT; + while (length > 0) { range_s *r1, *r2; @@ -560,9 +577,9 @@ value_available_contents_eq (const struct value *val1, int offset1, /* The usual case is for both values to be completely available. */ if (idx1 == -1 && idx2 == -1) - return (memcmp (val1->contents + offset1, - val2->contents + offset2, - length) == 0); + return (memcmp (val1->contents + (offset1 / TARGET_CHAR_BIT), + val2->contents + (offset2 / TARGET_CHAR_BIT), + (length / TARGET_CHAR_BIT)) == 0); /* The contents only match equal if the available set matches as well. */ else if (idx1 == -1 || idx2 == -1) @@ -595,9 +612,9 @@ value_available_contents_eq (const struct value *val1, int offset1, return 0; /* Compare the _available_ contents. */ - if (memcmp (val1->contents + offset1, - val2->contents + offset2, - l1) != 0) + if (memcmp (val1->contents + (offset1 / TARGET_CHAR_BIT), + val2->contents + (offset2 / TARGET_CHAR_BIT), + (l1 / TARGET_CHAR_BIT)) != 0) return 0; length -= h1; @@ -938,6 +955,7 @@ value_contents_copy_raw (struct value *dst, int dst_offset, { range_s *r; int i; + int src_bit_offset, dst_bit_offset, bit_length; /* A lazy DST would make that this copy operation useless, since as soon as DST's contents were un-lazied (by a later value_contents @@ -956,16 +974,19 @@ value_contents_copy_raw (struct value *dst, int dst_offset, length); /* Copy the meta-data, adjusted. */ + src_bit_offset = src_offset * TARGET_CHAR_BIT; + dst_bit_offset = dst_offset * TARGET_CHAR_BIT; + bit_length = length * TARGET_CHAR_BIT; for (i = 0; VEC_iterate (range_s, src->unavailable, i, r); i++) { ULONGEST h, l; - l = max (r->offset, src_offset); - h = min (r->offset + r->length, src_offset + length); + l = max (r->offset, src_bit_offset); + h = min (r->offset + r->length, src_bit_offset + bit_length); if (l < h) - mark_value_bytes_unavailable (dst, - dst_offset + (l - src_offset), + insert_into_bit_range_vector (&dst->unavailable, + dst_bit_offset + (l - src_bit_offset), h - l); } }