* [PATCH 01/23] gdb/dwarf: change die_needs_namespace to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 02/23] gdb/dwarf: change dwarf2_flag_true_p " Simon Marchi
` (22 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change the return type to bool, and do some other trivial refactoring:
- remove unnecessary `attr` variable, which I don't think helps code
readability
- change an `if (cond) return false; return true` pattern to be just
one return expression.
Change-Id: I647c3ad73af94bb76c4b59f580bbdfd1eef45888
---
gdb/dwarf2/read.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 25ea7644ed08..d52f0651de1b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -4980,11 +4980,9 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
needs to have the name of the scope prepended to the name listed in the
die. */
-static int
+static bool
die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
{
- struct attribute *attr;
-
if (tag_is_type (die->tag) && die->tag != DW_TAG_template_type_param)
{
/* Historically GNAT emitted some types in funny scopes. For
@@ -4997,7 +4995,7 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
. DW_AT_name: natural
To detect this, we look up the DIE tree for a node that has
- a name; and if that name is fully qualified, we return 0
+ a name; and if that name is fully qualified, we return false
here. */
if (cu->lang () == language_ada)
{
@@ -5013,7 +5011,7 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
}
}
}
- return 1;
+ return true;
}
switch (die->tag)
@@ -5024,7 +5022,7 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
case DW_TAG_entry_point:
case DW_TAG_member:
case DW_TAG_imported_declaration:
- return 1;
+ return true;
case DW_TAG_module:
/* We don't need the namespace for Fortran modules, but we do
@@ -5046,22 +5044,21 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
spec_cu);
}
- attr = dwarf2_attr (die, DW_AT_external, cu);
- if (attr == NULL && die->parent->tag != DW_TAG_namespace
+ if (dwarf2_attr (die, DW_AT_external, cu) == nullptr
+ && die->parent->tag != DW_TAG_namespace
&& die->parent->tag != DW_TAG_module)
- return 0;
+ return false;
+
/* A variable in a lexical block of some kind does not need a
namespace, even though in C++ such variables may be external
and have a mangled name. */
- if (die->parent->tag == DW_TAG_lexical_block
- || die->parent->tag == DW_TAG_try_block
- || die->parent->tag == DW_TAG_catch_block
- || die->parent->tag == DW_TAG_subprogram)
- return 0;
- return 1;
+ return (die->parent->tag != DW_TAG_lexical_block
+ && die->parent->tag != DW_TAG_try_block
+ && die->parent->tag != DW_TAG_catch_block
+ && die->parent->tag != DW_TAG_subprogram);
default:
- return 0;
+ return false;
}
}
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 02/23] gdb/dwarf: change dwarf2_flag_true_p to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
2026-03-11 18:05 ` [PATCH 01/23] gdb/dwarf: change die_needs_namespace to return bool Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 03/23] gdb/dwarf: change die_is_declaration " Simon Marchi
` (21 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: Ie60d5d715171f7482f77598553e9236c3fe94ab1
---
gdb/dwarf2/read.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index d52f0651de1b..827772a2af78 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -724,8 +724,8 @@ static const char *dwarf2_string_attr (struct die_info *die, unsigned int name,
static const char *dwarf2_dwo_name (struct die_info *die, struct dwarf2_cu *cu);
-static int dwarf2_flag_true_p (struct die_info *die, unsigned name,
- struct dwarf2_cu *cu);
+static bool dwarf2_flag_true_p (struct die_info *die, unsigned name,
+ struct dwarf2_cu *cu);
static int die_is_declaration (struct die_info *, struct dwarf2_cu *cu);
@@ -15175,11 +15175,11 @@ dwarf2_dwo_name (struct die_info *die, struct dwarf2_cu *cu)
return dwo_name;
}
-/* Return non-zero iff the attribute NAME is defined for the given DIE,
+/* Return true iff the attribute NAME is defined for the given DIE,
and holds a non-zero value. This function should only be used for
DW_FORM_flag or DW_FORM_flag_present attributes. */
-static int
+static bool
dwarf2_flag_true_p (struct die_info *die, unsigned name, struct dwarf2_cu *cu)
{
struct attribute *attr = dwarf2_attr (die, name, cu);
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 03/23] gdb/dwarf: change die_is_declaration to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
2026-03-11 18:05 ` [PATCH 01/23] gdb/dwarf: change die_needs_namespace to return bool Simon Marchi
2026-03-11 18:05 ` [PATCH 02/23] gdb/dwarf: change dwarf2_flag_true_p " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 04/23] gdb/dwarf: change need_gnat_info " Simon Marchi
` (20 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I20f9f5b273a2cb8d24b590447a86bf1575d21ddc
---
gdb/dwarf2/read.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 827772a2af78..155e5d94dbc7 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -727,7 +727,7 @@ static const char *dwarf2_dwo_name (struct die_info *die, struct dwarf2_cu *cu);
static bool dwarf2_flag_true_p (struct die_info *die, unsigned name,
struct dwarf2_cu *cu);
-static int die_is_declaration (struct die_info *, struct dwarf2_cu *cu);
+static bool die_is_declaration (struct die_info *, struct dwarf2_cu *cu);
static struct die_info *die_specification (struct die_info *die,
struct dwarf2_cu **);
@@ -15187,7 +15187,7 @@ dwarf2_flag_true_p (struct die_info *die, unsigned name, struct dwarf2_cu *cu)
return attr != nullptr && attr->as_boolean ();
}
-static int
+static bool
die_is_declaration (struct die_info *die, struct dwarf2_cu *cu)
{
/* A DIE is a declaration if it has a DW_AT_declaration attribute
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 04/23] gdb/dwarf: change need_gnat_info to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (2 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 03/23] gdb/dwarf: change die_is_declaration " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 05/23] gdb/dwarf: change attr_to_dynamic_prop " Simon Marchi
` (19 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I0bc5930cc3b30986682d50f5eaad39fb74b2db8e
---
gdb/dwarf2/read.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 155e5d94dbc7..57945a24fb13 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -755,7 +755,7 @@ static struct type *read_subrange_index_type (struct die_info *die,
static struct type *die_type (struct die_info *, struct dwarf2_cu *);
-static int need_gnat_info (struct dwarf2_cu *);
+static bool need_gnat_info (struct dwarf2_cu *);
static struct type *die_descriptive_type (struct die_info *,
struct dwarf2_cu *);
@@ -16079,12 +16079,12 @@ die_type (struct die_info *die, struct dwarf2_cu *cu)
that allows to find parallel types through that information instead
of having to do expensive parallel lookups by type name. */
-static int
+static bool
need_gnat_info (struct dwarf2_cu *cu)
{
/* Assume that the Ada compiler was GNAT, which always produces
the auxiliary information. */
- return (cu->lang () == language_ada);
+ return cu->lang () == language_ada;
}
/* Return the auxiliary type of the die in question using its
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 05/23] gdb/dwarf: change attr_to_dynamic_prop to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (3 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 04/23] gdb/dwarf: change need_gnat_info " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 06/23] gdb/dwarf: change dwarf2_is_constructor " Simon Marchi
` (18 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I80fc429cd15328c5dfd1f4e7f87ad83368bcb28d
---
gdb/dwarf2/read.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 57945a24fb13..a8b2716e6649 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -892,9 +892,9 @@ static struct type *get_DW_AT_signature_type (struct die_info *,
static dwarf2_cu *load_full_type_unit (signatured_type *sig_type,
dwarf2_per_objfile *per_objfile);
-static int attr_to_dynamic_prop (const struct attribute *attr,
- struct die_info *die, struct dwarf2_cu *cu,
- struct dynamic_prop *prop, struct type *type);
+static bool attr_to_dynamic_prop (const struct attribute *attr,
+ struct die_info *die, struct dwarf2_cu *cu,
+ struct dynamic_prop *prop, struct type *type);
/* memory allocation interface */
@@ -11500,12 +11500,12 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
if (attribute *attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
attr != nullptr)
{
- int stride_ok;
struct type *prop_type = cu->addr_sized_int_type (false);
byte_stride_prop = &stride_storage;
- stride_ok = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop,
- prop_type);
+ bool stride_ok
+ = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop, prop_type);
+
if (!stride_ok)
{
complaint (_("unable to read array DW_AT_byte_stride "
@@ -13376,9 +13376,9 @@ var_decl_name (struct die_info *die, struct dwarf2_cu *cu)
/* Parse dwarf attribute if it's a block, reference or constant and put the
resulting value of the attribute into struct bound_prop.
- Returns 1 if ATTR could be resolved into PROP, 0 otherwise. */
+ Returns true if ATTR could be resolved into PROP, false otherwise. */
-static int
+static bool
attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
struct dwarf2_cu *cu, struct dynamic_prop *prop,
struct type *default_type)
@@ -13391,7 +13391,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
gdb_assert (default_type != NULL);
if (attr == NULL || prop == NULL)
- return 0;
+ return false;
if (attr->form_is_block ())
{
@@ -13450,9 +13450,9 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
if (name != nullptr)
{
prop->set_variable_name (name);
- return 1;
+ return true;
}
- return 0;
+ return false;
}
switch (target_attr->name)
@@ -13483,7 +13483,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
{
dwarf2_invalid_attrib_class_complaint ("DW_AT_location",
"dynamic property");
- return 0;
+ return false;
}
break;
case DW_AT_data_member_location:
@@ -13491,7 +13491,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
{
baton = find_field_create_baton (cu, target_die);
if (baton == nullptr)
- return 0;
+ return false;
baton->property_type = read_type_die (target_die->parent,
target_cu);
@@ -13520,12 +13520,12 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
else
goto invalid;
- return 1;
+ return true;
invalid:
dwarf2_invalid_attrib_class_complaint (dwarf_form_name (attr->form),
dwarf2_name (die, cu));
- return 0;
+ return false;
}
/* See read.h. */
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 06/23] gdb/dwarf: change dwarf2_is_constructor to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (4 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 05/23] gdb/dwarf: change attr_to_dynamic_prop " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 07/23] gdb/dwarf: change is_vtable_name " Simon Marchi
` (17 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I207d368269494a4a36884847f4474e2f6c326511
---
gdb/dwarf2/read.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a8b2716e6649..1423dd0a574b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9891,7 +9891,7 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
/* Return true if this member function is a constructor, false
otherwise. */
-static int
+static bool
dwarf2_is_constructor (struct die_info *die, struct dwarf2_cu *cu)
{
const char *fieldname;
@@ -9899,17 +9899,17 @@ dwarf2_is_constructor (struct die_info *die, struct dwarf2_cu *cu)
int len;
if (die->parent == NULL)
- return 0;
+ return false;
if (die->parent->tag != DW_TAG_structure_type
&& die->parent->tag != DW_TAG_union_type
&& die->parent->tag != DW_TAG_class_type)
- return 0;
+ return false;
fieldname = dwarf2_name (die, cu);
type_name = dwarf2_name (die->parent, cu);
if (fieldname == NULL || type_name == NULL)
- return 0;
+ return false;
len = strlen (fieldname);
return (strncmp (fieldname, type_name, len) == 0
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 07/23] gdb/dwarf: change is_vtable_name to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (5 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 06/23] gdb/dwarf: change dwarf2_is_constructor " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 08/23] gdb/dwarf: change prototyped_function_p " Simon Marchi
` (16 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: Ib14b18b75ddfc308b9987cd9102f0f721c91a3b1
---
gdb/dwarf2/read.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1423dd0a574b..4db3139a265d 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -10147,18 +10147,16 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type,
TYPE_NFN_FIELDS (type) = fip->fnfieldlists.size ();
}
-/* Returns non-zero if NAME is the name of a vtable member in CU's
- language, zero otherwise. */
-static int
+/* Returns true if NAME is the name of a vtable member in CU's
+ language, false otherwise. */
+
+static bool
is_vtable_name (const char *name, struct dwarf2_cu *cu)
{
static const char vptr[] = "_vptr";
/* Look for the C++ form of the vtable. */
- if (startswith (name, vptr) && is_cplus_marker (name[sizeof (vptr) - 1]))
- return 1;
-
- return 0;
+ return startswith (name, vptr) && is_cplus_marker (name[sizeof (vptr) - 1]);
}
/* GCC outputs unnamed structures that are really pointers to member
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 08/23] gdb/dwarf: change prototyped_function_p to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (6 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 07/23] gdb/dwarf: change is_vtable_name " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 09/23] gdb/dwarf: change dwarf2_ranges_process " Simon Marchi
` (15 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I4a6f6c2d063be780c4d740b8bac2d2d92d42001e
---
gdb/dwarf2/read.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 4db3139a265d..514f562e5aba 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -12477,17 +12477,17 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
return set_die_type (die, type, cu);
}
-/* Assuming that DIE corresponds to a function, returns nonzero
+/* Assuming that DIE corresponds to a function, returns true
if the function is prototyped. */
-static int
+static bool
prototyped_function_p (struct die_info *die, struct dwarf2_cu *cu)
{
struct attribute *attr;
attr = dwarf2_attr (die, DW_AT_prototyped, cu);
if (attr && attr->as_boolean ())
- return 1;
+ return true;
/* The DWARF standard implies that the DW_AT_prototyped attribute
is only meaningful for C, but the concept also extends to other
@@ -12497,16 +12497,16 @@ prototyped_function_p (struct die_info *die, struct dwarf2_cu *cu)
if (cu->lang () != language_c
&& cu->lang () != language_objc
&& cu->lang () != language_opencl)
- return 1;
+ return true;
/* RealView does not emit DW_AT_prototyped. We can not distinguish
prototyped and unprototyped functions; default to prototyped,
since that is more common in modern code (and RealView warns
about unprototyped functions). */
if (cu->producer_is_realview ())
- return 1;
+ return true;
- return 0;
+ return false;
}
/* Handle DIES due to C code like:
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 09/23] gdb/dwarf: change dwarf2_ranges_process to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (7 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 08/23] gdb/dwarf: change prototyped_function_p " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 10/23] gdb/dwarf: change dwarf2_ranges_read " Simon Marchi
` (14 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I7472405cf276a336247fd47bf1126eaf21b05b92
---
gdb/dwarf2/read.c | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 514f562e5aba..6861b6ad4cde 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -8387,12 +8387,15 @@ dwarf_fixup_empty_range (struct dwarf2_cu *cu, dwarf_tag tag)
return tag == DW_TAG_inlined_subroutine && cu->producer_is_gcc ();
}
-/* Call CALLBACK from DW_AT_ranges attribute value OFFSET
- reading .debug_rnglists.
+/* Call CALLBACK from DW_AT_ranges attribute value OFFSET reading
+ .debug_rnglists.
+
Callback's type should be:
- void (CORE_ADDR range_beginning, CORE_ADDR range_end)
- Return true if the attributes are present and valid, otherwise,
- return false. */
+
+ void (CORE_ADDR range_beginning, CORE_ADDR range_end)
+
+ Return true if the attributes are present and valid, otherwise return
+ false. */
template <typename Callback>
static bool
@@ -8599,11 +8602,14 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
/* Call CALLBACK from DW_AT_ranges attribute value OFFSET reading .debug_ranges.
Callback's type should be:
- void (unrelocated_addr range_beginning, unrelocated_addr range_end)
- Return 1 if the attributes are present and valid, otherwise, return 0. */
+
+ void (unrelocated_addr range_beginning, unrelocated_addr range_end)
+
+ Return true if the attributes are present and valid, otherwise return
+ false. */
template <typename Callback>
-static int
+static bool
dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
Callback &&callback)
{
@@ -8628,7 +8634,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
{
complaint (_("Offset %d out of bounds for DW_AT_ranges attribute"),
offset);
- return 0;
+ return false;
}
buffer = per_objfile->per_bfd->ranges.buffer + offset;
@@ -8664,14 +8670,14 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
/* We have no valid base address for the ranges
data. */
complaint (_("Invalid .debug_ranges data (no base address)"));
- return 0;
+ return false;
}
if (range_beginning > range_end)
{
/* Inverted range entries are invalid. */
complaint (_("Invalid .debug_ranges data (inverted range)"));
- return 0;
+ return false;
}
/* Empty range entries have no effect. */
@@ -8701,7 +8707,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
callback (range_beginning, range_end);
}
- return 1;
+ return true;
}
/* See read.h. */
@@ -8714,7 +8720,7 @@ dwarf2_ranges_read (unsigned offset, unrelocated_addr *low_return,
int low_set = 0;
unrelocated_addr low = {};
unrelocated_addr high = {};
- int retval;
+ bool retval;
retval = dwarf2_ranges_process (offset, cu, tag,
[&] (unrelocated_addr range_beginning, unrelocated_addr range_end)
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 10/23] gdb/dwarf: change dwarf2_ranges_read to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (8 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 09/23] gdb/dwarf: change dwarf2_ranges_process " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-12 12:44 ` Tom Tromey
2026-03-11 18:05 ` [PATCH 11/23] gdb/dwarf: change unavailable_retaddr and undefined_retaddr to bool Simon Marchi
` (13 subsequent siblings)
23 siblings, 1 reply; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Also, do some little cleanups in the function itself.
Change-Id: I83928a31dcdcae34b651828fef27b1fa877241eb
---
gdb/dwarf2/read.c | 32 ++++++++++++++++++--------------
gdb/dwarf2/read.h | 10 +++++-----
2 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 6861b6ad4cde..74c6ab7eff7f 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -8712,17 +8712,15 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
/* See read.h. */
-int
+bool
dwarf2_ranges_read (unsigned offset, unrelocated_addr *low_return,
unrelocated_addr *high_return, struct dwarf2_cu *cu,
addrmap_mutable *map, void *datum, dwarf_tag tag)
{
- int low_set = 0;
+ bool low_set = false;
unrelocated_addr low = {};
unrelocated_addr high = {};
- bool retval;
-
- retval = dwarf2_ranges_process (offset, cu, tag,
+ bool retval = dwarf2_ranges_process (offset, cu, tag,
[&] (unrelocated_addr range_beginning, unrelocated_addr range_end)
{
if (map != nullptr)
@@ -8737,33 +8735,39 @@ dwarf2_ranges_read (unsigned offset, unrelocated_addr *low_return,
segment of consecutive addresses. We should have a
data structure for discontiguous block ranges
instead. */
- if (! low_set)
+ if (!low_set)
{
low = range_beginning;
high = range_end;
- low_set = 1;
+ low_set = true;
}
else
{
if (range_beginning < low)
low = range_beginning;
+
if (range_end > high)
high = range_end;
}
});
+
if (!retval)
- return 0;
+ return false;
- if (! low_set)
- /* If the first entry is an end-of-list marker, the range
+ if (!low_set)
+ {
+ /* If the first entry is an end-of-list marker, the range
describes an empty scope, i.e. no instructions. */
- return 0;
+ return false;
+ }
- if (low_return)
+ if (low_return != nullptr)
*low_return = low;
- if (high_return)
+
+ if (high_return != nullptr)
*high_return = high;
- return 1;
+
+ return true;
}
/* Process ranges and fill in a vector of the low PC values only. */
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index e2d75e16146c..86f97e7ccf4a 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -1381,14 +1381,14 @@ extern dwarf2_per_cu *dwarf2_find_unit (const section_and_offset &start,
extern bool decode_locdesc (dwarf_block *blk, dwarf2_cu *cu, CORE_ADDR *result);
/* Get low and high pc attributes from DW_AT_ranges attribute value OFFSET.
- Return 1 if the attributes are present and valid, otherwise, return 0.
+ Return true if the attributes are present and valid, otherwise, return false.
TAG is passed to dwarf2_ranges_process. If MAP is not NULL, then
ranges in MAP are set, using DATUM as the value. */
-extern int dwarf2_ranges_read (unsigned offset, unrelocated_addr *low_return,
- unrelocated_addr *high_return, dwarf2_cu *cu,
- addrmap_mutable *map, void *datum,
- dwarf_tag tag);
+extern bool dwarf2_ranges_read (unsigned offset, unrelocated_addr *low_return,
+ unrelocated_addr *high_return, dwarf2_cu *cu,
+ addrmap_mutable *map, void *datum,
+ dwarf_tag tag);
extern file_and_directory &find_file_and_directory (die_info *die,
dwarf2_cu *cu);
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH 10/23] gdb/dwarf: change dwarf2_ranges_read to return bool
2026-03-11 18:05 ` [PATCH 10/23] gdb/dwarf: change dwarf2_ranges_read " Simon Marchi
@ 2026-03-12 12:44 ` Tom Tromey
2026-03-12 14:21 ` Simon Marchi
0 siblings, 1 reply; 28+ messages in thread
From: Tom Tromey @ 2026-03-12 12:44 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
Simon> -int
Simon> +bool
Simon> dwarf2_ranges_read (unsigned offset, unrelocated_addr *low_return,
Simon> unrelocated_addr *high_return, struct dwarf2_cu *cu,
Simon> addrmap_mutable *map, void *datum, dwarf_tag tag)
Simon> {
Simon> - int low_set = 0;
Simon> + bool low_set = false;
Simon> unrelocated_addr low = {};
Simon> unrelocated_addr high = {};
I was going to suggest std::optional here, but it seems "low_set" is
misnamed and it really tracks whether both values have been set.
Tom
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH 10/23] gdb/dwarf: change dwarf2_ranges_read to return bool
2026-03-12 12:44 ` Tom Tromey
@ 2026-03-12 14:21 ` Simon Marchi
0 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-12 14:21 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 2026-03-12 08:44, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>
> Simon> -int
> Simon> +bool
> Simon> dwarf2_ranges_read (unsigned offset, unrelocated_addr *low_return,
> Simon> unrelocated_addr *high_return, struct dwarf2_cu *cu,
> Simon> addrmap_mutable *map, void *datum, dwarf_tag tag)
> Simon> {
> Simon> - int low_set = 0;
> Simon> + bool low_set = false;
> Simon> unrelocated_addr low = {};
> Simon> unrelocated_addr high = {};
>
> I was going to suggest std::optional here, but it seems "low_set" is
> misnamed and it really tracks whether both values have been set.
>
> Tom
I'll see if I can improve things there.
Simon
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 11/23] gdb/dwarf: change unavailable_retaddr and undefined_retaddr to bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (9 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 10/23] gdb/dwarf: change dwarf2_ranges_read " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 12/23] gdb/dwarf: change frame_is_tailcall to return bool Simon Marchi
` (12 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I928e9244aee156501e0c2318f2a58b26ed00add7
---
gdb/dwarf2/frame.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 771a03d9467c..47cdf397f3de 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -853,10 +853,10 @@ struct dwarf2_frame_cache
/* Set if the return address column was marked as unavailable
(required non-collected memory or registers to compute). */
- int unavailable_retaddr;
+ bool unavailable_retaddr;
/* Set if the return address column was marked as undefined. */
- int undefined_retaddr;
+ bool undefined_retaddr;
/* Saved registers, indexed by GDB register number, not by DWARF
register number. */
@@ -997,7 +997,7 @@ dwarf2_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
{
if (ex.error == NOT_AVAILABLE_ERROR)
{
- cache->unavailable_retaddr = 1;
+ cache->unavailable_retaddr = true;
return cache;
}
@@ -1101,7 +1101,7 @@ incomplete CFI data; unspecified registers (e.g., %s) at %s"),
if (fs.retaddr_column < fs.regs.reg.size ()
&& fs.regs.reg[fs.retaddr_column].how == DWARF2_FRAME_REG_UNDEFINED)
- cache->undefined_retaddr = 1;
+ cache->undefined_retaddr = true;
dwarf2_tailcall_sniffer_first (this_frame, &cache->tailcall_cache,
(entry_cfa_sp_offset_p
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 12/23] gdb/dwarf: change frame_is_tailcall to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (10 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 11/23] gdb/dwarf: change unavailable_retaddr and undefined_retaddr to bool Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 13/23] gdb/dwarf: change call_site_parameter_matches " Simon Marchi
` (11 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: Icc70cb565ece0f04fbd8950cf6ff41f9b3e2c242
---
gdb/dwarf2/frame-tailcall.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdb/dwarf2/frame-tailcall.c b/gdb/dwarf2/frame-tailcall.c
index 9e2e56b9bcb5..bfdf5db473f4 100644
--- a/gdb/dwarf2/frame-tailcall.c
+++ b/gdb/dwarf2/frame-tailcall.c
@@ -131,10 +131,10 @@ cache_unref (struct tailcall_cache *cache)
}
}
-/* Return 1 if FI is a non-bottom (not the callee) tail call frame. Otherwise
- return 0. */
+/* Return true if FI is a non-bottom (not the callee) tail call frame.
+ Otherwise return false. */
-static int
+static bool
frame_is_tailcall (const frame_info_ptr &fi)
{
return frame_unwinder_is (fi, &dwarf2_tailcall_frame_unwind);
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 13/23] gdb/dwarf: change call_site_parameter_matches to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (11 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 12/23] gdb/dwarf: change frame_is_tailcall to return bool Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 14/23] gdb/dwarf: change dwarf2_fetch_cfa_info " Simon Marchi
` (10 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: Ic131c1752151a1b275c06c3dc92d86bcc925d6f7
---
gdb/dwarf2/loc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 2d63be7d57e5..8dfd04461be0 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1110,9 +1110,9 @@ call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
return retval;
}
-/* Return 1 if KIND and KIND_U match PARAMETER. Return 0 otherwise. */
+/* Return true if KIND and KIND_U match PARAMETER. Return false otherwise. */
-static int
+static bool
call_site_parameter_matches (struct call_site_parameter *parameter,
enum call_site_parameter_kind kind,
union call_site_parameter_u kind_u)
@@ -1129,7 +1129,8 @@ call_site_parameter_matches (struct call_site_parameter *parameter,
case CALL_SITE_PARAMETER_PARAM_OFFSET:
return kind_u.param_cu_off == parameter->u.param_cu_off;
}
- return 0;
+
+ return false;
}
/* See loc.h. */
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 14/23] gdb/dwarf: change dwarf2_fetch_cfa_info to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (12 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 13/23] gdb/dwarf: change call_site_parameter_matches " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 15/23] gdb/dwarf: change dwarf2_locexpr_baton_eval " Simon Marchi
` (9 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I4d5dc288c6ade399e62c73dcb21eebfe2ae16bb7
---
gdb/dwarf2/frame.c | 7 ++++---
gdb/dwarf2/frame.h | 32 ++++++++++++++++----------------
2 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 47cdf397f3de..be55b90df597 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -768,7 +768,7 @@ dwarf2_frame_find_quirks (struct dwarf2_frame_state *fs,
/* See dwarf2/frame.h. */
-int
+bool
dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
dwarf2_per_cu *data, int *regnum_out,
LONGEST *offset_out, CORE_ADDR *text_offset_out,
@@ -815,14 +815,15 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
*offset_out = -fs.regs.cfa_offset;
else
*offset_out = fs.regs.cfa_offset;
- return 1;
+
+ return true;
}
case CFA_EXP:
*text_offset_out = per_objfile->objfile->text_section_offset ();
*cfa_start_out = fs.regs.cfa_exp;
*cfa_end_out = fs.regs.cfa_exp + fs.regs.cfa_exp_len;
- return 0;
+ return false;
default:
internal_error (_("Unknown CFA rule."));
diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h
index 89fa234c43c0..47f9ed88f7c5 100644
--- a/gdb/dwarf2/frame.h
+++ b/gdb/dwarf2/frame.h
@@ -246,7 +246,7 @@ CORE_ADDR dwarf2_frame_cfa (const frame_info_ptr &this_frame);
/* Find the CFA information for PC.
- Return 1 if a register is used for the CFA, or 0 if another
+ Return true if a register is used for the CFA, or false if another
expression is used. Throw an exception on error.
GDBARCH is the architecture to use.
@@ -254,17 +254,17 @@ CORE_ADDR dwarf2_frame_cfa (const frame_info_ptr &this_frame);
REGNUM_OUT is an out parameter that is set to the register number.
OFFSET_OUT is the offset to use from this register.
- These are only filled in when 1 is returned.
+ These are only filled in when true is returned.
TEXT_OFFSET_OUT, CFA_START_OUT, and CFA_END_OUT describe the CFA
- in other cases. These are only used when 0 is returned. */
+ in other cases. These are only used when false is returned. */
-extern int dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
- dwarf2_per_cu *data, int *regnum_out,
- LONGEST *offset_out,
- CORE_ADDR *text_offset_out,
- const gdb_byte **cfa_start_out,
- const gdb_byte **cfa_end_out);
+extern bool dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
+ dwarf2_per_cu *data, int *regnum_out,
+ LONGEST *offset_out,
+ CORE_ADDR *text_offset_out,
+ const gdb_byte **cfa_start_out,
+ const gdb_byte **cfa_end_out);
/* Allocate a new instance of the function unique data.
@@ -330,14 +330,14 @@ static inline void *dwarf2_frame_allocate_fn_data
return nullptr;
}
-static inline int dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
- struct dwarf2_per_cu_data *data,
- int *regnum_out, LONGEST *offset_out,
- CORE_ADDR *text_offset_out,
- const gdb_byte **cfa_start_out,
- const gdb_byte **cfa_end_out)
+static inline bool
+dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
+ struct dwarf2_per_cu_data *data, int *regnum_out,
+ LONGEST *offset_out, CORE_ADDR *text_offset_out,
+ const gdb_byte **cfa_start_out,
+ const gdb_byte **cfa_end_out)
{
- return 0;
+ return false;
}
static inline void
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 15/23] gdb/dwarf: change dwarf2_locexpr_baton_eval to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (13 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 14/23] gdb/dwarf: change dwarf2_fetch_cfa_info " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 16/23] gdb/dwarf: change base_types_equal_p " Simon Marchi
` (8 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: Ib22b4ca4365e9943cc17b0d510bf5590842eb258
---
gdb/dwarf2/loc.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 8dfd04461be0..c310fa3d8afd 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1577,9 +1577,9 @@ dwarf2_evaluate_loc_desc (struct type *type, const frame_info_ptr &frame,
before evaluation starts. PUSH_VALUES[0] is pushed first, then
PUSH_VALUES[1], and so on.
- Returns 1 on success, 0 otherwise. */
+ Returns true on success, false otherwise. */
-static int
+static bool
dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
const frame_info_ptr &frame,
const struct property_addr_info *addr_stack,
@@ -1588,7 +1588,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
bool *is_reference)
{
if (dlbaton->size == 0)
- return 0;
+ return false;
dwarf2_per_objfile *per_objfile = dlbaton->per_objfile;
dwarf2_per_cu *per_cu = dlbaton->per_cu;
@@ -1610,20 +1610,20 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
{
if (ex.error == NOT_AVAILABLE_ERROR)
{
- return 0;
+ return false;
}
else if (ex.error == NO_ENTRY_VALUE_ERROR)
{
if (entry_values_debug)
exception_print (gdb_stdout, ex);
- return 0;
+ return false;
}
else
throw;
}
if (result->optimized_out ())
- return 0;
+ return false;
if (result->lval () == lval_memory)
*valp = result->address ();
@@ -1635,7 +1635,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
*valp = value_as_address (result);
}
- return 1;
+ return true;
}
/* See dwarf2/loc.h. */
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 16/23] gdb/dwarf: change base_types_equal_p to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (14 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 15/23] gdb/dwarf: change dwarf2_locexpr_baton_eval " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 17/23] gdb/dwarf: change dwarf2_frame_signal_frame_p " Simon Marchi
` (7 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I66f13baf8fe2b15fa2bab9f3dcb60c3ad9e91d6a
---
gdb/dwarf2/expr.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index c253460ba34c..a5ea43e0bcc4 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -1353,13 +1353,15 @@ dwarf_expr_require_composition (const gdb_byte *op_ptr, const gdb_byte *op_end,
checks that might reasonably be needed to compare DWARF base
types. */
-static int
+static bool
base_types_equal_p (struct type *t1, struct type *t2)
{
if (t1->code () != t2->code ())
- return 0;
+ return false;
+
if (t1->is_unsigned () != t2->is_unsigned ())
- return 0;
+ return false;
+
return t1->length () == t2->length ();
}
@@ -2050,7 +2052,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
first = fetch (0);
pop ();
- if (! base_types_equal_p (first->type (), second->type ()))
+ if (!base_types_equal_p (first->type (), second->type ()))
error (_("Incompatible types on DWARF stack"));
switch (op)
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 17/23] gdb/dwarf: change dwarf2_frame_signal_frame_p to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (15 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 16/23] gdb/dwarf: change base_types_equal_p " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 18/23] gdb/dwarf: change piece_end_p " Simon Marchi
` (6 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: Iaa387e7c3eca9c8a131798442adcf0136e9eb16c
---
gdb/dwarf2/frame.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index be55b90df597..7012a7a4f12c 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -694,14 +694,15 @@ dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
/* Query the architecture-specific signal frame recognizer for
THIS_FRAME. */
-static int
+static bool
dwarf2_frame_signal_frame_p (struct gdbarch *gdbarch,
const frame_info_ptr &this_frame)
{
struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
if (ops->signal_frame_p == NULL)
- return 0;
+ return false;
+
return ops->signal_frame_p (gdbarch, this_frame);
}
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 18/23] gdb/dwarf: change piece_end_p to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (16 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 17/23] gdb/dwarf: change dwarf2_frame_signal_frame_p " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 19/23] gdb/dwarf: define type aliases for dwarf2_frame_ops function types Simon Marchi
` (5 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: Ia8f7f5a88161901f32415f16a0f911aeee50b6a8
---
gdb/dwarf2/loc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index c310fa3d8afd..273d3d942b5a 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -3132,7 +3132,7 @@ locexpr_get_symbol_read_needs (struct symbol *symbol)
/* Return true if DATA points to the end of a piece. END is one past
the last byte in the expression. */
-static int
+static bool
piece_end_p (const gdb_byte *data, const gdb_byte *end)
{
return data == end || data[0] == DW_OP_piece || data[0] == DW_OP_bit_piece;
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 19/23] gdb/dwarf: define type aliases for dwarf2_frame_ops function types
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (17 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 18/23] gdb/dwarf: change piece_end_p " Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 20/23] gdb/dwarf: change dwarf2_frame_ops to return bool Simon Marchi
` (4 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
This makes the code less verbose, and I think more readable.
Change-Id: I715669281d341bd15547e3eba82c716a953f2274
---
gdb/dwarf2/frame.c | 40 +++++++++++++---------------------------
gdb/dwarf2/frame.h | 45 +++++++++++++++++++++++----------------------
2 files changed, 36 insertions(+), 49 deletions(-)
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 7012a7a4f12c..0566fd516f5a 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -590,16 +590,14 @@ static void dwarf2_frame_default_init_reg (struct gdbarch *gdbarch,
struct dwarf2_frame_ops
{
/* Pre-initialize the register state REG for register REGNUM. */
- void (*init_reg) (struct gdbarch *, int, struct dwarf2_frame_state_reg *,
- const frame_info_ptr &)
- = dwarf2_frame_default_init_reg;
+ init_reg_ftype *init_reg = dwarf2_frame_default_init_reg;
/* Check whether the THIS_FRAME is a signal trampoline. */
- int (*signal_frame_p) (struct gdbarch *, const frame_info_ptr &) = nullptr;
+ signal_frame_p_ftype *signal_frame_p = nullptr;
/* Convert .eh_frame register number to DWARF register number, or
adjust .debug_frame register number. */
- int (*adjust_regnum) (struct gdbarch *, int, int) = nullptr;
+ adjust_regnum_ftype *adjust_regnum = nullptr;
};
/* Per-architecture data key. */
@@ -656,14 +654,9 @@ dwarf2_frame_default_init_reg (struct gdbarch *gdbarch, int regnum,
function for GDBARCH to INIT_REG. */
void
-dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
- void (*init_reg) (struct gdbarch *, int,
- struct dwarf2_frame_state_reg *,
- const frame_info_ptr &))
+dwarf2_frame_set_init_reg (gdbarch *gdbarch, init_reg_ftype *init_reg)
{
- struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
-
- ops->init_reg = init_reg;
+ get_frame_ops (gdbarch)->init_reg = init_reg;
}
/* Pre-initialize the register state REG for register REGNUM. */
@@ -673,22 +666,17 @@ dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
struct dwarf2_frame_state_reg *reg,
const frame_info_ptr &this_frame)
{
- struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
-
- ops->init_reg (gdbarch, regnum, reg, this_frame);
+ get_frame_ops (gdbarch)->init_reg (gdbarch, regnum, reg, this_frame);
}
/* Set the architecture-specific signal trampoline recognition
function for GDBARCH to SIGNAL_FRAME_P. */
void
-dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
- int (*signal_frame_p) (struct gdbarch *,
- const frame_info_ptr &))
+dwarf2_frame_set_signal_frame_p (gdbarch *gdbarch,
+ signal_frame_p_ftype *signal_frame_p)
{
- struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
-
- ops->signal_frame_p = signal_frame_p;
+ get_frame_ops (gdbarch)->signal_frame_p = signal_frame_p;
}
/* Query the architecture-specific signal frame recognizer for
@@ -710,13 +698,10 @@ dwarf2_frame_signal_frame_p (struct gdbarch *gdbarch,
register numbers. */
void
-dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
- int (*adjust_regnum) (struct gdbarch *,
- int, int))
+dwarf2_frame_set_adjust_regnum (gdbarch *gdbarch,
+ adjust_regnum_ftype *adjust_regnum)
{
- struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
-
- ops->adjust_regnum = adjust_regnum;
+ get_frame_ops (gdbarch)->adjust_regnum = adjust_regnum;
}
/* Translate a .eh_frame register to DWARF register, or adjust a .debug_frame
@@ -730,6 +715,7 @@ dwarf2_frame_adjust_regnum (struct gdbarch *gdbarch,
if (ops->adjust_regnum == NULL)
return regnum;
+
return ops->adjust_regnum (gdbarch, regnum, eh_frame_p);
}
diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h
index 47f9ed88f7c5..c3bbfcc03f59 100644
--- a/gdb/dwarf2/frame.h
+++ b/gdb/dwarf2/frame.h
@@ -198,6 +198,11 @@ struct dwarf2_frame_state
bool armcc_cfa_offsets_reversed = false;
};
+using init_reg_ftype = void (gdbarch *, int, dwarf2_frame_state_reg *,
+ const frame_info_ptr &);
+using signal_frame_p_ftype = int (gdbarch *, const frame_info_ptr &);
+using adjust_regnum_ftype = int (gdbarch *, int, int);
+
/* If DWARF supoprt was requested, create the real prototype for the
append_unwinders function. Otherwise, create a fake inline function.
@@ -210,25 +215,19 @@ struct dwarf2_frame_state
/* Set the architecture-specific register state initialization
function for GDBARCH to INIT_REG. */
-extern void dwarf2_frame_set_init_reg (
- gdbarch *gdbarch, void (*init_reg) (struct gdbarch *, int,
- dwarf2_frame_state_reg *,
- const frame_info_ptr &));
+void dwarf2_frame_set_init_reg (gdbarch *gdbarch, init_reg_ftype *init_reg);
/* Set the architecture-specific signal trampoline recognition
function for GDBARCH to SIGNAL_FRAME_P. */
-extern void dwarf2_frame_set_signal_frame_p
- (gdbarch *gdbarch, int (*signal_frame_p) (struct gdbarch *,
- const frame_info_ptr &));
+void dwarf2_frame_set_signal_frame_p (gdbarch *gdbarch,
+ signal_frame_p_ftype *signal_frame_p);
/* Set the architecture-specific adjustment of .eh_frame and .debug_frame
register numbers. */
-extern void
- dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
- int (*adjust_regnum) (struct gdbarch *,
- int, int));
+void dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
+ adjust_regnum_ftype *adjust_regnum);
/* Append the DWARF-2 frame unwinders to GDBARCH's list. */
@@ -300,10 +299,10 @@ extern void *dwarf2_frame_get_fn_data (const frame_info_ptr &this_frame,
static inline void dwarf2_append_unwinders (struct gdbarch *gdbarch) { }
-static inline void dwarf2_frame_set_init_reg (
- gdbarch *gdbarch, void (*init_reg) (struct gdbarch *,int,
- dwarf2_frame_state_reg *,
- const frame_info_ptr &)) { }
+static inline void
+dwarf2_frame_set_init_reg (gdbarch *gdbarch, init_reg_ftype *init_reg)
+{
+}
static inline const struct frame_base *
dwarf2_frame_base_sniffer (const frame_info_ptr &this_frame)
@@ -312,9 +311,11 @@ static inline const struct frame_base *
return nullptr;
}
-static inline void dwarf2_frame_set_signal_frame_p
- (gdbarch *gdbarch, int (*signal_frame_p) (struct gdbarch *,
- const frame_info_ptr &)) { }
+static inline void
+dwarf2_frame_set_signal_frame_p (gdbarch *gdbarch,
+ signal_frame_p_ftype *signal_frame_p)
+{
+}
static inline void *dwarf2_frame_get_fn_data (const frame_info_ptr &this_frame,
void **this_cache,
@@ -341,10 +342,10 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
}
static inline void
- dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
- int (*adjust_regnum) (struct gdbarch *,
- int, int))
-{}
+dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
+ adjust_regnum_ftype *adjust_regnum)
+{
+}
#endif /* DWARF_FORMAT_AVAILABLE */
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 20/23] gdb/dwarf: change dwarf2_frame_ops to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (18 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 19/23] gdb/dwarf: define type aliases for dwarf2_frame_ops function types Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 21/23] gdb/dwarf: use true/false in read_gdb_index_from_buffer Simon Marchi
` (3 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I0531b413823b1edc419be8f4977e9baa9efe3833
---
gdb/dwarf2/frame.h | 2 +-
gdb/i386-darwin-tdep.c | 2 +-
gdb/i386-darwin-tdep.h | 2 +-
gdb/i386-linux-tdep.c | 12 +++++-------
4 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h
index c3bbfcc03f59..6ecd5d0d6563 100644
--- a/gdb/dwarf2/frame.h
+++ b/gdb/dwarf2/frame.h
@@ -200,7 +200,7 @@ struct dwarf2_frame_state
using init_reg_ftype = void (gdbarch *, int, dwarf2_frame_state_reg *,
const frame_info_ptr &);
-using signal_frame_p_ftype = int (gdbarch *, const frame_info_ptr &);
+using signal_frame_p_ftype = bool (gdbarch *, const frame_info_ptr &);
using adjust_regnum_ftype = int (gdbarch *, int, int);
/* If DWARF supoprt was requested, create the real prototype for the
diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
index 76617a97a64e..b9ea7cb3f362 100644
--- a/gdb/i386-darwin-tdep.c
+++ b/gdb/i386-darwin-tdep.c
@@ -97,7 +97,7 @@ i386_darwin_sigcontext_addr (const frame_info_ptr &this_frame)
Without this function, the frame is recognized as a normal frame which is
not expected. */
-int
+bool
darwin_dwarf_signal_frame_p (struct gdbarch *gdbarch,
const frame_info_ptr &this_frame)
{
diff --git a/gdb/i386-darwin-tdep.h b/gdb/i386-darwin-tdep.h
index a0f88b39c280..1496e2829c19 100644
--- a/gdb/i386-darwin-tdep.h
+++ b/gdb/i386-darwin-tdep.h
@@ -27,6 +27,6 @@
extern int i386_darwin_thread_state_reg_offset[];
extern const int i386_darwin_thread_state_num_regs;
-int darwin_dwarf_signal_frame_p (struct gdbarch *, const frame_info_ptr &);
+bool darwin_dwarf_signal_frame_p (struct gdbarch *, const frame_info_ptr &);
#endif /* GDB_I386_DARWIN_TDEP_H */
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 4a4daabbeaa9..dae4a7b7eeba 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -250,10 +250,10 @@ i386_linux_sigtramp_p (const frame_info_ptr &this_frame)
|| strcmp ("__restore_rt", name) == 0);
}
-/* Return one if the PC of THIS_FRAME is in a signal trampoline which
+/* Return true if the PC of THIS_FRAME is in a signal trampoline which
may have DWARF-2 CFI. */
-static int
+static bool
i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
const frame_info_ptr &this_frame)
{
@@ -264,11 +264,9 @@ i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
/* If a vsyscall DSO is in use, the signal trampolines may have these
names. */
- if (name && (strcmp (name, "__kernel_sigreturn") == 0
- || strcmp (name, "__kernel_rt_sigreturn") == 0))
- return 1;
-
- return 0;
+ return (name != nullptr
+ && (streq (name, "__kernel_sigreturn")
+ || streq (name, "__kernel_rt_sigreturn")));
}
/* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 21/23] gdb/dwarf: use true/false in read_gdb_index_from_buffer
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (19 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 20/23] gdb/dwarf: change dwarf2_frame_ops to return bool Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 22/23] gdb/dwarf: change dwarf_block_to_sp_offset to return bool Simon Marchi
` (2 subsequent siblings)
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I92ee061796705394c8b305599c10b2c9f953ac82
---
gdb/dwarf2/read-gdb-index.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index 06fea0ea7519..ddbac684675f 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -441,8 +441,9 @@ read_gdb_index_from_buffer (const char *filename,
filename));
warning_printed = 1;
}
- return 0;
+ return false;
}
+
/* Version 7 indices generated by gold refer to the CU for a symbol instead
of the TU (for symbols coming from TUs),
http://sourceware.org/bugzilla/show_bug.cgi?id=15021.
@@ -454,7 +455,7 @@ read_gdb_index_from_buffer (const char *filename,
/* Indexes with higher version than the one supported by GDB may be no
longer backward compatible. */
if (version > 9)
- return 0;
+ return false;
map->version = version;
@@ -501,7 +502,7 @@ read_gdb_index_from_buffer (const char *filename,
symbol_table));
}
- return 1;
+ return true;
}
/* A helper for create_cus_from_gdb_index that handles a given list of
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 22/23] gdb/dwarf: change dwarf_block_to_sp_offset to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (20 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 21/23] gdb/dwarf: use true/false in read_gdb_index_from_buffer Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-11 18:05 ` [PATCH 23/23] gdb/dwarf: change dwarf_block_to_fb_offset " Simon Marchi
2026-03-12 12:59 ` [PATCH 00/23] int -> bool in dwarf2/ Tom Tromey
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I7607e0b1cbbbb0c7be0ec309d7d936154a910554
---
gdb/dwarf2/expr.c | 25 ++++++++++++-------------
gdb/dwarf2/expr.h | 10 +++++++---
gdb/dwarf2/read.c | 2 +-
3 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index a5ea43e0bcc4..217f494ebd3c 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -1493,11 +1493,9 @@ dwarf_block_to_fb_offset (const gdb_byte *buf, const gdb_byte *buf_end,
return 1;
}
-/* If <BUF..BUF_END] contains DW_FORM_block* with single DW_OP_bregSP(X) fill
- in SP_OFFSET_RETURN with the X offset and return 1. Otherwise return 0.
- The matched SP register number depends on GDBARCH. */
+/* See expr.h. */
-int
+bool
dwarf_block_to_sp_offset (struct gdbarch *gdbarch, const gdb_byte *buf,
const gdb_byte *buf_end, CORE_ADDR *sp_offset_return)
{
@@ -1505,7 +1503,8 @@ dwarf_block_to_sp_offset (struct gdbarch *gdbarch, const gdb_byte *buf,
int64_t sp_offset;
if (buf_end <= buf)
- return 0;
+ return false;
+
if (*buf >= DW_OP_breg0 && *buf <= DW_OP_breg31)
{
dwarf_reg = *buf - DW_OP_breg0;
@@ -1514,25 +1513,25 @@ dwarf_block_to_sp_offset (struct gdbarch *gdbarch, const gdb_byte *buf,
else
{
if (*buf != DW_OP_bregx)
- return 0;
+ return false;
+
buf++;
buf = gdb_read_uleb128 (buf, buf_end, &dwarf_reg);
if (buf == NULL)
- return 0;
+ return false;
}
if (dwarf_reg_to_regnum (gdbarch, dwarf_reg)
!= gdbarch_sp_regnum (gdbarch))
- return 0;
+ return false;
buf = gdb_read_sleb128 (buf, buf_end, &sp_offset);
if (buf == NULL)
- return 0;
- *sp_offset_return = sp_offset;
- if (buf != buf_end || sp_offset != (LONGEST) *sp_offset_return)
- return 0;
+ return false;
- return 1;
+ *sp_offset_return = sp_offset;
+
+ return buf == buf_end && sp_offset == (LONGEST) *sp_offset_return;
}
/* Return true if, for an expr evaluated in the context of FRAME, we can
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index e25492f29a7c..ad841658f632 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -278,9 +278,13 @@ int dwarf_block_to_dwarf_reg_deref (const gdb_byte *buf,
int dwarf_block_to_fb_offset (const gdb_byte *buf, const gdb_byte *buf_end,
CORE_ADDR *fb_offset_return);
-int dwarf_block_to_sp_offset (struct gdbarch *gdbarch, const gdb_byte *buf,
- const gdb_byte *buf_end,
- CORE_ADDR *sp_offset_return);
+/* If <BUF..BUF_END] contains DW_FORM_block* with single DW_OP_bregSP(X) fill
+ in SP_OFFSET_RETURN with the X offset and return true. Otherwise return
+ false. The matched SP register number depends on GDBARCH. */
+
+bool dwarf_block_to_sp_offset (struct gdbarch *gdbarch, const gdb_byte *buf,
+ const gdb_byte *buf_end,
+ CORE_ADDR *sp_offset_return);
/* Wrappers around the leb128 reader routines to simplify them for our
purposes. */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 74c6ab7eff7f..5e310afc3f92 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -8258,7 +8258,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
if (parameter->u.dwarf_reg != -1)
parameter->kind = CALL_SITE_PARAMETER_DWARF_REG;
else if (dwarf_block_to_sp_offset (gdbarch, block->data,
- &block->data[block->size],
+ &block->data[block->size],
¶meter->u.fb_offset))
parameter->kind = CALL_SITE_PARAMETER_FB_OFFSET;
else
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH 23/23] gdb/dwarf: change dwarf_block_to_fb_offset to return bool
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (21 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 22/23] gdb/dwarf: change dwarf_block_to_sp_offset to return bool Simon Marchi
@ 2026-03-11 18:05 ` Simon Marchi
2026-03-12 12:59 ` [PATCH 00/23] int -> bool in dwarf2/ Tom Tromey
23 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-11 18:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: If62adeb3bf302de07e0dab46a1b9fad6050df800
---
gdb/dwarf2/expr.c | 19 +++++++++----------
gdb/dwarf2/expr.h | 8 ++++++--
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 217f494ebd3c..222f563e2a95 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -1467,30 +1467,29 @@ dwarf_block_to_dwarf_reg_deref (const gdb_byte *buf, const gdb_byte *buf_end,
return dwarf_reg;
}
-/* If <BUF..BUF_END] contains DW_FORM_block* with single DW_OP_fbreg(X) fill
- in FB_OFFSET_RETURN with the X offset and return 1. Otherwise return 0. */
+/* See expr.h. */
-int
+bool
dwarf_block_to_fb_offset (const gdb_byte *buf, const gdb_byte *buf_end,
CORE_ADDR *fb_offset_return)
{
int64_t fb_offset;
if (buf_end <= buf)
- return 0;
+ return false;
if (*buf != DW_OP_fbreg)
- return 0;
+ return false;
+
buf++;
buf = gdb_read_sleb128 (buf, buf_end, &fb_offset);
if (buf == NULL)
- return 0;
- *fb_offset_return = fb_offset;
- if (buf != buf_end || fb_offset != (LONGEST) *fb_offset_return)
- return 0;
+ return false;
- return 1;
+ *fb_offset_return = fb_offset;
+
+ return buf == buf_end && fb_offset == (LONGEST) *fb_offset_return;
}
/* See expr.h. */
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index ad841658f632..eaa166935342 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -275,8 +275,12 @@ int dwarf_block_to_dwarf_reg_deref (const gdb_byte *buf,
const gdb_byte *buf_end,
CORE_ADDR *deref_size_return);
-int dwarf_block_to_fb_offset (const gdb_byte *buf, const gdb_byte *buf_end,
- CORE_ADDR *fb_offset_return);
+/* If <BUF..BUF_END] contains DW_FORM_block* with single DW_OP_fbreg(X) fill
+ in FB_OFFSET_RETURN with the X offset and return true. Otherwise return
+ false. */
+
+bool dwarf_block_to_fb_offset (const gdb_byte *buf, const gdb_byte *buf_end,
+ CORE_ADDR *fb_offset_return);
/* If <BUF..BUF_END] contains DW_FORM_block* with single DW_OP_bregSP(X) fill
in SP_OFFSET_RETURN with the X offset and return true. Otherwise return
--
2.53.0
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH 00/23] int -> bool in dwarf2/
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
` (22 preceding siblings ...)
2026-03-11 18:05 ` [PATCH 23/23] gdb/dwarf: change dwarf_block_to_fb_offset " Simon Marchi
@ 2026-03-12 12:59 ` Tom Tromey
2026-03-12 14:21 ` Simon Marchi
23 siblings, 1 reply; 28+ messages in thread
From: Tom Tromey @ 2026-03-12 12:59 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
Simon> Here is another bool-ification series. This one changes all (I believe,
Simon> but I might have missed some) functions in dwarf2/ to return bool
Simon> instead of int, where applicable. It is mostly trivial.
I read through these and they look fine to me.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH 00/23] int -> bool in dwarf2/
2026-03-12 12:59 ` [PATCH 00/23] int -> bool in dwarf2/ Tom Tromey
@ 2026-03-12 14:21 ` Simon Marchi
0 siblings, 0 replies; 28+ messages in thread
From: Simon Marchi @ 2026-03-12 14:21 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 2026-03-12 08:59, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>
> Simon> Here is another bool-ification series. This one changes all (I believe,
> Simon> but I might have missed some) functions in dwarf2/ to return bool
> Simon> instead of int, where applicable. It is mostly trivial.
>
> I read through these and they look fine to me.
> Approved-By: Tom Tromey <tom@tromey.com>
>
> Tom
Thanks, will push shortly.
Simon
^ permalink raw reply [flat|nested] 28+ messages in thread