aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-04-28 22:14:53 +0100
committerAndrew Burgess <aburgess@redhat.com>2023-04-28 22:50:46 +0100
commit94e6c5641234c4ced9cb3fa0ccc2aaaa6b7b62ea (patch)
tree6d01ae3d20ba8fad600ec7174fd02474f70425e4 /gdb/infcmd.c
parentcc09d372f664410aea226bfaa246aeb74fee8126 (diff)
downloadgdb-94e6c5641234c4ced9cb3fa0ccc2aaaa6b7b62ea.zip
gdb-94e6c5641234c4ced9cb3fa0ccc2aaaa6b7b62ea.tar.gz
gdb-94e6c5641234c4ced9cb3fa0ccc2aaaa6b7b62ea.tar.bz2
gdb: make set/show cwd work with $_gdb_setting_str
The previous commit fixed set/show args when used with $_gdb_setting_str, this commit fixes set/show cwd. Instead of using a scratch variable which is then pushed into the current inferior from a set callback, move to the API that allows for getters and setters, and store the value directly within the current inferior. Update the existing test to check the cwd setting.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 310ad62..7b2db17 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -66,10 +66,6 @@ static void step_1 (int, int, const char *);
#define ERROR_NO_INFERIOR \
if (!target_has_execution ()) error (_("The program is not being run."));
-/* Scratch area where the new cwd will be stored by 'set cwd'. */
-
-static std::string inferior_cwd_scratch;
-
/* Scratch area where 'set inferior-tty' will store user-provided value.
We'll immediate copy it into per-inferior storage. */
@@ -165,12 +161,12 @@ get_inferior_cwd ()
return current_inferior ()->cwd ();
}
-/* Handle the 'set cwd' command. */
+/* Store the new value passed to 'set cwd'. */
static void
-set_cwd_command (const char *args, int from_tty, struct cmd_list_element *c)
+set_cwd_value (const std::string &args)
{
- current_inferior ()->set_cwd (inferior_cwd_scratch);
+ current_inferior ()->set_cwd (args);
}
/* Handle the 'show cwd' command. */
@@ -3164,8 +3160,7 @@ Follow this command with any number of args, to be passed to the program."),
set_cmd_completer (args_set_show.set, filename_completer);
auto cwd_set_show
- = add_setshow_string_noescape_cmd ("cwd", class_run,
- &inferior_cwd_scratch, _("\
+ = add_setshow_string_noescape_cmd ("cwd", class_run, _("\
Set the current working directory to be used when the inferior is started.\n \
Changing this setting does not have any effect on inferiors that are\n \
already running."),
@@ -3175,7 +3170,7 @@ Show the current working directory that is used when the inferior is started."),
Use this command to change the current working directory that will be used\n\
when the inferior is started. This setting does not affect GDB's current\n\
working directory."),
- set_cwd_command,
+ set_cwd_value, get_inferior_cwd,
show_cwd_command,
&setlist, &showlist);
set_cmd_completer (cwd_set_show.set, filename_completer);