* [PATCH 0/4] Remove some bfd_boolean uses
@ 2026-03-07 18:20 Tom Tromey
2026-03-07 18:20 ` [PATCH 1/4] Use bool, not bfd_boolean Tom Tromey
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Tom Tromey @ 2026-03-07 18:20 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
I saw some recent commits removing uses of bfd_boolean from the tree.
This series removes the remaining uses from gdb as well, and then
arranges to poison the identifier using the BFD-supplied approach.
Signed-off-by: Tom Tromey <tom@tromey.com>
---
Tom Tromey (4):
Use bool, not bfd_boolean
Don't use BFD TRUE/FALSE constants
Drop use of bfd_boolean from findcmd.c
Poison bfd_boolean
gdb/arc-linux-tdep.c | 6 +++---
gdb/compile/compile-object-load.c | 4 ++--
gdb/defs.h | 2 ++
gdb/elfread.c | 2 +-
gdb/findcmd.c | 33 +++++++++++++--------------------
gdb/ft32-tdep.c | 6 +++---
gdb/machoread.c | 4 ++--
7 files changed, 26 insertions(+), 31 deletions(-)
---
base-commit: a00fddb175ff5cb9edef18beedfba38fc6fc6017
change-id: 20260307-no-bfd-boolean-1c8cbdbf2849
Best regards,
--
Tom Tromey <tom@tromey.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/4] Use bool, not bfd_boolean
2026-03-07 18:20 [PATCH 0/4] Remove some bfd_boolean uses Tom Tromey
@ 2026-03-07 18:20 ` Tom Tromey
2026-03-07 18:20 ` [PATCH 2/4] Don't use BFD TRUE/FALSE constants Tom Tromey
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2026-03-07 18:20 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This changes a couple of spots to use bool rather than bfd_boolean.
bfd_boolean appears to be deprecated.
---
gdb/compile/compile-object-load.c | 2 +-
gdb/ft32-tdep.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 27cd0c7c2f3..e31be539741 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -220,7 +220,7 @@ link_callbacks_warning (struct bfd_link_info *link_info, const char *xwarning,
static void
link_callbacks_undefined_symbol (struct bfd_link_info *link_info,
const char *name, bfd *abfd, asection *section,
- bfd_vma address, bfd_boolean is_fatal)
+ bfd_vma address, bool is_fatal)
{
warning (_("Cannot resolve relocation to \"%s\" "
"from compiled module \"%s\" section \"%s\"."),
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 84b9ce657cb..5a1f3315c7f 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -61,7 +61,7 @@ struct ft32_frame_cache
/* Saved SP in this frame */
CORE_ADDR saved_sp;
/* Has the new frame been LINKed. */
- bfd_boolean established;
+ bool established;
};
/* Implement the "frame_align" gdbarch method. */
@@ -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] 8+ messages in thread
* [PATCH 2/4] Don't use BFD TRUE/FALSE constants
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 ` Tom Tromey
2026-03-07 18:20 ` [PATCH 3/4] Drop use of bfd_boolean from findcmd.c Tom Tromey
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2026-03-07 18:20 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This patch replaces uses of the BFD TRUE/FALSE constants with the
corresponding C++ constants.
Note that some uses of TRUE and FALSE remain:
* Mach code (Darwin and Hurd). I don't know if this is typical and
anyway I can't build this code.
* Curses code
* Windows code
---
gdb/arc-linux-tdep.c | 6 +++---
gdb/compile/compile-object-load.c | 2 +-
gdb/elfread.c | 2 +-
gdb/machoread.c | 4 ++--
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
index 207235d3732..ca3dbf5a5fa 100644
--- a/gdb/arc-linux-tdep.c
+++ b/gdb/arc-linux-tdep.c
@@ -212,18 +212,18 @@ arc_linux_is_sigtramp (const frame_info_ptr &this_frame)
if (!safe_frame_unwind_memory (this_frame, pc, {buf, insns_sz}))
{
/* Failed to unwind frame. */
- return FALSE;
+ return false;
}
/* Is that code the sigtramp instruction sequence? */
if (memcmp (buf, arc_sigtramp_insns, insns_sz) == 0)
- return TRUE;
+ return true;
/* No - look one instruction earlier in the code... */
if (!safe_frame_unwind_memory (this_frame, pc - 4, {buf, insns_sz}))
{
/* Failed to unwind frame. */
- return FALSE;
+ return false;
}
return (memcmp (buf, arc_sigtramp_insns, insns_sz) == 0);
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index e31be539741..bbee2f7cc56 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -372,7 +372,7 @@ copy_section (bfd *abfd, asection *sect,
sect_data_got = bfd_get_relocated_section_contents (abfd, &link_info,
&link_order,
- sect_data.get (), FALSE,
+ sect_data.get (), false,
symbol_table.data ());
if (sect_data_got == NULL)
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 7e38f623d12..7a647396f68 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -601,7 +601,7 @@ elf_rel_plt_read (minimal_symbol_reader &reader,
if (relplt == NULL)
return;
- if (! bed->s->slurp_reloc_table (obfd, relplt, dyn_symbol_table, TRUE))
+ if (! bed->s->slurp_reloc_table (obfd, relplt, dyn_symbol_table, true))
return;
std::string string_buffer;
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 334e3b41b6a..416eb6766fd 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -483,7 +483,7 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
struct macho_sym_hash_entry *ent;
ent = (struct macho_sym_hash_entry *)
- bfd_hash_lookup (&table, sym->name, TRUE, FALSE);
+ bfd_hash_lookup (&table, sym->name, true, false);
if (ent->sym != NULL)
complaint (_("Duplicated symbol %s in symbol table"), sym->name);
else
@@ -548,7 +548,7 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
struct macho_sym_hash_entry *ent;
ent = (struct macho_sym_hash_entry *)
- bfd_hash_lookup (&table, sym->name, FALSE, FALSE);
+ bfd_hash_lookup (&table, sym->name, false, false);
if (ent != NULL)
addr = bfd_asymbol_value (ent->sym);
}
--
2.49.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/4] Drop use of bfd_boolean from findcmd.c
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 ` Tom Tromey
2026-08-07 12:54 ` Guinevere Larsen
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
4 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2026-03-07 18:20 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
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. */
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. */
--
2.49.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/4] Poison bfd_boolean
2026-03-07 18:20 [PATCH 0/4] Remove some bfd_boolean uses Tom Tromey
` (2 preceding siblings ...)
2026-03-07 18:20 ` [PATCH 3/4] Drop use of bfd_boolean from findcmd.c Tom Tromey
@ 2026-03-07 18:20 ` Tom Tromey
2026-08-07 12:55 ` [PATCH 0/4] Remove some bfd_boolean uses Guinevere Larsen
4 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2026-03-07 18:20 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
BFD is moving away from bfd_boolean. This patch arranges for gdb to
do the same by having BFD poison the identifier so that no new uses
will creep in.
---
gdb/defs.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/gdb/defs.h b/gdb/defs.h
index b378449343d..de4f44e2458 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -32,6 +32,8 @@
#undef PACKAGE_TARNAME
#include <config.h>
+
+#define POISON_BFD_BOOLEAN
#include "bfd.h"
#include <sys/types.h>
--
2.49.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/4] Drop use of bfd_boolean from findcmd.c
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
0 siblings, 0 replies; 8+ messages in thread
From: Guinevere Larsen @ 2026-08-07 12:54 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
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)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] Remove some bfd_boolean uses
2026-03-07 18:20 [PATCH 0/4] Remove some bfd_boolean uses Tom Tromey
` (3 preceding siblings ...)
2026-03-07 18:20 ` [PATCH 4/4] Poison bfd_boolean Tom Tromey
@ 2026-08-07 12:55 ` Guinevere Larsen
2026-08-21 16:42 ` Tom Tromey
4 siblings, 1 reply; 8+ messages in thread
From: Guinevere Larsen @ 2026-08-07 12:55 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 3/7/26 3:20 PM, Tom Tromey wrote:
> I saw some recent commits removing uses of bfd_boolean from the tree.
> This series removes the remaining uses from gdb as well, and then
> arranges to poison the identifier using the BFD-supplied approach.
>
> Signed-off-by: Tom Tromey <tom@tromey.com>
> ---
Hi Tom!
I looked over this series and everything looks ok to me. I have sent a
nitpick suggestion on patch 3, but otherwise I think this looks nice
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
> Tom Tromey (4):
> Use bool, not bfd_boolean
> Don't use BFD TRUE/FALSE constants
> Drop use of bfd_boolean from findcmd.c
> Poison bfd_boolean
>
> gdb/arc-linux-tdep.c | 6 +++---
> gdb/compile/compile-object-load.c | 4 ++--
> gdb/defs.h | 2 ++
> gdb/elfread.c | 2 +-
> gdb/findcmd.c | 33 +++++++++++++--------------------
> gdb/ft32-tdep.c | 6 +++---
> gdb/machoread.c | 4 ++--
> 7 files changed, 26 insertions(+), 31 deletions(-)
> ---
> base-commit: a00fddb175ff5cb9edef18beedfba38fc6fc6017
> change-id: 20260307-no-bfd-boolean-1c8cbdbf2849
>
> Best regards,
--
Cheers,
Guinevere Larsen
it/its
she/her (deprecated)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] Remove some bfd_boolean uses
2026-08-07 12:55 ` [PATCH 0/4] Remove some bfd_boolean uses Guinevere Larsen
@ 2026-08-21 16:42 ` Tom Tromey
0 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2026-08-21 16:42 UTC (permalink / raw)
To: Guinevere Larsen; +Cc: Tom Tromey, gdb-patches
>>>>> "Guinevere" == Guinevere Larsen <guinevere@redhat.com> writes:
Guinevere> Hi Tom!
Guinevere> I looked over this series and everything looks ok to me. I have sent a
Guinevere> nitpick suggestion on patch 3, but otherwise I think this looks nice
Guinevere> Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
FWIW I think these were all obsoleted by Alan's patches to remove bfd_boolean.
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-08-21 16:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox