Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb] Drop nullptr in "get_selected_frame (nullptr)"
@ 2026-06-04 20:01 Tom de Vries
  2026-06-05 20:55 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2026-06-04 20:01 UTC (permalink / raw)
  To: gdb-patches

I came across "get_selected_frame (nullptr)", and realized nullptr is the
default argument, so this can be simplified to "get_selected_frame ()".

Do so using the following script:
...
$ find gdb* -type f -name "*.[ch]" -o -name "*.cc" \
    | xargs sed -i 's/get_selected_frame (nullptr)/get_selected_frame ()/'
...
and likewise for "get_selected_frame (NULL)".

Tested on x86_64-linux.
---
 gdb/ada-lang.c                      |  2 +-
 gdb/ada-tasks.c                     |  6 +++---
 gdb/arch-utils.c                    |  2 +-
 gdb/breakpoint.c                    |  4 ++--
 gdb/bsd-kvm.c                       |  6 +++---
 gdb/cli/cli-cmds.c                  |  2 +-
 gdb/compile/compile-c-symbols.c     |  2 +-
 gdb/compile/compile-cplus-symbols.c |  2 +-
 gdb/compile/compile-loc2c.c         |  2 +-
 gdb/compile/compile.c               |  4 ++--
 gdb/corelow.c                       |  2 +-
 gdb/dwarf2/loc.c                    |  2 +-
 gdb/eval.c                          |  2 +-
 gdb/frame.c                         |  2 +-
 gdb/infcmd.c                        | 12 ++++++------
 gdb/infrun.c                        |  2 +-
 gdb/language.c                      |  4 ++--
 gdb/mi/mi-cmd-stack.c               |  6 +++---
 gdb/mi/mi-interp.c                  |  2 +-
 gdb/mi/mi-main.c                    | 10 +++++-----
 gdb/namespace.c                     |  2 +-
 gdb/printcmd.c                      |  2 +-
 gdb/record-btrace.c                 |  2 +-
 gdb/record-full.c                   |  4 ++--
 gdb/stack.c                         |  6 +++---
 gdb/thread.c                        |  4 ++--
 gdb/tracepoint.c                    |  2 +-
 gdb/tui/tui-hooks.c                 |  4 ++--
 gdb/tui/tui-regs.c                  |  2 +-
 gdb/tui/tui-source.c                |  2 +-
 gdb/varobj.c                        |  4 ++--
 31 files changed, 55 insertions(+), 55 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index cb741647d47..bb044e2c5a0 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13167,7 +13167,7 @@ ada_exceptions_list_1 (compiled_regex *preg)
   if (has_stack_frames ())
     {
       prev_len = result.size ();
-      ada_add_exceptions_from_frame (preg, get_selected_frame (NULL),
+      ada_add_exceptions_from_frame (preg, get_selected_frame (),
 				     &result);
       if (result.size () > prev_len)
 	sort_remove_dups_ada_exceptions_list (&result, prev_len);
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 6bd6600b802..f55afcc915d 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -1382,11 +1382,11 @@ task_command_1 (const char *taskno_str, int from_tty, struct inferior *inf)
 	   task_to_str (taskno, task_info).c_str ());
 
   switch_to_thread (tp);
-  ada_find_printable_frame (get_selected_frame (NULL));
+  ada_find_printable_frame (get_selected_frame ());
   gdb_printf (_("[Switching to task %s]\n"),
 	      task_to_str (taskno, task_info).c_str ());
-  print_stack_frame (get_selected_frame (NULL),
-		     frame_relative_level (get_selected_frame (NULL)),
+  print_stack_frame (get_selected_frame (),
+		     frame_relative_level (get_selected_frame ()),
 		     SRC_AND_LOC, 1);
 }
 
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 5e15fa5b434..e959788bd3b 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -844,7 +844,7 @@ struct gdbarch *
 get_current_arch (void)
 {
   if (has_stack_frames ())
-    return get_frame_arch (get_selected_frame (NULL));
+    return get_frame_arch (get_selected_frame ());
   else
     return current_inferior ()->arch ();
 }
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 101dc57ee6b..199b52433b3 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2295,7 +2295,7 @@ update_watchpoint (struct watchpoint *b, bool reparse)
       if (b->exp_valid_block == nullptr)
 	wp_pspace = current_program_space;
       else
-	wp_pspace = get_frame_program_space (get_selected_frame (NULL));
+	wp_pspace = get_frame_program_space (get_selected_frame ());
 
       /* Look at each value on the value chain.  */
       gdb_assert (!val_chain.empty ());
@@ -10981,7 +10981,7 @@ until_break_command (const char *arg, int from_tty, int anywhere)
      may need to switch threads), so do any frame handling before
      that.  */
 
