[PATCH v8 3/6] gdb, cli: pass the argument of a set command to its callback.

Klaus Gerlicher <[email protected]> Wed, 22 Jul 2026 10:27:43 +0000
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
From: Natalia Saiapova <[email protected]>

This might be useful, if some commands need to have a special case if
run w/o arguments.

I am going to use it in
  gdb: refine commands to control scheduler locking.
to keep the old behaviour of the
  set scheduler-locking step
which should set both
  set scheduler-locking step on
  set scheduler-locking replay step on
To do this, the set-command needs to detect that it was issued without
arguments and have a special handling for this.

Without the special handling, the command
  set scheduler-locking step
would set only
  set scheduler-locking step on

Approved-By: Tom Tromey <[email protected]>
---
 gdb/cli/cli-setshow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 7688da015de..f1f313a4cd0 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -455,7 +455,7 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
       error (_("gdb internal error: bad var_type in do_setshow_command"));
     }
 
-  c->func (NULL, from_tty, c);
+  c->func (arg, from_tty, c);
 
   if (notify_command_param_changed_p (option_changed, c))
     {
-- 
2.34.1

Intel Deutschland GmbH

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928