Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function
@ 2026-04-10 10:12 Tom de Vries
  2026-04-10 10:12 ` [PATCH v4 1/4] [gdb/testsuite] Extend gdb.opt/inline-cmds.exp Tom de Vries
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Tom de Vries @ 2026-04-10 10:12 UTC (permalink / raw)
  To: gdb-patches

This patch series consisting of four patches.

The first patch extends test-case gdb.opt/inline-cmds.exp.

The second patch does some refactoring, to make the following fix minimal.

The third patch contains a fix for PR33981.

The fourth patch does a cleanup in function print_stop_location.

A v1 was submitted here [1].

Changes in v2 [2]:
- added two refactoring patches
- changed approach after review comment by Andrew, changing
  in_step_start_function usage to notice stepping in and out of inlined
  functions

Changes in v3 [3]:
- dropped first refactoring patch
- merged second refactoring patch into patch containing fix
- changed approach from using find_symbol_for_pc_sect_maybe_inline to using
  get_frame_function
- extended test-case gdb.opt/inline-cmds.exp
- added patch with cleanup in function print_stop_location

Changes in v4:
- factored out patch extending test-case gdb.opt/inline-cmds.exp
- re-instated refactoring patch
- updated cleanup patch to use selected frame instead of current frame

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33981

[1] v1 https://sourceware.org/pipermail/gdb-patches/2026-March/225916.html
[2] v2 (RFC) https://sourceware.org/pipermail/gdb-patches/2026-March/226269.html
[3] v3 https://sourceware.org/pipermail/gdb-patches/2026-April/226330.html

Andrew Burgess (2):
  [gdb/testsuite] Extend gdb.opt/inline-cmds.exp
  gdb: use get_current_frame consistently in print_stop_location

Tom de Vries (2):
  [gdb] Add thread_control_state::step_start_function methods
  gdb: fix missing print frame when stepping out of function

 gdb/gdbthread.h                               | 36 ++++++++++++++-
 gdb/infcmd.c                                  |  3 +-
 gdb/infrun.c                                  | 25 ++++++-----
 .../gdb.dwarf2/dw2-extend-inline-block.exp    | 45 +++++++++++++++++--
 gdb/testsuite/gdb.opt/inline-cmds.exp         | 33 +++++++++-----
 5 files changed, 113 insertions(+), 29 deletions(-)


base-commit: d7e49fd331d5a9a66d467c7d5cb4b5fc156a1ee0
-- 
2.51.0


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

* [PATCH v4 1/4] [gdb/testsuite] Extend gdb.opt/inline-cmds.exp
  2026-04-10 10:12 [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Tom de Vries
@ 2026-04-10 10:12 ` Tom de Vries
  2026-04-10 10:12 ` [PATCH v4 2/4] [gdb] Add thread_control_state::step_start_function methods Tom de Vries
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries @ 2026-04-10 10:12 UTC (permalink / raw)
  To: gdb-patches

From: Andrew Burgess <aburgess@redhat.com>

When using this tentative patch [1], GDB regresses like this in test-case
gdb.opt/inline-cmds.exp:
...
 Temporary breakpoint 1, main () at inline-cmds.c:64
 64	  y = 8; /* set mi break here */
 (gdb) s
+main () at inline-cmds.c:66
 66	  result = func1 ();
 (gdb) s
 func1 () at inline-cmds.c:35
 35	  bar ();
 (gdb)
...
but the regression doesn't produce a FAIL.

The regression does produce a FAIL during the part of the test that runs in MI
mode.

Extend the test so the regression also produces a FAIL in CLI mode.

[1] https://sourceware.org/pipermail/gdb-patches/2026-March/226272.html
---
 gdb/testsuite/gdb.opt/inline-cmds.exp | 33 ++++++++++++++++++---------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/gdb/testsuite/gdb.opt/inline-cmds.exp b/gdb/testsuite/gdb.opt/inline-cmds.exp
index 12db0709fe6..9bfc32f58b3 100644
--- a/gdb/testsuite/gdb.opt/inline-cmds.exp
+++ b/gdb/testsuite/gdb.opt/inline-cmds.exp
@@ -176,24 +176,35 @@ if { $bt_test == 0 } {
 # "stop" at the call sites before entering them.
 runto_main
 
-set msg "step into func1"
-set saw_call_site 0
-gdb_test_multiple "list" $msg {
-    -re "($first|$opt).*$gdb_prompt $" {
+set saw_call_site false
+set saw_main_frame false
+# Don't send the command using gdb_test_multiple, as it will be
+# injected into the regexp that start with '^' and use '-wrap', and we
+# send a different command using 'send_gdb' within the gdb_test_multiple.
+send_gdb "list\r"
+gdb_test_multiple "" "step into func1" {
+    -re "^(list|step)\r\n" {
+	exp_continue
+    }
+    -re -wrap "^\[^\r\n\]*($first|$opt)\[^\r\n\]*" {
 	send_gdb "step\r"
 	exp_continue
     }
-    -re "result = func1.*$gdb_prompt $" {
-	set saw_call_site 1
+    -re -wrap "^\[^\r\n\]*y = 8\[^\r\n\]*" {
+	send_gdb "step\r"
+	exp_continue
+    }
+    -re "^main \\(\\) at \[^\r\n\]+\r\n" {
+	set saw_main_frame true
+	exp_continue
+    }
+    -re -wrap "^\[^\r\n\]*result = func1 \\(\\);" {
+	set saw_call_site true
 	send_gdb "step\r"
 	exp_continue
     }
     -re "func1 \\\(\\\) at .*\r\n$decimal.*bar \\\(\\\);\r\n$gdb_prompt $" {
-	if { $saw_call_site } {
-	    pass $msg
-	} else {
-	    fail $msg
-	}
+	gdb_assert { $saw_call_site && !$saw_main_frame } $gdb_test_name
     }
 }
 
-- 
2.51.0


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

* [PATCH v4 2/4] [gdb] Add thread_control_state::step_start_function methods
  2026-04-10 10:12 [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Tom de Vries
  2026-04-10 10:12 ` [PATCH v4 1/4] [gdb/testsuite] Extend gdb.opt/inline-cmds.exp Tom de Vries