-  frame = get_selected_frame (NULL);
+  frame = get_selected_frame ();
   frame_gdbarch = get_frame_arch (frame);
   stack_frame_id = get_stack_frame_id (frame);
   caller_frame_id = frame_unwind_caller_id (frame);
diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c
index ca7aed7ec42..3cf217b88a4 100644
--- a/gdb/bsd-kvm.c
+++ b/gdb/bsd-kvm.c
@@ -137,7 +137,7 @@ bsd_kvm_target_open (const char *arg, int from_tty)
   target_fetch_registers (get_thread_regcache (thr), -1);
 
   reinit_frame_cache ();
-  print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
+  print_stack_frame (get_selected_frame (), 0, SRC_AND_LOC, 1);
 }
 
 void
@@ -335,7 +335,7 @@ bsd_kvm_proc_cmd (const char *arg, int fromtty)
   target_fetch_registers (get_thread_regcache (inferior_thread ()), -1);
 
   reinit_frame_cache ();
-  print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
+  print_stack_frame (get_selected_frame (), 0, SRC_AND_LOC, 1);
 }
 
 #endif
@@ -355,7 +355,7 @@ bsd_kvm_pcb_cmd (const char *arg, int fromtty)
   target_fetch_registers (get_thread_regcache (inferior_thread ()), -1);
 
   reinit_frame_cache ();
