aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat
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/nat
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/nat')
-rw-r--r--gdb/nat/fork-inferior.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c
index d280e11..c88cf4c 100644
--- a/gdb/nat/fork-inferior.c
+++ b/gdb/nat/fork-inferior.c
@@ -281,8 +281,6 @@ fork_inferior (const char *exec_file_arg, const std::string &allargs,
char **save_our_env;
int i;
int save_errno;
- const char *inferior_cwd;
- std::string expanded_inferior_cwd;
/* If no exec file handed to us, get it from the exec-file command
-- with a good, common error message if none is specified. */
@@ -326,14 +324,13 @@ fork_inferior (const char *exec_file_arg, const std::string &allargs,
/* Check if the user wants to set a different working directory for
the inferior. */
- inferior_cwd = get_inferior_cwd ();
+ std::string inferior_cwd = get_inferior_cwd ();
- if (inferior_cwd != NULL)
+ if (!inferior_cwd.empty ())
{
/* Expand before forking because between fork and exec, the child
process may only execute async-signal-safe operations. */
- expanded_inferior_cwd = gdb_tilde_expand (inferior_cwd);
- inferior_cwd = expanded_inferior_cwd.c_str ();
+ inferior_cwd = gdb_tilde_expand (inferior_cwd.c_str ());
}
/* If there's any initialization of the target layers that must
@@ -373,10 +370,10 @@ fork_inferior (const char *exec_file_arg, const std::string &allargs,
/* Change to the requested working directory if the user
requested it. */
- if (inferior_cwd != NULL)
+ if (!inferior_cwd.empty ())
{
- if (chdir (inferior_cwd) < 0)
- trace_start_error_with_name (inferior_cwd);
+ if (chdir (inferior_cwd.c_str ()) < 0)
+ trace_start_error_with_name (inferior_cwd.c_str ());
}
if (debug_fork)