From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 6/6] Return bool from more value methods
Date: Tue, 14 Feb 2023 13:23:36 -0700 [thread overview]
Message-ID: <20230214-submit-more-value-stuff-v1-6-2fb85efbaa72@tromey.com> (raw)
In-Reply-To: <20230214-submit-more-value-stuff-v1-0-2fb85efbaa72@tromey.com>
There are several more value methods that currently return 'int' but
that should return 'bool'. This patch updates these.
---
gdb/value.c | 30 +++++++++++++++---------------
gdb/value.h | 22 +++++++++++-----------
2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/gdb/value.c b/gdb/value.c
index 9e561e28551..1943ef06321 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -69,7 +69,7 @@ struct internal_function
/* Returns true if the ranges defined by [offset1, offset1+len1) and
[offset2, offset2+len2) overlap. */
-static int
+static bool
ranges_overlap (LONGEST offset1, ULONGEST len1,
LONGEST offset2, ULONGEST len2)
{
@@ -83,7 +83,7 @@ ranges_overlap (LONGEST offset1, ULONGEST len1,
/* Returns true if RANGES contains any range that overlaps [OFFSET,
OFFSET+LENGTH). */
-static int
+static bool
ranges_contain (const std::vector<range> &ranges, LONGEST offset,
ULONGEST length)
{
@@ -131,7 +131,7 @@ ranges_contain (const std::vector<range> &ranges, LONGEST offset,
const struct range &bef = *(i - 1);
if (ranges_overlap (bef.offset, bef.length, offset, length))
- return 1;
+ return true;
}
if (i < ranges.end ())
@@ -139,10 +139,10 @@ ranges_contain (const std::vector<range> &ranges, LONGEST offset,
const struct range &r = *i;
if (ranges_overlap (r.offset, r.length, offset, length))
- return 1;
+ return true;
}
- return 0;
+ return false;
}
static struct cmd_list_element *functionlist;
@@ -168,7 +168,7 @@ value::arch () const
return type ()->arch ();
}
-int
+bool
value::bits_available (LONGEST offset, ULONGEST length) const
{
gdb_assert (!m_lazy);
@@ -182,7 +182,7 @@ value::bits_available (LONGEST offset, ULONGEST length) const
|| ranges_contain (m_unavailable, offset, length));
}
-int
+bool
value::bytes_available (LONGEST offset, ULONGEST length) const
{
ULONGEST sign = (1ULL << (sizeof (ULONGEST) * 8 - 1)) / TARGET_CHAR_BIT;
@@ -196,7 +196,7 @@ value::bytes_available (LONGEST offset, ULONGEST length) const
return bits_available (offset * TARGET_CHAR_BIT, length * TARGET_CHAR_BIT);
}
-int
+bool
value::bits_any_optimized_out (int bit_offset, int bit_length) const
{
gdb_assert (!m_lazy);
@@ -204,7 +204,7 @@ value::bits_any_optimized_out (int bit_offset, int bit_length) const
return ranges_contain (m_optimized_out, bit_offset, bit_length);
}
-int
+bool
value::entirely_available ()
{
/* We can only tell whether the whole value is available when we try
@@ -213,13 +213,13 @@ value::entirely_available ()
fetch_lazy ();
if (m_unavailable.empty ())
- return 1;
- return 0;
+ return true;
+ return false;
}
/* See value.h. */
-int
+bool
value::entirely_covered_by_range_vector (const std::vector<range> &ranges)
{
/* We can only tell whether the whole value is optimized out /
@@ -233,10 +233,10 @@ value::entirely_covered_by_range_vector (const std::vector<range> &ranges)
if (t.offset == 0
&& t.length == TARGET_CHAR_BIT * enclosing_type ()->length ())
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/* Insert into the vector pointed to by VECTORP the bit range starting of
@@ -1255,7 +1255,7 @@ value::contents_writeable ()
return contents_raw ();
}
-int
+bool
value::optimized_out ()
{
if (m_lazy)
diff --git a/gdb/value.h b/gdb/value.h
index 5536e00332e..f2a4907ab81 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -487,23 +487,23 @@ struct value
/* Given a value, determine whether the contents bytes starting at
OFFSET and extending for LENGTH bytes are available. This returns
- nonzero if all bytes in the given range are available, zero if any
+ true if all bytes in the given range are available, false if any
byte is unavailable. */
- int bytes_available (LONGEST offset, ULONGEST length) const;
+ bool bytes_available (LONGEST offset, ULONGEST length) const;
/* Given a value, determine whether the contents bits starting at
OFFSET and extending for LENGTH bits are available. This returns
- nonzero if all bits in the given range are available, zero if any
+ true if all bits in the given range are available, false if any
bit is unavailable. */
- int bits_available (LONGEST offset, ULONGEST length) const;
+ bool bits_available (LONGEST offset, ULONGEST length) const;
/* Like bytes_available, but return false if any byte in the
whole object is unavailable. */
- int entirely_available ();
+ bool entirely_available ();
/* Like entirely_available, but return false if any byte in the
whole object is available. */
- int entirely_unavailable ()
+ bool entirely_unavailable ()
{ return entirely_covered_by_range_vector (m_unavailable); }
/* Mark this value's content bytes starting at OFFSET and extending
@@ -514,19 +514,19 @@ struct value
for LENGTH bits as unavailable. */
void mark_bits_unavailable (LONGEST offset, ULONGEST length);
- /* If nonzero, this is the value of a variable which does not actually
+ /* If true, this is the value of a variable which does not actually
exist in the program, at least partially. If the value is lazy,
this may fetch it now. */
- int optimized_out ();
+ bool optimized_out ();
/* Given a value, return true if any of the contents bits starting at
OFFSET and extending for LENGTH bits is optimized out, false
otherwise. */
- int bits_any_optimized_out (int bit_offset, int bit_length) const;
+ bool bits_any_optimized_out (int bit_offset, int bit_length) const;
/* Like optimized_out, but return true iff the whole value is
optimized out. */
- int entirely_optimized_out ()
+ bool entirely_optimized_out ()
{
return entirely_covered_by_range_vector (m_optimized_out);
}
@@ -829,7 +829,7 @@ struct value
/* Returns true if this value is entirely covered by RANGES. If the
value is lazy, it'll be read now. Note that RANGE is a pointer
to pointer because reading the value might change *RANGE. */
- int entirely_covered_by_range_vector (const std::vector<range> &ranges);
+ bool entirely_covered_by_range_vector (const std::vector<range> &ranges);
/* Copy the ranges metadata from this value that overlaps
[SRC_BIT_OFFSET, SRC_BIT_OFFSET+BIT_LENGTH) into DST,
--
2.39.1
next prev parent reply other threads:[~2023-02-14 20:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-14 20:23 [PATCH 0/6] Use bool in value Tom Tromey
2023-02-14 20:23 ` [PATCH 1/6] Change value::m_modifiable to bool Tom Tromey
2023-02-21 14:36 ` Alexandra Petlanova Hajkova
2023-02-14 20:23 ` [PATCH 2/6] Change value::m_lazy " Tom Tromey
2023-02-15 11:53 ` Bruno Larsen
2023-02-15 21:52 ` Tom Tromey
2023-02-14 20:23 ` [PATCH 3/6] Change value::m_initialized " Tom Tromey
2023-02-21 15:10 ` Alexandra Petlanova Hajkova
2023-02-14 20:23 ` [PATCH 4/6] Change value::m_stack " Tom Tromey
2023-02-21 15:30 ` Alexandra Petlanova Hajkova
2023-02-14 20:23 ` [PATCH 5/6] Have value::bits_synthetic_pointer return bool Tom Tromey
2023-02-14 20:23 ` Tom Tromey [this message]
2023-02-15 12:22 ` [PATCH 0/6] Use bool in value Bruno Larsen
2023-02-15 21:54 ` Tom Tromey
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=20230214-submit-more-value-stuff-v1-6-2fb85efbaa72@tromey.com \
--to=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).