-  print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
+  print_stack_frame (get_selected_frame (), 0, SRC_AND_LOC, 1);
 }
 
 bool
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 63f5a637697..3abb2f136ec 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1310,7 +1310,7 @@ list_command (const char *arg, int from_tty)
 	    {
 	      /* Find the current line by getting the PC of the currently
 		 selected frame, and finding the line associated to it.  */
-	      frame_info_ptr frame = get_selected_frame (nullptr);
+	      frame_info_ptr frame = get_selected_frame ();
 	      CORE_ADDR curr_pc = get_frame_pc (frame);
 	      cursal = find_sal_for_pc (curr_pc, 0);
 
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index dc0487d8f82..09bf22bacff 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -147,7 +147,7 @@ convert_one_symbol (compile_c_instance *context,
 
 	    if (symbol_read_needs_frame (sym.symbol))
 	      {
-		frame = get_selected_frame (NULL);
+		frame = get_selected_frame ();
 		if (frame == NULL)
 		  error (_("Symbol \"%s\" cannot be used because "
 			   "there is no selected frame"),
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index bc582ffb511..779e66d3073 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -143,7 +143,7 @@ convert_one_symbol (compile_cplus_instance *instance,
 
 	    if (symbol_read_needs_frame (sym.symbol))
 	      {
-		frame = get_selected_frame (nullptr);
+		frame = get_selected_frame ();
 		if (frame == nullptr)
 		  error (_("Symbol \"%s\" cannot be used because "
 			   "there is no selected frame"),
diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c
index 9f189ef1cc7..5e208a86563 100644
--- a/gdb/compile/compile-loc2c.c
+++ b/gdb/compile/compile-loc2c.c
@@ -632,7 +632,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
      offset by hand seemed too hackish.  */
   if (is_tls)
     {
-      frame_info_ptr frame = get_selected_frame (NULL);
+      frame_info_ptr frame = get_selected_frame ();
       struct value *val;
 
       if (frame == NULL)
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index c0b548fefd8..b52859b4bc8 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -437,7 +437,7 @@ show_compile_gcc (struct ui_file *file, int from_tty,
 static const char *
 get_selected_pc_producer_options (void)
 {
-  CORE_ADDR pc = get_frame_pc (get_selected_frame (NULL));
+  CORE_ADDR pc = get_frame_pc (get_selected_frame ());
   struct compunit_symtab *symtab = find_compunit_symtab_for_pc (pc);
   const char *cs;
 
@@ -584,7 +584,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
 	     "work."));
 
   expr_block = get_expr_block_and_pc (&trash_pc);
-  expr_pc = get_frame_address_in_block (get_selected_frame (NULL));
+  expr_pc = get_frame_address_in_block (get_selected_frame ());
 
   /* Set up instance and context for the compiler.  */
   std::unique_ptr<compile_instance> compiler
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 819e7cae6f9..d5a724ab551 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -1252,7 +1252,7 @@ core_target_open (const char *arg, int from_tty)
 
   /* Now, set up the frame cache, and print the top of stack.  */
   reinit_frame_cache ();
-  print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+  print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC, 1);
 
   /* Current thread should be NUM 1 but the user does not know that.
      If a program is single threaded gdb in general does not mention
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 5bf863e13d5..8e2b401ba34 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1639,7 +1639,7 @@ dwarf2_evaluate_property (const dynamic_prop *prop,
   frame_info_ptr frame = initial_frame;
 
   if (frame == NULL && has_stack_frames ())
-    frame = get_selected_frame (NULL);
+    frame = get_selected_frame ();
 
   switch (prop->kind ())
     {
diff --git a/gdb/eval.c b/gdb/eval.c
index a00774bda3d..7e07765c9e6 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1088,7 +1088,7 @@ eval_op_var_entry_value (struct type *expect_type, struct expression *exp,
     error (_("Symbol \"%s\" does not have any specific entry value"),
 	   sym->print_name ());
 
-  frame_info_ptr frame = get_selected_frame (NULL);
+  frame_info_ptr frame = get_selected_frame ();
   return computed_ops->read_variable_at_entry (sym, frame);
 }
 
diff --git a/gdb/frame.c b/gdb/frame.c
index 179e251eb1f..f64f5554f8c 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1975,7 +1975,7 @@ deprecated_safe_get_selected_frame (void)
 {
   if (!has_stack_frames ())
     return NULL;
-  return get_selected_frame (NULL);
+  return get_selected_frame ();
 }
 
 /* Invalidate the selected frame.  */
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index f3f15c9ae1d..bd5dbb02f48 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1817,7 +1817,7 @@ finish_backward (struct finish_command_fsm *sm)
   CORE_ADDR func_addr;
   CORE_ADDR alt_entry_point;
   CORE_ADDR entry_point;
-  frame_info_ptr frame = get_selected_frame (nullptr);
+  frame_info_ptr frame = get_selected_frame ();
   struct gdbarch *gdbarch = get_frame_arch (frame);
 
   pc = get_frame_pc (get_current_frame ());
@@ -1983,7 +1983,7 @@ finish_command (const char *arg, int from_tty)
       if (from_tty)
 	{
 	  gdb_printf (_("Run till exit from "));
-	  print_stack_frame (get_selected_frame (nullptr), 1, LOCATION, 0);
+	  print_stack_frame (get_selected_frame (), 1, LOCATION, 0);
 	}
 
       proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
@@ -1991,7 +1991,7 @@ finish_command (const char *arg, int from_tty)
     }
 
   /* Find the function we will return from.  */
-  frame_info_ptr callee_frame = get_selected_frame (nullptr);
+  frame_info_ptr callee_frame = get_selected_frame ();
   sm->function = find_symbol_for_pc (get_frame_pc (callee_frame));
   sm->return_buf = 0;    /* Initialize buffer address is not available.  */
 
@@ -2523,7 +2523,7 @@ registers_info (const char *addr_exp, bool fpregs)
 
   if (!target_has_registers ())
     error (_("The program has no registers now."));
-  frame = get_selected_frame (nullptr);
+  frame = get_selected_frame ();
   gdbarch = get_frame_arch (frame);
 
   if (!addr_exp)
@@ -2660,7 +2660,7 @@ info_vector_command (const char *args, int from_tty)
   if (!target_has_registers ())
     error (_("The program has no registers now."));
 
-  print_vector_info (gdb_stdout, get_selected_frame (nullptr), args);
+  print_vector_info (gdb_stdout, get_selected_frame (), args);
 }
 \f
 /* Kill the inferior process.  Make us have no inferior.  */
@@ -3197,7 +3197,7 @@ info_float_command (const char *args, int from_tty)
   if (!target_has_registers ())
     error (_("The program has no registers now."));
 
-  frame = get_selected_frame (nullptr);
+  frame = get_selected_frame ();
   gdbarch_print_float_info (get_frame_arch (frame), gdb_stdout, frame, args);
 }
 \f
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 11c5d5214d6..22a05608486 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9457,7 +9457,7 @@ print_stop_location (const target_waitstatus &ws)
   /* 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);
+  frame_info_ptr print_frame = get_selected_frame ();
 
  switch (bpstat_ret)
     {
diff --git a/gdb/language.c b/gdb/language.c
index 439ef293622..31213577052 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -174,7 +174,7 @@ show_language_command (struct ui_file *file, int from_tty,
     {
       frame_info_ptr frame;
 
-      frame = get_selected_frame (NULL);
+      frame = get_selected_frame ();
       flang = get_frame_language (frame);
       if (flang != language_unknown
 	  && language_mode == language_mode_manual
@@ -200,7 +200,7 @@ set_language (const char *language)
 	{
 	  frame_info_ptr frame;
 
-	  frame = get_selected_frame (NULL);
+	  frame = get_selected_frame ();
 	  flang = get_frame_language (frame);
 	}
       catch (const gdb_exception_error &ex)
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 3281be2b4dc..280a08d121e 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -262,7 +262,7 @@ mi_cmd_stack_list_locals (const char *command, const char *const *argv,
     error (_("-stack-list-locals: Usage: [--no-frame-filters] "
 	     "[--skip-unavailable] PRINT_VALUES"));
 
-  frame = get_selected_frame (NULL);
+  frame = get_selected_frame ();
   print_value = mi_parse_print_values (argv[oind]);
 
    if (! raw_arg && frame_filters)
@@ -456,7 +456,7 @@ mi_cmd_stack_list_variables (const char *command, const char *const *argv,
     error (_("-stack-list-variables: Usage: [--no-frame-filters] " \
 	     "[--skip-unavailable] PRINT_VALUES"));
 
-   frame = get_selected_frame (NULL);
+   frame = get_selected_frame ();
    print_value = mi_parse_print_values (argv[oind]);
 
    if (! raw_arg && frame_filters)
@@ -762,5 +762,5 @@ mi_cmd_stack_info_frame (const char *command, const char *const *argv,
     error (_("-stack-info-frame: No arguments allowed"));
 
   print_frame_info (user_frame_print_options,
-		    get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 0, 1);
+		    get_selected_frame (), 1, LOC_AND_ADDRESS, 0, 1);
 }
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 8b3048c5a46..1a0d34106ed 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -861,7 +861,7 @@ mi_interp::on_user_selected_context_changed (user_selected_what selection)
       if (tp->state () != THREAD_RUNNING)
 	{
 	  if (has_stack_frames ())
-	    print_stack_frame_to_uiout (mi_uiout, get_selected_frame (NULL),
+	    print_stack_frame_to_uiout (mi_uiout, get_selected_frame (),
 					1, SRC_AND_LOC, 1);
 	}
     }
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 52e642e1464..73c64b82186 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -225,7 +225,7 @@ mi_cmd_exec_return (const char *command, const char *const *argv, int argc)
 
   /* Because we have called return_command with from_tty = 0, we need
      to print the frame here.  */
-  print_stack_frame (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 1);
+  print_stack_frame (get_selected_frame (), 1, LOC_AND_ADDRESS, 1);
 }
 
 void
@@ -880,7 +880,7 @@ mi_cmd_data_list_changed_registers (const char *command,
      contents.  */
 
   prev_regs = std::move (this_regs);
-  this_regs = frame_save_as_regcache (get_selected_frame (NULL));
+  this_regs = frame_save_as_regcache (get_selected_frame ());
 
   /* Note that the test for a valid register must include checking the
      gdbarch_register_name because gdbarch_num_regs may be allocated
@@ -1014,7 +1014,7 @@ mi_cmd_data_list_register_values (const char *command, const char *const *argv,
 
   format = (int) argv[oind][0];
 
-  frame = get_selected_frame (NULL);
+  frame = get_selected_frame ();
   gdbarch = get_frame_arch (frame);
   numregs = gdbarch_num_cooked_regs (gdbarch);
 
@@ -2388,7 +2388,7 @@ mi_cmd_trace_find (const char *command, const char *const *argv, int argc)
     error (_("Invalid mode '%s'"), mode);
 
   if (has_stack_frames () || get_traceframe_number () >= 0)
-    print_stack_frame (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 1);
+    print_stack_frame (get_selected_frame (), 1, LOC_AND_ADDRESS, 1);
 }
 
 void
@@ -2630,7 +2630,7 @@ mi_cmd_trace_frame_collected (const char *command, const char *const *argv,
 
     ui_out_emit_list list_emitter (uiout, "registers");
 
-    frame = get_selected_frame (NULL);
+    frame = get_selected_frame ();
     gdbarch = get_frame_arch (frame);
     numregs = gdbarch_num_cooked_regs (gdbarch);
 
diff --git a/gdb/namespace.c b/gdb/namespace.c
index 5b5749369ee..e67ddc5efa7 100644
--- a/gdb/namespace.c
+++ b/gdb/namespace.c
@@ -111,7 +111,7 @@ using_direct::valid_line (unsigned int boundary) const
 {
   try
     {
-      CORE_ADDR curr_pc = get_frame_pc (get_selected_frame (nullptr));
+      CORE_ADDR curr_pc = get_frame_pc (get_selected_frame ());
       symtab_and_line curr_sal = find_sal_for_pc (curr_pc, 0);
       return (decl_line <= curr_sal.line)
 	     || (decl_line >= boundary);
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index ae498395436..0485670c4b2 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -750,7 +750,7 @@ pc_prefix (CORE_ADDR addr)
       frame_info_ptr frame;
       std::optional<CORE_ADDR> pc;
 
-      frame = get_selected_frame (NULL);
+      frame = get_selected_frame ();
       if ((pc = get_frame_pc_if_available (frame)) && *pc == addr)
 	return "=> ";
     }
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index b4f1dcc3dea..4bd755b24f2 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -2799,7 +2799,7 @@ record_btrace_set_replay (struct thread_info *tp,
   record_btrace_clear_histories (btinfo);
 
   tp->set_stop_pc (regcache_read_pc (get_thread_regcache (tp)));
-  print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+  print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC, 1);
 }
 
 /* The goto_record_begin method of target record-btrace.  */
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 69d2c100e57..bd3ea7ef962 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -2025,7 +2025,7 @@ record_full_goto_entry (struct record_full_entry *p)
 
   thread_info *thr = inferior_thread ();
   thr->set_stop_pc (regcache_read_pc (get_thread_regcache (thr)));
-  print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+  print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC, 1);
 }
 
 /* The "goto_record_begin" target method.  */
@@ -2509,7 +2509,7 @@ record_full_restore (struct bfd &cbfd)
   gdb_printf (_("Restored records from core file %s.\n"),
 	      bfd_get_filename (&cbfd));
 
-  print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+  print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC, 1);
 }
 
 /* bfdcore_write -- write bytes into a core file section.  */
