aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-06-25 18:07:54 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-07-23 15:38:54 -0400
commit11bd012ed256688f43d71dcc531c2f105a9c55dd (patch)
treeeeff398be94163b59fc0f261615449bd9dbeaeb1 /gdb/infcmd.c
parentfd2dec2a45a73154d9824071ebb8664a39a69174 (diff)
downloadgdb-11bd012ed256688f43d71dcc531c2f105a9c55dd.zip
gdb-11bd012ed256688f43d71dcc531c2f105a9c55dd.tar.gz
gdb-11bd012ed256688f43d71dcc531c2f105a9c55dd.tar.bz2
gdb: make inferior::m_cwd an std::string
Same idea as the previous patch, but for m_cwd. To keep things consistent across the board, change get_inferior_cwd as well, which is shared with GDBserver. So update the related GDBserver code too. Change-Id: Ia2c047fda738d45f3d18bc999eb67ceb8400ce4e
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 2d0d6cc..c027176 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -156,7 +156,7 @@ show_args_command (struct ui_file *file, int from_tty,
/* See gdbsupport/common-inferior.h. */
-const char *
+const std::string &
get_inferior_cwd ()
{
return current_inferior ()->cwd ();
@@ -167,10 +167,7 @@ get_inferior_cwd ()
static void
set_cwd_command (const char *args, int from_tty, struct cmd_list_element *c)
{
- if (*inferior_cwd_scratch == '\0')
- current_inferior ()->set_cwd (nullptr);
- else
- current_inferior ()->set_cwd (inferior_cwd_scratch);
+ current_inferior ()->set_cwd (inferior_cwd_scratch);
}
/* Handle the 'show cwd' command. */
@@ -179,9 +176,9 @@ static void
show_cwd_command (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- const char *cwd = current_inferior ()->cwd ();
+ const std::string &cwd = current_inferior ()->cwd ();
- if (cwd == NULL)
+ if (cwd.empty ())
fprintf_filtered (gdb_stdout,
_("\
You have not set the inferior's current working directory.\n\
@@ -190,7 +187,8 @@ server's cwd if remote debugging.\n"));
else
fprintf_filtered (gdb_stdout,
_("Current working directory that will be used "
- "when starting the inferior is \"%s\".\n"), cwd);
+ "when starting the inferior is \"%s\".\n"),
+ cwd.c_str ());
}