aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/infcmd.c24
-rw-r--r--gdb/inferior.h27
-rw-r--r--gdb/remote.c2
-rw-r--r--gdb/windows-nat.c2
4 files changed, 29 insertions, 26 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 1407a3e..be6031d 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -154,28 +154,12 @@ show_args_command (struct ui_file *file, int from_tty,
current_inferior ()->args ());
}
-/* Set the inferior current working directory. If CWD is NULL, unset
- the directory. */
-
-static void
-set_inferior_cwd (const char *cwd)
-{
- struct inferior *inf = current_inferior ();
-
- gdb_assert (inf != NULL);
-
- if (cwd == NULL)
- inf->cwd.reset ();
- else
- inf->cwd.reset (xstrdup (cwd));
-}
-
/* See gdbsupport/common-inferior.h. */
const char *
get_inferior_cwd ()
{
- return current_inferior ()->cwd.get ();
+ return current_inferior ()->cwd ();
}
/* Handle the 'set cwd' command. */
@@ -184,9 +168,9 @@ static void
set_cwd_command (const char *args, int from_tty, struct cmd_list_element *c)
{
if (*inferior_cwd_scratch == '\0')
- set_inferior_cwd (NULL);
+ current_inferior ()->set_cwd (nullptr);
else
- set_inferior_cwd (inferior_cwd_scratch);
+ current_inferior ()->set_cwd (inferior_cwd_scratch);
}
/* Handle the 'show cwd' command. */
@@ -195,7 +179,7 @@ static void
show_cwd_command (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- const char *cwd = get_inferior_cwd ();
+ const char *cwd = current_inferior ()->cwd ();
if (cwd == NULL)
fprintf_filtered (gdb_stdout,
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 445b566..fb57df7 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -466,6 +466,25 @@ public:
return m_args.get ();
}
+ /* Set the inferior current working directory.
+
+ If CWD is NULL, unset the directory. */
+ void set_cwd (const char *cwd)
+ {
+ if (cwd == NULL)
+ m_cwd.reset ();
+ else
+ m_cwd.reset (xstrdup (cwd));
+ }
+
+ /* Get the inferior current working directory.
+
+ Return nullptr if the current working directory is not specified. */
+ const char *cwd () const
+ {
+ return m_cwd.get ();
+ }
+
/* Convenient handle (GDB inferior id). Unique across all
inferiors. */
int num = 0;
@@ -495,10 +514,6 @@ public:
/* The program space bound to this inferior. */
struct program_space *pspace = NULL;
- /* The current working directory that will be used when starting
- this inferior. */
- gdb::unique_xmalloc_ptr<char> cwd;
-
/* The terminal state as set by the last target_terminal::terminal_*
call. */
target_terminal_state terminal_state = target_terminal_state::is_ours;
@@ -591,6 +606,10 @@ private:
This is nullptr when there are not args. */
gdb::unique_xmalloc_ptr<char> m_args;
+
+ /* The current working directory that will be used when starting
+ this inferior. */
+ gdb::unique_xmalloc_ptr<char> m_cwd;
};
/* Keep a registry of per-inferior data-pointers required by other GDB
diff --git a/gdb/remote.c b/gdb/remote.c
index e488ca6..dc3948b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -10391,7 +10391,7 @@ remote_target::extended_remote_set_inferior_cwd ()
{
if (packet_support (PACKET_QSetWorkingDir) != PACKET_DISABLE)
{
- const char *inferior_cwd = get_inferior_cwd ();
+ const char *inferior_cwd = current_inferior ()->cwd ();
remote_state *rs = get_remote_state ();
if (inferior_cwd != NULL)
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 05d95ea..9526149 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2558,7 +2558,7 @@ windows_nat_target::create_inferior (const char *exec_file,
if (!exec_file)
error (_("No executable specified, use `target exec'."));
- const char *inferior_cwd = get_inferior_cwd ();
+ const char *inferior_cwd = current_inferior ()->cwd ();
std::string expanded_infcwd;
if (inferior_cwd != NULL)
{