From 11bd012ed256688f43d71dcc531c2f105a9c55dd Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 25 Jun 2021 18:07:54 -0400 Subject: 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 --- gdbserver/inferiors.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'gdbserver/inferiors.cc') diff --git a/gdbserver/inferiors.cc b/gdbserver/inferiors.cc index 0a09de7..32f8478 100644 --- a/gdbserver/inferiors.cc +++ b/gdbserver/inferiors.cc @@ -28,8 +28,10 @@ std::list 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); } -- cgit v1.1