Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCHv3 4/7] gdb: move block range recording into its own function
Date: Thu, 16 Oct 2025 18:49:50 +0100	[thread overview]
Message-ID: <1023052882f93ee1338daa406eabc18be22f8f00.1760636870.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1760636870.git.aburgess@redhat.com>

Like the previous commit, this is a refactor that makes a later commit
in this series easier.  The later commit improves GDB's ability to
debug optimised code.  To do this I propose to "fix" the address
ranges of some inline blocks.

In order to know which blocks to fix, I need to record the end address
of inline blocks.

And so, I'd like to create a single common function where block ranges
are recorded, in a later commit I can then hook into this function to
record the block's end address(es).  This commit sets up this single
common function.

The new function I'm adding dwarf2_record_single_block_range, takes a
currently unused argument unrel_high.  This argument will be needed in
the later commit.  I've added it now as this will allow the later
commit to be smaller and more focused.  I only plan to push this
commit as part of the larger series, so I don't think adding
the (currently) unused argument is too much of a problem.

There should be no user visible change after this commit.
---
 gdb/dwarf2/read.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 6c5157ea8d4..023cb07edd8 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9940,6 +9940,21 @@ dwarf2_record_block_entry_pc (struct die_info *die, struct block *block,
     }
 }
 
+/* Helper function for dwarf2_record_block_ranges.  This function records
+   the address range for a single BLOCK.  LOW and HIGH are the block's
+   range, these addresses are inclusive, so LOW is the first address in
+   the range, and HIGH is the last address inside the range.  UNREL_HIGH
+   is the unrelocated, exclusive version of HIGH, that is, HIGH is the
+   first address outside the range of BLOCK.  */
+
+static void
+dwarf2_record_single_block_range (struct dwarf2_cu *cu, struct block *block,
+				  CORE_ADDR low, CORE_ADDR high,
+				  unrelocated_addr unrel_high)
+{
+  cu->get_builder ()->record_block_range (block, low, high);
+}
+
 /* Record the address ranges for BLOCK, offset by BASEADDR, as given
    in DIE.  Also set the entry PC for BLOCK.  */
 
@@ -10008,7 +10023,8 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
 	     in GDB's internal structures, it's just more to search
 	     through, and it will never match any address.  */
 	  if (high >= low)
-	    cu->get_builder ()->record_block_range (block, low, high);
+	    dwarf2_record_single_block_range (cu, block, low, high,
+					      unrel_high);
 	}
 
       attr = dwarf2_attr (die, DW_AT_ranges, cu);
@@ -10038,8 +10054,8 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
 	  {
 	    CORE_ADDR abs_start = per_objfile->relocate (start);
 	    CORE_ADDR abs_end = per_objfile->relocate (end);
-	    cu->get_builder ()->record_block_range (block, abs_start,
-						    abs_end - 1);
+	    dwarf2_record_single_block_range (cu, block, abs_start,
+					      abs_end - 1, end);
 	    blockvec.emplace_back (abs_start, abs_end);
 	  });
 
-- 
2.47.1


  parent reply	other threads:[~2025-10-16 17:52 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-20 10:20 [PATCH 0/7] Inline Function Optimised Code Debug Improvements Andrew Burgess
2025-07-20 10:20 ` [PATCH 1/7] gdb: improve line number lookup around inline functions Andrew Burgess
2025-07-20 10:20 ` [PATCH 2/7] gdb: handle empty ranges for inline subroutines Andrew Burgess
2025-07-20 10:20 ` [PATCH 3/7] gdb: split dwarf line table parsing in two Andrew Burgess
2025-07-20 10:20 ` [PATCH 4/7] gdb: move block range recording into its own function Andrew Burgess
2025-07-20 10:20 ` [PATCH 5/7] gdb: create address map after parsing all DIE Andrew Burgess
2025-07-20 10:20 ` [PATCH 6/7] gdb: record block end addresses while parsing DIEs Andrew Burgess
2025-07-20 10:20 ` [PATCH 7/7] gdb: fix-up truncated inline function block ranges Andrew Burgess
2025-08-01  8:58 ` [PATCHv2 0/7] Inline Function Optimised Code Debug Improvements Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 1/7] gdb: improve line number lookup around inline functions Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 2/7] gdb: handle empty ranges for inline subroutines Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 3/7] gdb: split dwarf line table parsing in two Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 4/7] gdb: move block range recording into its own function Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 5/7] gdb: create address map after parsing all DIE Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 6/7] gdb: record block end addresses while parsing DIEs Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 7/7] gdb: fix-up truncated inline function block ranges Andrew Burgess
2025-10-16 17:49   ` [PATCHv3 0/7] Inline Function Optimised Code Debug Improvements Andrew Burgess
2025-10-16 17:49     ` [PATCHv3 1/7] gdb: improve line number lookup around inline functions Andrew Burgess
2025-10-27 22:22       ` Tom Tromey
2025-12-17 14:32         ` Andrew Burgess
2025-12-17 14:48           ` Tom de Vries
2025-12-18 14:46             ` Andrew Burgess
2025-10-16 17:49     ` [PATCHv3 2/7] gdb: handle empty ranges for inline subroutines Andrew Burgess
2025-10-16 17:49     ` [PATCHv3 3/7] gdb: split dwarf line table parsing in two Andrew Burgess
2025-10-16 17:49     ` Andrew Burgess [this message]
2025-10-27 22:45       ` [PATCHv3 4/7] gdb: move block range recording into its own function Tom Tromey
2025-10-16 17:49     ` [PATCHv3 5/7] gdb: create address map after parsing all DIE Andrew Burgess
2025-10-27 22:56       ` Tom Tromey
2026-01-02 16:36         ` Andrew Burgess
2026-01-05 20:03           ` Tom Tromey
2026-01-05 21:37             ` Andrew Burgess
2026-01-06  0:53               ` Tom Tromey
2025-10-16 17:49     ` [PATCHv3 6/7] gdb: record block end addresses while parsing DIEs Andrew Burgess
2025-10-27 23:00       ` Tom Tromey
2025-10-16 17:49     ` [PATCHv3 7/7] gdb: fix-up truncated inline function block ranges Andrew Burgess
2026-02-04 10:43     ` [PATCHv3 0/7] Inline Function Optimised Code Debug Improvements Andrew Burgess
2025-08-01 15:41 ` [PATCH " Sam James

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=1023052882f93ee1338daa406eabc18be22f8f00.1760636870.git.aburgess@redhat.com \
    --to=aburgess@redhat.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