@ 2026-04-10 10:12 ` Tom de Vries
  2026-04-10 10:12 ` [PATCH v4 3/4] gdb: fix missing print frame when stepping out of function Tom de Vries
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries @ 2026-04-10 10:12 UTC (permalink / raw)
  To: gdb-patches

Factor out all uses of thread_control_state::step_start_function into
methods, and make the field private.

Tested on x86_64-linux.

Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
---
 gdb/gdbthread.h | 36 ++++++++++++++++++++++++++++++++++--
 gdb/infcmd.c    |  2 +-
 gdb/infrun.c    | 13 ++++++-------
 3 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index d64bf6e5a01..224e6e4b657 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -154,8 +154,36 @@ struct thread_control_state
   CORE_ADDR step_range_start = 0;	/* Inclusive */
   CORE_ADDR step_range_end = 0;		/* Exclusive */
 
-  /* Function the thread was in as of last it started stepping.  */
-  struct symbol *step_start_function = nullptr;
+  /* Set m_step_start_function according to PC.  */
+  void set_step_start_function (CORE_ADDR pc)
+  {
+    m_step_start_function = find_symbol_for_pc (pc);
+  }
+
+  /* Reset m_step_start_function.  */
+  void reset_step_start_function ()
+  {
+    m_step_start_function = nullptr;
+  }
+
+  /* Return true if the function symbol for PC matches
+     m_step_start_function.  */
+  bool in_step_start_function (CORE_ADDR pc)
+  {
+    return m_step_start_function == find_symbol_for_pc (pc);
+  }
+
+  /* Return true if m_step_start_function is set.  */
+  bool step_start_function_p ()
+  {
+    return m_step_start_function != nullptr;
+  }
+
+  /* Return m_step_start_function.  */
+  struct symbol *step_start_function ()
+  {
+    return m_step_start_function;
+  }
 
   /* If GDB issues a target step request, and this is nonzero, the
      target should single-step this thread once, and then continue
@@ -208,6 +236,10 @@ struct thread_control_state
 
   /* True if the thread is evaluating a BP condition.  */
   bool in_cond_eval = false;
