Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 22/23] gdb/dwarf: change dwarf_block_to_sp_offset to return bool
Date: Wed, 11 Mar 2026 14:05:47 -0400	[thread overview]
Message-ID: <20260311180825.720803-23-simon.marchi@efficios.com> (raw)
In-Reply-To: <20260311180825.720803-1-simon.marchi@efficios.com>

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],
 					     &parameter->u.fb_offset))
 	    parameter->kind = CALL_SITE_PARAMETER_FB_OFFSET;
 	  else
-- 
2.53.0


  parent reply	other threads:[~2026-03-11 18:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` [PATCH 03/23] gdb/dwarf: change die_is_declaration " Simon Marchi
2026-03-11 18:05 ` [PATCH 04/23] gdb/dwarf: change need_gnat_info " Simon Marchi
2026-03-11 18:05 ` [PATCH 05/23] gdb/dwarf: change attr_to_dynamic_prop " Simon Marchi
2026-03-11 18:05 ` [PATCH 06/23] gdb/dwarf: change dwarf2_is_constructor " Simon Marchi
2026-03-11 18:05 ` [PATCH 07/23] gdb/dwarf: change is_vtable_name " Simon Marchi
2026-03-11 18:05 ` [PATCH 08/23] gdb/dwarf: change prototyped_function_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 09/23] gdb/dwarf: change dwarf2_ranges_process " Simon Marchi
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
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 ` [PATCH 12/23] gdb/dwarf: change frame_is_tailcall to return bool Simon Marchi
2026-03-11 18:05 ` [PATCH 13/23] gdb/dwarf: change call_site_parameter_matches " Simon Marchi
2026-03-11 18:05 ` [PATCH 14/23] gdb/dwarf: change dwarf2_fetch_cfa_info " Simon Marchi
2026-03-11 18:05 ` [PATCH 15/23] gdb/dwarf: change dwarf2_locexpr_baton_eval " Simon Marchi
2026-03-11 18:05 ` [PATCH 16/23] gdb/dwarf: change base_types_equal_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 17/23] gdb/dwarf: change dwarf2_frame_signal_frame_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 18/23] gdb/dwarf: change piece_end_p " Simon Marchi
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 ` [PATCH 20/23] gdb/dwarf: change dwarf2_frame_ops to return bool Simon Marchi
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 [this message]
2026-03-11 18:05 ` [PATCH 23/23] gdb/dwarf: change dwarf_block_to_fb_offset to return bool Simon Marchi
2026-03-12 12:59 ` [PATCH 00/23] int -> bool in dwarf2/ Tom Tromey
2026-03-12 14:21   ` Simon Marchi

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=20260311180825.720803-23-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.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