diff --git a/gdb/stack.c b/gdb/stack.c
index 7329430adab..e084976eabf 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2471,7 +2471,7 @@ get_selected_block (CORE_ADDR *addr_in_block)
   if (!has_stack_frames ())
     return 0;
 
-  return get_frame_block (get_selected_frame (NULL), addr_in_block);
+  return get_frame_block (get_selected_frame (), addr_in_block);
 }
 
 /* Find a frame a certain number of levels away from FRAME.
@@ -2702,7 +2702,7 @@ return_command (const char *retval_exp, int from_tty)
     }
 
   /* Discard the selected frame and all frames inner-to it.  */
-  frame_pop (get_selected_frame (NULL));
+  frame_pop (get_selected_frame ());
 
   /* Store RETURN_VALUE in the just-returned register set.  */
   if (return_value != NULL)
@@ -2726,7 +2726,7 @@ return_command (const char *retval_exp, int from_tty)
   select_frame (get_current_frame ());
   /* If interactive, print the frame that is now current.  */
   if (from_tty)
-    print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+    print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC, 1);
 }
 
 /* Find the most inner frame in the current stack for a function called
diff --git a/gdb/thread.c b/gdb/thread.c
index 110e58a70aa..96c733e0629 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1243,7 +1243,7 @@ do_print_thread (ui_out *uiout, const char *requested_threads,
     {
       /* The switch above put us at the top of the stack (leaf
 	 frame).  */
-      print_stack_frame (get_selected_frame (NULL),
+      print_stack_frame (get_selected_frame (),
 			 /* For MI output, print frame level.  */
 			 uiout->is_mi_like_p (),
 			 LOCATION, 0);
@@ -2163,7 +2163,7 @@ print_selected_thread_frame (struct ui_out *uiout,
 	uiout->text ("\n");
 
       if (has_stack_frames ())
-	print_stack_frame_to_uiout (uiout, get_selected_frame (NULL),
+	print_stack_frame_to_uiout (uiout, get_selected_frame (),
 				    1, SRC_AND_LOC, 1);
     }
 }
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 7f078684b14..798bb9a552d 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2188,7 +2188,7 @@ tfind_1 (enum trace_find_type type, int num,
       else
 	print_what = SRC_AND_LOC;
 
-      print_stack_frame (get_selected_frame (NULL), 1, print_what, 1);
+      print_stack_frame (get_selected_frame (), 1, print_what, 1);
       do_displays ();
     }
 }
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 17ae8e7a590..f3d3cbe87a6 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -59,7 +59,7 @@ tui_register_changed (const frame_info_ptr &frame, int regno)
      And even if the frames differ a register change made in one can still show
      up in the other.  So we always use the selected frame here, and ignore
      FRAME.  */
-  fi = get_selected_frame (NULL);
+  fi = get_selected_frame ();
   tui_data_win ()->check_register_values (fi);
 }
 
@@ -114,7 +114,7 @@ tui_refresh_frame_and_register_information ()
       frame_info_ptr fi;
       if (has_stack_frames ())
 	{
-	  fi = get_selected_frame (NULL);
+	  fi = get_selected_frame ();
 
 	  /* Display the frame position (even if there is no symbols or
 	     the PC is not known).  */
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 28f0d8b82d4..3e2e0745993 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -143,7 +143,7 @@ tui_data_window::update_register_data (const reggroup *group)
   if (group == nullptr)
     group = general_reggroup;
 
-  frame_info_ptr frame = get_selected_frame (nullptr);
+  frame_info_ptr frame = get_selected_frame ();
   struct gdbarch *gdbarch = get_frame_arch (frame);
 
   if (m_current_group == group && m_gdbarch == gdbarch)
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 85b754730c8..783d4b2a1c2 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -158,7 +158,7 @@ tui_source_window::do_scroll_vertical (int num_to_scroll)
 
       if (cursal.symtab == NULL)
 	{
-	  frame_info_ptr fi = get_selected_frame (NULL);
+	  frame_info_ptr fi = get_selected_frame ();
 	  s = find_symtab_for_pc (get_frame_pc (fi));
 	  arch = get_frame_arch (fi);
 	}
diff --git a/gdb/varobj.c b/gdb/varobj.c
index edd94ea4963..0cd3ba90a91 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -276,7 +276,7 @@ varobj_create (const char *objname,
 	{
 	  /* Allow creator to specify context of variable.  */
 	  if ((type == USE_CURRENT_FRAME) || (type == USE_SELECTED_FRAME))
-	    fi = get_selected_frame (NULL);
+	    fi = get_selected_frame ();
 	  else
 	    /* FIXME: cagney/2002-11-23: This code should be doing a
 	       lookup using the frame ID and not just the frame's
@@ -354,7 +354,7 @@ varobj_create (const char *objname,
 
 	  var->root->frame = get_frame_id (fi);
 	  var->root->thread_id = inferior_thread ()->global_num;
-	  old_id = get_frame_id (get_selected_frame (NULL));
+	  old_id = get_frame_id (get_selected_frame ());
 	  select_frame (fi);
 	}
 

base-commit: dafd73bcda60e9a54bdd43c79337dce452b1d8af
-- 
2.51.0


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

* Re: [PATCH] [gdb] Drop nullptr in "get_selected_frame (nullptr)"
  2026-06-04 20:01 [PATCH] [gdb] Drop nullptr in "get_selected_frame (nullptr)" Tom de Vries
@ 2026-06-05 20:55 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2026-06-05 20:55 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

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

Tom> I came across "get_selected_frame (nullptr)", and realized nullptr is the
Tom> default argument, so this can be simplified to "get_selected_frame ()".

Seems fine to me, thanks.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

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

end of thread, other threads:[~2026-06-05 20:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-04 20:01 [PATCH] [gdb] Drop nullptr in "get_selected_frame (nullptr)" Tom de Vries
2026-06-05 20:55 ` Tom Tromey

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