Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] gdb/block: make find_iterator_compunit_symtab a method of block_iterator
@ 2026-01-30  2:55 simon.marchi
  2026-01-30  2:55 ` [PATCH 2/3] gdb/symtab: make compunit_symtab::includes a std::vector simon.marchi
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: simon.marchi @ 2026-01-30  2:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

I noticed some code in bkscm_print_block_syms_progress_smob peeking a
bit in the implementation details of block_iterator, and doing
essentially the same thing as the existing static function
find_iterator_compunit_symtab.

Change find_iterator_compunit_symtab to become
block_iterator::compunit_symtab, and use it in
bkscm_print_block_syms_progress_smob.

Change-Id: I344a2155a2edb5d278e98684c71f1ee161e8d1d4
---
 gdb/block.c           | 19 ++++++++-----------
 gdb/block.h           |  4 ++++
 gdb/guile/scm-block.c |  7 ++-----
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/gdb/block.c b/gdb/block.c
index 0ee29d9e3f26..fa2246383d1e 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -440,15 +440,14 @@ initialize_block_iterator (const struct block *block,
     }
 }
 
-/* A helper function that finds the current compunit over whose static
-   or global block we should iterate.  */
+/* See block.h.  */
 
-static struct compunit_symtab *
-find_iterator_compunit_symtab (struct block_iterator *iterator)
+compunit_symtab *
+block_iterator::compunit_symtab () const
 {
-  if (iterator->idx == -1)
-    return iterator->d.compunit_symtab;
-  return iterator->d.compunit_symtab->includes[iterator->idx];
+  if (this->idx == -1)
+    return this->d.compunit_symtab;
+  return this->d.compunit_symtab->includes[this->idx];
 }
 
 /* Perform a single step for a plain block iterator, iterating across
@@ -466,8 +465,7 @@ block_iterator_step (struct block_iterator *iterator, int first)
     {
       if (first)
 	{
-	  struct compunit_symtab *cust
-	    = find_iterator_compunit_symtab (iterator);
+	  compunit_symtab *cust = iterator->compunit_symtab ();
 	  const struct block *block;
 
 	  /* Iteration is complete.  */
@@ -508,8 +506,7 @@ block_iter_match_step (struct block_iterator *iterator,
     {
       if (first)
 	{
-	  struct compunit_symtab *cust
-	    = find_iterator_compunit_symtab (iterator);
+	  compunit_symtab *cust = iterator->compunit_symtab ();
 	  const struct block *block;
 
 	  /* Iteration is complete.  */
diff --git a/gdb/block.h b/gdb/block.h
index c3d060af92fb..535db5ced51d 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -553,6 +553,10 @@ extern const struct block *block_for_pc_sect (CORE_ADDR, struct obj_section *);
 
 struct block_iterator
 {
+/* Return the compunit over whose static or global block the iterator currently
+   iterates.  Return nullptr is the iteration is finished.  */
+  struct compunit_symtab *compunit_symtab () const;
+
   /* If we're iterating over a single block, this holds the block.
      Otherwise, it holds the canonical compunit.  */
 
diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c
index c1edd2b5782a..5db73ec917e1 100644
--- a/gdb/guile/scm-block.c
+++ b/gdb/guile/scm-block.c
@@ -535,16 +535,13 @@ bkscm_print_block_syms_progress_smob (SCM self, SCM port,
 	case GLOBAL_BLOCK:
 	case STATIC_BLOCK:
 	  {
-	    struct compunit_symtab *cust;
-
 	    gdbscm_printf (port, " %s",
 			   i_smob->iter.which == GLOBAL_BLOCK
 			   ? "global" : "static");
 	    if (i_smob->iter.idx != -1)
 	      gdbscm_printf (port, " @%d", i_smob->iter.idx);
-	    cust = (i_smob->iter.idx == -1
-		    ? i_smob->iter.d.compunit_symtab
-		    : i_smob->iter.d.compunit_symtab->includes[i_smob->iter.idx]);
+
+	    compunit_symtab *cust = i_smob->iter.compunit_symtab ();
 	    gdbscm_printf (port, " %s",
 			   symtab_to_filename_for_display
 			     (cust->primary_filetab ()));

base-commit: be3c73b4610a7ccf915daca693565bc895f3584e
-- 
2.52.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-02-05 19:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-30  2:55 [PATCH 1/3] gdb/block: make find_iterator_compunit_symtab a method of block_iterator simon.marchi
2026-01-30  2:55 ` [PATCH 2/3] gdb/symtab: make compunit_symtab::includes a std::vector simon.marchi
2026-02-05 18:38   ` Tom Tromey
2026-01-30  2:55 ` [PATCH 3/3] gdb/block: bool-ify some parameters simon.marchi
2026-02-03 17:36   ` [PATCH] gdb/dwarf2: don't search included symtabs recursively Simon Marchi
2026-02-05 18:53     ` Tom Tromey
2026-02-05 19:36       ` Simon Marchi
2026-02-05 18:38   ` [PATCH 3/3] gdb/block: bool-ify some parameters Tom Tromey
2026-02-05 17:41 ` [PATCH 1/3] gdb/block: make find_iterator_compunit_symtab a method of block_iterator Tom Tromey
2026-02-05 19:33   ` Simon Marchi
2026-02-05 18:46 ` Tom Tromey
2026-02-05 19:17   ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox