summaryrefslogtreecommitdiff
path: root/gdbserver/inferiors.cc
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 /gdbserver/inferiors.cc
parentfd2dec2a45a73154d9824071ebb8664a39a69174 (diff)
downloadbinutils-gdb-11bd012ed256688f43d71dcc531c2f105a9c55dd.tar.gz
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 'gdbserver/inferiors.cc')
-rw-r--r--gdbserver/inferiors.cc16
1 files changed, 7 insertions, 9 deletions
diff --git a/gdbserver/inferiors.cc b/gdbserver/inferiors.cc
index 0a09de79071..32f847812e6 100644
--- a/gdbserver/inferiors.cc
+++ b/gdbserver/inferiors.cc
@@ -28,8 +28,10 @@ std::list<thread_info *> all_threads;
struct thread_info *current_thread;
-/* The current working directory used to start the inferior. */
-static const char *current_inferior_cwd = NULL;
+/* The current working directory used to start the inferior.
+
+ Empty if not specified. */
+static std::string current_inferior_cwd;
struct thread_info *
add_thread (ptid_t thread_id, void *target_data)
@@ -235,7 +237,7 @@ switch_to_process (process_info *proc)
/* See gdbsupport/common-inferior.h. */
-const char *
+const std::string &
get_inferior_cwd ()
{
return current_inferior_cwd;
@@ -244,11 +246,7 @@ get_inferior_cwd ()
/* See inferiors.h. */
void
-set_inferior_cwd (const char *cwd)
+set_inferior_cwd (std::string cwd)
{
- xfree ((void *) current_inferior_cwd);
- if (cwd != NULL)
- current_inferior_cwd = xstrdup (cwd);
- else
- current_inferior_cwd = NULL;
+ current_inferior_cwd = std::move (cwd);
}