+
+private:
+  /* Function the thread was in as of last it started stepping.  */
+  struct symbol *m_step_start_function = nullptr;
 };
 
 /* Inferior thread specific part of `struct infcall_suspend_state'.  */
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index fa7b273ae57..a1df59e09f2 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -899,7 +899,7 @@ set_step_frame (thread_info *tp)
   set_step_info (tp, frame, sal);
 
   CORE_ADDR pc = get_frame_pc (frame);
-  tp->control.step_start_function = find_symbol_for_pc (pc);
+  tp->control.set_step_start_function (pc);
 }
 
 /* Step until outside of current statement.  */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 2c9a27325af..becd68a21ad 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3098,7 +3098,7 @@ clear_proceed_status_thread (struct thread_info *tp)
   tp->control.step_frame_id = null_frame_id;
   tp->control.step_stack_frame_id = null_frame_id;
   tp->control.step_over_calls = STEP_OVER_UNDEBUGGABLE;
-  tp->control.step_start_function = nullptr;
+  tp->control.reset_step_start_function ();
   tp->stop_requested = false;
 
   tp->control.stop_step = 0;
@@ -7745,9 +7745,9 @@ process_event_stop_test (struct execution_control_state *ecs)
   if (execution_direction != EXEC_REVERSE
       && ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE
       && in_solib_dynsym_resolve_code (ecs->event_thread->stop_pc ())
-      && (ecs->event_thread->control.step_start_function == nullptr
+      && (!ecs->event_thread->control.step_start_function_p ()
 	  || !in_solib_dynsym_resolve_code (
-	       ecs->event_thread->control.step_start_function->value_block ()
+	       ecs->event_thread->control.step_start_function ()->value_block ()
 		->entry_pc ())))
     {
       CORE_ADDR pc_after_resolver =
@@ -7871,8 +7871,8 @@ process_event_stop_test (struct execution_control_state *ecs)
 	   == ecs->event_thread->control.step_stack_frame_id)
 	  && ((ecs->event_thread->control.step_stack_frame_id
 	       != outer_frame_id)
-	      || (ecs->event_thread->control.step_start_function
-		  != find_symbol_for_pc (ecs->event_thread->stop_pc ())))))
+	      || !ecs->event_thread->control.in_step_start_function
+		    (ecs->event_thread->stop_pc ()))))
     {
       CORE_ADDR stop_pc = ecs->event_thread->stop_pc ();
       CORE_ADDR real_stop_pc;
@@ -9359,8 +9359,7 @@ print_stop_location (const target_waitstatus &ws)
       if (tp->control.stop_step
 	  && (tp->control.step_frame_id
 	      == get_frame_id (get_current_frame ()))
-	  && (tp->control.step_start_function
-	      == find_symbol_for_pc (tp->stop_pc ())))
+	  && tp->control.in_step_start_function (tp->stop_pc ()))
 	{
 	  symtab_and_line sal = find_frame_sal (get_selected_frame (nullptr));
 	  if (sal.symtab != tp->current_symtab)
-- 
2.51.0


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

* [PATCH v4 3/4] gdb: fix missing print frame when stepping out of function
  2026-04-10 10:12 [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Tom de Vries
  2026-04-10 10:12 ` [PATCH v4 1/4] [gdb/testsuite] Extend gdb.opt/inline-cmds.exp Tom de Vries
  2026-04-10 10:12 ` [PATCH v4 2/4] [gdb] Add thread_control_state::step_start_function methods Tom de Vries
@ 2026-04-10 10:12 ` Tom de Vries
  2026-04-10 10:12 ` [PATCH v4 4/4] gdb: use get_current_frame consistently in print_stop_location Tom de Vries
  2026-04-14 16:32 ` [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Andrew Burgess
  4 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries @ 2026-04-10 10:12 UTC (permalink / raw)
  To: gdb-patches

Consider test-case gdb.dwarf2/dw2-extend-inline-block.exp,
specifically the "contiguous block" prefix part, which can be stepped
through like this:

...
  $ gdb -q outputs/gdb.dwarf2/dw2-extend-inline-block/dw2-extend-inline-block-5
  Reading symbols from dw2-extend-inline-block-5...
  (gdb) start
  ... snip ...
  Temporary breakpoint 1, main () at dw2-extend-inline-block.c:35
  35	  /* main:2 */
  (gdb) s
  36	  /* main:3 */ foo ();				/* foo call line */
  (gdb)
  foo () at dw2-extend-inline-block.c:26
  26	  /* foo:1 */
  (gdb) s
  27	  /* foo:2 */
  (gdb) s
  28	  /* foo:3 */
  (gdb) s
  main () at dw2-extend-inline-block.c:37
  37	  /* main:4 */
  (gdb)
...

If we slightly modify the line program:

...
	DW_LNE_set_address main_4
+	DW_LNS_advance_line 1
	DW_LNS_copy

	DW_LNE_set_address main_5
-	DW_LNS_advance_line 1
	DW_LNS_negate_stmt
	DW_LNS_copy
...

we change the 36/0x401165 entry into a 37/0x401165 entry:

...
  File name                     Line number    Starting address    View    Stmt
  dw2-extend-inline-block.c              34            0x401116               x
  dw2-extend-inline-block.c              35            0x401129               x
  dw2-extend-inline-block.c              26            0x401138               x
  dw2-extend-inline-block.c              27            0x401147               x
  dw2-extend-inline-block.c              28            0x401156               x
  dw2-extend-inline-block.c              36            0x401156
 -dw2-extend-inline-block.c              36            0x401165
 +dw2-extend-inline-block.c              37            0x401165
  dw2-extend-inline-block.c              37            0x401174               x
  dw2-extend-inline-block.c              38            0x401183               x
  dw2-extend-inline-block.c              39            0x401192               x
  dw2-extend-inline-block.c              40            0x4011a1               x
  dw2-extend-inline-block.c               -            0x4011b7
...

As it happens, the fix to extend truncated inlined function blocks
doesn't work in this case.  This is PR gdb/33930.

We can work around this by making sure that the inlined function block
isn't truncated in the first place:

...
-			DW_AT_high_pc main_3 addr
+			DW_AT_high_pc main_4 addr
...

But then we still run into PR gdb/33981: the problem that gdb doesn't
notify us when stepping out of foo:

...
  (gdb) step^M
  28        /* foo:3 */^M
  (gdb) step^M
  37        /* main:4 */^M
  (gdb)
...

What happens is that the slightly different line program triggers a
different stepping path, which includes a case of "stepped to a
different frame, but it's not the start of a statement", which
refreshes the stepping info and consequently updates
tp->control.step_frame_id to the frame id of main.

So by the time we're stopped at line 37, and are trying to figure out
what to print in print_stop_location, this condition evaluates to
true:

...
      if (tp->control.stop_step
	  && (tp->control.step_frame_id
	      == get_frame_id (get_current_frame ()))
	  && (tp->control.step_start_function
	      == find_symbol_for_pc (tp->stop_pc ())))
...

and we get:

...
      /* Finished step in same frame and same file, just print source
	 line.  */
      source_flag = SRC_LINE;
...

It's good to realize here that because foo is inlined into main,
tp->control.step_start_function is not foo but main, so consequently
the step_start_function check (which checks if we are still in the
same function) also passes, even though we actually stepped from foo
into main.

The problem is the use of find_symbol_for_pc, this function
deliberately skips over inline frames and returns the symbol for the
innermost non-inline frame.

It might be tempting to think that we should switch to use
find_symbol_for_pc_sect_maybe_inline, which will return the symbol for
an inline frame, but this also has problems, specifically, attempting
this caused a regression in gdb.opt/inline-cmds.exp.  The previous
version of this patch, which showed the regression can be found here:

  https://inbox.sourceware.org/gdb-patches/20260331132342.1050954-1-tdevries@suse.de

At a given $pc the inferior might be reported as being within an
inline frame, or it might be reported as being in the containing
non-inline frame.  When the user performs a 'step' the
step_start_function needs to be set based on the function symbol of
the frame the inferior is actually reported in.  And we have a
function that gives us this information, get_frame_function.  So
instead of looking up the step_start_function based on the $pc value,
set it based on the frame.

Test gdb.dwarf2/dw2-extend-inline-block.exp is extended with the
additional test case described above.

Tested on x86_64-linux.

Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33930
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33981
---
 gdb/gdbthread.h                               | 12 ++---
 gdb/infcmd.c                                  |  3 +-
 gdb/infrun.c                                  |  5 +--
 .../gdb.dwarf2/dw2-extend-inline-block.exp    | 45 +++++++++++++++++--
 4 files changed, 51 insertions(+), 14 deletions(-)

diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 224e6e4b657..c56c4ce4036 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -154,10 +154,10 @@ struct thread_control_state
   CORE_ADDR step_range_start = 0;	/* Inclusive */
   CORE_ADDR step_range_end = 0;		/* Exclusive */
 
-  /* Set m_step_start_function according to PC.  */
-  void set_step_start_function (CORE_ADDR pc)
+  /* Set m_step_start_function according to FRAME.  */
+  void set_step_start_function (const frame_info_ptr &frame)
   {
-    m_step_start_function = find_symbol_for_pc (pc);
+    m_step_start_function = get_frame_function (frame);
   }
 
   /* Reset m_step_start_function.  */
@@ -166,11 +166,11 @@ struct thread_control_state
     m_step_start_function = nullptr;
   }
 
-  /* Return true if the function symbol for PC matches
+  /* Return true if the function symbol of FRAME matches
      m_step_start_function.  */
-  bool in_step_start_function (CORE_ADDR pc)
+  bool in_step_start_function (const frame_info_ptr &frame)
   {
-    return m_step_start_function == find_symbol_for_pc (pc);
+    return m_step_start_function == get_frame_function (frame);
   }
 
   /* Return true if m_step_start_function is set.  */
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index a1df59e09f2..c0d12be6e4a 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -898,8 +898,7 @@ set_step_frame (thread_info *tp)
   symtab_and_line sal = find_frame_sal (frame);
   set_step_info (tp, frame, sal);
 
-  CORE_ADDR pc = get_frame_pc (frame);
-  tp->control.set_step_start_function (pc);
+  tp->control.set_step_start_function (frame);
 }
 
 /* Step until outside of current statement.  */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index becd68a21ad..dea2a2cbd48 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -7871,8 +7871,7 @@ process_event_stop_test (struct execution_control_state *ecs)
 	   == ecs->event_thread->control.step_stack_frame_id)
 	  && ((ecs->event_thread->control.step_stack_frame_id
 	       != outer_frame_id)
-	      || !ecs->event_thread->control.in_step_start_function
-		    (ecs->event_thread->stop_pc ()))))
+	      || !ecs->event_thread->control.in_step_start_function (frame))))
     {
       CORE_ADDR stop_pc = ecs->event_thread->stop_pc ();
       CORE_ADDR real_stop_pc;
@@ -9359,7 +9358,7 @@ print_stop_location (const target_waitstatus &ws)
       if (tp->control.stop_step
 	  && (tp->control.step_frame_id
 	      == get_frame_id (get_current_frame ()))
-	  && tp->control.in_step_start_function (tp->stop_pc ()))
+	  && tp->control.in_step_start_function (get_current_frame ()))
 	{
 	  symtab_and_line sal = find_frame_sal (get_selected_frame (nullptr));
 	  if (sal.symtab != tp->current_symtab)
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-extend-inline-block.exp b/gdb/testsuite/gdb.dwarf2/dw2-extend-inline-block.exp
index 9e4798b53f3..481dfbdd134 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-extend-inline-block.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-extend-inline-block.exp
@@ -52,8 +52,11 @@ get_func_info main
 # Create DWARF for the test.  In this case, inline function 'foo' is created
 # with a contiguous address range that needs extending.
 
-proc build_dwarf_for_contiguous_block { asm_file } {
+proc build_dwarf_for_contiguous_block { asm_file {range_correct 0} {variant 0} } {
     Dwarf::assemble $asm_file {
+	upvar range_correct range_correct
+	upvar variant variant
+
 	declare_labels lines_table inline_func
 
 	cu { } {
@@ -83,7 +86,11 @@ proc build_dwarf_for_contiguous_block { asm_file } {
 			DW_AT_call_file 1 data1
 			DW_AT_call_line $::foo_call_line data1
 			DW_AT_low_pc main_1 addr
-			DW_AT_high_pc main_3 addr
+			if {$range_correct} {
+			    DW_AT_high_pc main_4 addr
+			} else {
+			    DW_AT_high_pc main_3 addr
+			}
 		    }
 		}
 	    }
@@ -120,10 +127,15 @@ proc build_dwarf_for_contiguous_block { asm_file } {
 		DW_LNS_copy
 
 		DW_LNE_set_address main_4
+		if {$variant == 1} {
+		    DW_LNS_advance_line 1
+		}
 		DW_LNS_copy
 
 		DW_LNE_set_address main_5
-		DW_LNS_advance_line 1
+		if {$variant == 0} {
+		    DW_LNS_advance_line 1
+		}
 		DW_LNS_negate_stmt
 		DW_LNS_copy
 
@@ -146,6 +158,22 @@ proc build_dwarf_for_contiguous_block { asm_file } {
     }
 }
 
+# Like build_dwarf_for_contiguous_block, but use a slightly different line
+# info by setting variant == 1.
+# Use range_correct 1, so we're not testing the fix for PR33930.
+
+proc build_dwarf_for_contiguous_block_2 { asm_file } {
+    return [build_dwarf_for_contiguous_block $asm_file 1 1]
+}
+
+# Like build_dwarf_for_contiguous_block, but use a slightly different line
+# info by setting variant == 1.
+# Use range_correct 0, so we're testing the fix for PR33930.
+
+proc build_dwarf_for_contiguous_block_3 { asm_file } {
+    return [build_dwarf_for_contiguous_block $asm_file 0 1]
+}
+
 # Assuming GDB is stopped at the entry $pc for 'foo', use 'maint info
 # blocks' to check the block for 'foo' is correct.  This function checks
 # 'foo' created by 'build_dwarf_for_contiguous_block'.
@@ -555,6 +583,12 @@ set test_list \
 	 [list "contiguous block" \
 	      build_dwarf_for_contiguous_block \
 	      check_contiguous_block] \
+	 [list "contiguous block 2" \
+	      build_dwarf_for_contiguous_block_2 \
+	      check_contiguous_block] \
+	 [list "contiguous block 3" \
+	      build_dwarf_for_contiguous_block_3 \
+	      check_contiguous_block] \
 	]
 
 # Run all the tests.
@@ -566,6 +600,11 @@ foreach test_spec $test_list {
     set build_dwarf_func [lindex $test_spec 1]
     set check_block_func [lindex $test_spec 2]
 
+    if {$build_dwarf_func == "build_dwarf_for_contiguous_block_3"} {
+	# Work around PR gdb/33930.
+	continue
+    }
+
     with_test_prefix $prefix {
 	set asm_file [standard_output_file ${testfile}-${suffix}.S]
 	$build_dwarf_func $asm_file
-- 
2.51.0


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

* [PATCH v4 4/4] gdb: use get_current_frame consistently in print_stop_location
  2026-04-10 10:12 [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Tom de Vries
                   ` (2 preceding siblings ...)
  2026-04-10 10:12 ` [PATCH v4 3/4] gdb: fix missing print frame when stepping out of function Tom de Vries
@ 2026-04-10 10:12 ` Tom de Vries
  2026-04-14 16:32 ` [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Andrew Burgess
  4 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries @ 2026-04-10 10:12 UTC (permalink / raw)
  To: gdb-patches

From: Andrew Burgess <aburgess@redhat.com>

In print_stop_location, in the PRINT_UNKNOWN case we currently use a
strange mix of get_current_frame and get_selected_frame.  This works
fine because at the point print_stop_location is called the selected
frame will always be the current frame, but calling these two
different functions is confusing, at least for me.

Since bpstat_print selects the frame to print (which usually is the current
frame, but not always), the correct frame to use is the selected frame after
the bpstat_print call.

Assign the selected frame to a variable print_frame, and use it throughout the
function.

There should be no user visible changes after this commit.

Co-Authored-By: Tom de Vries <tdevries@suse.de>
---
 gdb/infrun.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index dea2a2cbd48..19836c4d89e 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9349,7 +9349,12 @@ print_stop_location (const target_waitstatus &ws)
   struct thread_info *tp = inferior_thread ();
 
   bpstat_ret = bpstat_print (tp->control.stop_bpstat, ws.kind ());
-  switch (bpstat_ret)
+  /* Function bpstat_print selects the frame to print.  Typically, that is the
+     stop frame, in other words get_current_frame ().  But bpstat_print may
+     select a different frame, see for instance ada_catchpoint::print_it.  */
+  frame_info_ptr print_frame = get_selected_frame (nullptr);
+
+ switch (bpstat_ret)
     {
     case PRINT_UNKNOWN:
       /* FIXME: cagney/2002-12-01: Given that a frame ID does (or
@@ -9357,10 +9362,10 @@ print_stop_location (const target_waitstatus &ws)
 	 that when doing a frame comparison.  */
       if (tp->control.stop_step
 	  && (tp->control.step_frame_id
-	      == get_frame_id (get_current_frame ()))
-	  && tp->control.in_step_start_function (get_current_frame ()))
+	      == get_frame_id (print_frame))
+	  && tp->control.in_step_start_function (print_frame))
 	{
-	  symtab_and_line sal = find_frame_sal (get_selected_frame (nullptr));
+	  symtab_and_line sal = find_frame_sal (print_frame);
 	  if (sal.symtab != tp->current_symtab)
 	    {
 	      /* Finished step in same frame but into different file, print
@@ -9403,7 +9408,7 @@ print_stop_location (const target_waitstatus &ws)
      LOCATION: Print only location
      SRC_AND_LOC: Print location and source line.  */
   if (do_frame_printing)
-    print_stack_frame (get_selected_frame (nullptr), 0, source_flag, 1);
+    print_stack_frame (print_frame, 0, source_flag, 1);
 }
 
 /* See `print_stop_event` in infrun.h.  */
-- 
2.51.0


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

* Re: [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function
  2026-04-10 10:12 [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Tom de Vries
                   ` (3 preceding siblings ...)
  2026-04-10 10:12 ` [PATCH v4 4/4] gdb: use get_current_frame consistently in print_stop_location Tom de Vries
@ 2026-04-14 16:32 ` Andrew Burgess
  2026-04-14 20:41   ` Tom de Vries
  4 siblings, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2026-04-14 16:32 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

Tom de Vries <tdevries@suse.de> writes:

> This patch series consisting of four patches.
>
> The first patch extends test-case gdb.opt/inline-cmds.exp.
>
> The second patch does some refactoring, to make the following fix minimal.
>
> The third patch contains a fix for PR33981.
>
> The fourth patch does a cleanup in function print_stop_location.
>
> A v1 was submitted here [1].
>
> Changes in v2 [2]:
> - added two refactoring patches
> - changed approach after review comment by Andrew, changing
>   in_step_start_function usage to notice stepping in and out of inlined
>   functions
>
> Changes in v3 [3]:
> - dropped first refactoring patch
> - merged second refactoring patch into patch containing fix
> - changed approach from using find_symbol_for_pc_sect_maybe_inline to using
>   get_frame_function
> - extended test-case gdb.opt/inline-cmds.exp
> - added patch with cleanup in function print_stop_location
>
> Changes in v4:
> - factored out patch extending test-case gdb.opt/inline-cmds.exp
> - re-instated refactoring patch
> - updated cleanup patch to use selected frame instead of current frame

Thanks for all your work on this series.

I don't fully see the need for the split between patches #2 and #3, but
I don't object if that's your preference.  I think this is looking good.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew



>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33981
>
> [1] v1 https://sourceware.org/pipermail/gdb-patches/2026-March/225916.html
> [2] v2 (RFC) https://sourceware.org/pipermail/gdb-patches/2026-March/226269.html
> [3] v3 https://sourceware.org/pipermail/gdb-patches/2026-April/226330.html
>
> Andrew Burgess (2):
>   [gdb/testsuite] Extend gdb.opt/inline-cmds.exp
>   gdb: use get_current_frame consistently in print_stop_location
>
> Tom de Vries (2):
>   [gdb] Add thread_control_state::step_start_function methods
>   gdb: fix missing print frame when stepping out of function
>
>  gdb/gdbthread.h                               | 36 ++++++++++++++-
>  gdb/infcmd.c                                  |  3 +-
>  gdb/infrun.c                                  | 25 ++++++-----
>  .../gdb.dwarf2/dw2-extend-inline-block.exp    | 45 +++++++++++++++++--
>  gdb/testsuite/gdb.opt/inline-cmds.exp         | 33 +++++++++-----
>  5 files changed, 113 insertions(+), 29 deletions(-)
>
>
> base-commit: d7e49fd331d5a9a66d467c7d5cb4b5fc156a1ee0
> -- 
> 2.51.0


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

* Re: [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function
  2026-04-14 16:32 ` [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Andrew Burgess
@ 2026-04-14 20:41   ` Tom de Vries
  0 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries @ 2026-04-14 20:41 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 4/14/26 6:32 PM, Andrew Burgess wrote:
> Tom de Vries <tdevries@suse.de> writes:
> 
>> This patch series consisting of four patches.
>>
>> The first patch extends test-case gdb.opt/inline-cmds.exp.
>>
>> The second patch does some refactoring, to make the following fix minimal.
>>
>> The third patch contains a fix for PR33981.
>>
>> The fourth patch does a cleanup in function print_stop_location.
>>
>> A v1 was submitted here [1].
>>
>> Changes in v2 [2]:
>> - added two refactoring patches
>> - changed approach after review comment by Andrew, changing
>>    in_step_start_function usage to notice stepping in and out of inlined
>>    functions
>>
>> Changes in v3 [3]:
>> - dropped first refactoring patch
>> - merged second refactoring patch into patch containing fix
>> - changed approach from using find_symbol_for_pc_sect_maybe_inline to using
>>    get_frame_function
>> - extended test-case gdb.opt/inline-cmds.exp
>> - added patch with cleanup in function print_stop_location
>>
>> Changes in v4:
>> - factored out patch extending test-case gdb.opt/inline-cmds.exp
>> - re-instated refactoring patch
>> - updated cleanup patch to use selected frame instead of current frame
> 
> Thanks for all your work on this series.
> 
> I don't fully see the need for the split between patches #2 and #3, but
> I don't object if that's your preference.  I think this is looking good.
> 

Thanks Andrew, pushed.

- Tom

> Approved-By: Andrew Burgess <aburgess@redhat.com>
> 
> Thanks,
> Andrew
> 
> 
> 
>>
>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33981
>>
>> [1] v1 https://sourceware.org/pipermail/gdb-patches/2026-March/225916.html
>> [2] v2 (RFC) https://sourceware.org/pipermail/gdb-patches/2026-March/226269.html
>> [3] v3 https://sourceware.org/pipermail/gdb-patches/2026-April/226330.html
>>
>> Andrew Burgess (2):
>>    [gdb/testsuite] Extend gdb.opt/inline-cmds.exp
>>    gdb: use get_current_frame consistently in print_stop_location
>>
>> Tom de Vries (2):
>>    [gdb] Add thread_control_state::step_start_function methods
>>    gdb: fix missing print frame when stepping out of function
>>
>>   gdb/gdbthread.h                               | 36 ++++++++++++++-
>>   gdb/infcmd.c                                  |  3 +-
>>   gdb/infrun.c                                  | 25 ++++++-----
>>   .../gdb.dwarf2/dw2-extend-inline-block.exp    | 45 +++++++++++++++++--
>>   gdb/testsuite/gdb.opt/inline-cmds.exp         | 33 +++++++++-----
>>   5 files changed, 113 insertions(+), 29 deletions(-)
>>
>>
>> base-commit: d7e49fd331d5a9a66d467c7d5cb4b5fc156a1ee0
>> -- 
>> 2.51.0
> 


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

end of thread, other threads:[~2026-04-14 20:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-10 10:12 [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Tom de Vries
2026-04-10 10:12 ` [PATCH v4 1/4] [gdb/testsuite] Extend gdb.opt/inline-cmds.exp Tom de Vries
2026-04-10 10:12 ` [PATCH v4 2/4] [gdb] Add thread_control_state::step_start_function methods Tom de Vries
2026-04-10 10:12 ` [PATCH v4 3/4] gdb: fix missing print frame when stepping out of function Tom de Vries
2026-04-10 10:12 ` [PATCH v4 4/4] gdb: use get_current_frame consistently in print_stop_location Tom de Vries
2026-04-14 16:32 ` [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Andrew Burgess
2026-04-14 20:41   ` Tom de Vries

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