* [PATCH v2 1/2] Use boolean constants in ft32-tdep.c
2026-03-09 13:56 [PATCH v2 0/2] Update some spots that were using bfd_boolean Tom Tromey
@ 2026-03-09 13:56 ` Tom Tromey
2026-03-09 13:56 ` [PATCH v2 2/2] Use store_unsigned_integer in findcmd.c Tom Tromey
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2026-03-09 13:56 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
A couple of spots in ft32-tdep.c are using integer literals where
booleans are more appropriate.
---
gdb/ft32-tdep.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index fc796f44ae1..5a1f3315c7f 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -206,7 +206,7 @@ ft32_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
if (start_addr >= end_addr)
return end_addr;
- cache->established = 0;
+ cache->established = false;
for (next_addr = start_addr; next_addr < end_addr; next_addr += isize)
{
inst = ft32_fetch_instruction (next_addr, &isize, byte_order);
@@ -251,7 +251,7 @@ ft32_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
inst = ft32_fetch_instruction (next_addr, &isize, byte_order);
if (FT32_IS_LINK (inst))
{
- cache->established = 1;
+ cache->established = true;
for (regnum = FT32_R0_REGNUM; regnum < FT32_PC_REGNUM; regnum++)
{
if (cache->saved_regs[regnum] != REG_UNAVAIL)
--
2.49.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 2/2] Use store_unsigned_integer in findcmd.c
2026-03-09 13:56 [PATCH v2 0/2] Update some spots that were using bfd_boolean Tom Tromey
2026-03-09 13:56 ` [PATCH v2 1/2] Use boolean constants in ft32-tdep.c Tom Tromey
@ 2026-03-09 13:56 ` Tom Tromey
2026-03-09 16:04 ` [PATCH v2 0/2] Update some spots that were using bfd_boolean Simon Marchi
2026-03-09 16:59 ` Andrew Burgess
3 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2026-03-09 13:56 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This rewrites findcmd.c:put_bits to use store_unsigned_integer, and to
directly use the byte order.
---
gdb/findcmd.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/gdb/findcmd.c b/gdb/findcmd.c
index 1372c2ee348..b52c44d48d0 100644
--- a/gdb/findcmd.c
+++ b/gdb/findcmd.c
@@ -24,27 +24,20 @@
#include "cli/cli-utils.h"
#include <algorithm>
#include "gdbsupport/byte-vector.h"
+#include "extract-store-integer.h"
-/* Copied from bfd_put_bits. */
+/* Append DATA to BUF, writing only the specified number of bits,
+ using the given endian-ness. */
static void
-put_bits (uint64_t data, gdb::byte_vector &buf, int bits, bool big_p)
+put_bits (uint64_t data, gdb::byte_vector &buf, int bits,
+ bfd_endian byte_order)
{
- int i;
- int bytes;
-
gdb_assert (bits % 8 == 0);
-
- bytes = bits / 8;
+ int bytes = bits / 8;
size_t last = buf.size ();
buf.resize (last + bytes);
- for (i = 0; i < bytes; i++)
- {
- int index = big_p ? bytes - i - 1 : i;
-
- buf[last + index] = data & 0xff;
- data >>= 8;
- }
+ store_unsigned_integer (&buf[last], bytes, byte_order, data);
}
/* Subroutine of find_command to simplify it.
@@ -53,7 +46,7 @@ put_bits (uint64_t data, gdb::byte_vector &buf, int bits, bool big_p)
static gdb::byte_vector
parse_find_args (const char *args, ULONGEST *max_countp,
CORE_ADDR *start_addrp, ULONGEST *search_space_lenp,
- bool big_p)
+ bfd_endian byte_order)
{
/* Default to using the specified type. */
char size = '\0';
@@ -171,13 +164,13 @@ parse_find_args (const char *args, ULONGEST *max_countp,
pattern_buf.push_back (x);
break;
case 'h':
- put_bits (x, pattern_buf, 16, big_p);
+ put_bits (x, pattern_buf, 16, byte_order);
break;
case 'w':
- put_bits (x, pattern_buf, 32, big_p);
+ put_bits (x, pattern_buf, 32, byte_order);
break;
case 'g':
- put_bits (x, pattern_buf, 64, big_p);
+ put_bits (x, pattern_buf, 64, byte_order);
break;
}
}
@@ -210,7 +203,7 @@ static void
find_command (const char *args, int from_tty)
{
struct gdbarch *gdbarch = get_current_arch ();
- bool big_p = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG;
+ bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* Command line parameters.
These are initialized to avoid uninitialized warnings from -Wall. */
ULONGEST max_count = 0;
@@ -223,7 +216,7 @@ find_command (const char *args, int from_tty)
gdb::byte_vector pattern_buf = parse_find_args (args, &max_count,
&start_addr,
&search_space_len,
- big_p);
+ byte_order);
/* Perform the search. */
--
2.49.0
^ permalink raw reply [flat|nested] 5+ messages in thread