From: Guinevere Larsen <guinevere@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/4] Drop use of bfd_boolean from findcmd.c
Date: Fri, 7 Aug 2026 09:54:46 -0300 [thread overview]
Message-ID: <26fa5df9-54b3-4b80-aed0-16eba3621a3c@redhat.com> (raw)
In-Reply-To: <20260307-no-bfd-boolean-v1-3-186424bf8238@tromey.com>
On 3/7/26 3:20 PM, Tom Tromey wrote:
> This changes findcmd.c to remove the use of bfd_boolean. Instead, the
> byte order is used directly. put_bits is also rewritten in terms of
> store_unsigned_integer.
> ---
> gdb/findcmd.c | 33 +++++++++++++--------------------
> 1 file changed, 13 insertions(+), 20 deletions(-)
>
> diff --git a/gdb/findcmd.c b/gdb/findcmd.c
> index c4ee0ec97e4..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. */
I think that this comment should probably specify that it should be an
integer number of bytes, because I thought you could have like 9 bits
and was wondering how the code managed that (I misread the diff thinking
the assert was removed).
>
> static void
> -put_bits (uint64_t data, gdb::byte_vector &buf, int bits, bfd_boolean 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, bfd_boolean big_p)
> static gdb::byte_vector
> parse_find_args (const char *args, ULONGEST *max_countp,
> CORE_ADDR *start_addrp, ULONGEST *search_space_lenp,
> - bfd_boolean 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 ();
> - bfd_boolean 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. */
>
>
--
Cheers,
Guinevere Larsen
it/its
she/her (deprecated)
next prev parent reply other threads:[~2026-08-07 13:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 18:20 [PATCH 0/4] Remove some bfd_boolean uses Tom Tromey
2026-03-07 18:20 ` [PATCH 1/4] Use bool, not bfd_boolean Tom Tromey
2026-03-07 18:20 ` [PATCH 2/4] Don't use BFD TRUE/FALSE constants Tom Tromey
2026-03-07 18:20 ` [PATCH 3/4] Drop use of bfd_boolean from findcmd.c Tom Tromey
2026-08-07 12:54 ` Guinevere Larsen [this message]
2026-03-07 18:20 ` [PATCH 4/4] Poison bfd_boolean Tom Tromey
2026-08-07 12:55 ` [PATCH 0/4] Remove some bfd_boolean uses Guinevere Larsen
2026-08-21 16:42 ` 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=26fa5df9-54b3-4b80-aed0-16eba3621a3c@redhat.com \
--to=guinevere@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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