From: "Andrew Burgess" <aburgess@broadcom.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 05/12] Convert the unavailable to be bit based.
Date: Mon, 12 Aug 2013 12:24:00 -0000 [thread overview]
Message-ID: <5208D3D4.1080100@broadcom.com> (raw)
In-Reply-To: <5208D1DF.1090201@broadcom.com>
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 <aburgess@broadcom.com>
* 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);
}
}
next prev parent reply other threads:[~2013-08-12 12:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-12 12:15 [RFC 00/12] Merge value optimized_out and unavailable Andrew Burgess
2013-08-12 12:16 ` [PATCH 01/12] Introduce is_unavailable_error Andrew Burgess
2013-08-12 12:18 ` [PATCH 02/12]: Remove set_value_optimized_out Andrew Burgess
2013-08-12 12:20 ` [PATCH 03/12] Mark optimized out values as non-lazy Andrew Burgess
2013-11-26 16:38 ` Pedro Alves
2013-11-26 19:19 ` Andrew Burgess
2013-08-12 12:22 ` [PATCH 04/12] Introduce OPTIMIZED_OUT_ERROR Andrew Burgess
2013-08-12 12:24 ` Andrew Burgess [this message]
2013-08-12 12:27 ` [PATCH 06/12] Delete value_bits_valid Andrew Burgess
2013-11-25 21:41 ` [PATCH] Print entirely unavailable struct/union values as a single <unavailable>. (Re: [PATCH 06/12] Delete value_bits_valid.) Pedro Alves
2013-11-26 10:13 ` Andrew Burgess
2013-11-28 20:14 ` Pedro Alves
2013-08-12 12:28 ` [PATCH 07/12] Generic print unavailable or optimized out function Andrew Burgess
2013-08-12 12:29 ` [PATCH 08/12] Replace some value_optimized_out with value_entirely_available Andrew Burgess
2013-11-27 17:52 ` [COMMITTED PATCH 0/2] "set debug frame 1" and not saved registers (was: Re: [PATCH 08/12] Replace some value_optimized_out with value_entirely_available) Pedro Alves
2013-11-27 18:14 ` [PATCH 1/2] Make "set debug frame 1" use the standard print routine for optimized out values Pedro Alves
2013-11-27 18:35 ` [PATCH 2/2] Make "set debug frame 1" output print <not saved> instead of <optimized out> Pedro Alves
2013-11-27 18:41 ` Pedro Alves
2013-11-27 18:53 ` [pushed] Fix type of not saved registers. (was: Re: [PATCH 2/2] Make "set debug frame 1" output print <not saved> instead of <optimized out>.) Pedro Alves
2013-08-12 12:30 ` [PATCH 09/12] DWARF value, mark unavailable in bits not bytes Andrew Burgess
2013-08-12 12:31 ` [PATCH 10/12] Merge optimized_out into unavailable vector Andrew Burgess
2013-08-12 12:32 ` [PATCH 11/12] Add test mechanism for value " Andrew Burgess
2013-08-12 12:33 ` [PATCH 12/12] Remove old lval check valid functions Andrew Burgess
2013-08-29 17:21 ` PING: Re: [RFC 00/12] Merge value optimized_out and unavailable Andrew Burgess
2013-11-12 9:37 ` Andrew Burgess
2013-11-29 22:31 ` Pedro Alves
2013-12-04 14:54 ` Andrew Burgess
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=5208D3D4.1080100@broadcom.com \
--to=aburgess@broadcom.com \
--cc=gdb-patches@sourceware.org \
/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