aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2022-04-13 17:31:02 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2022-04-18 15:48:03 -0400
commit7ab2607f97e5deaeae91018edf3ef5b4255a842c (patch)
treef1fea75412b59b147691af35019eb6d940f062b0 /gdbserver
parente0c34637019b0a070780b57b50d9026c0aca16f4 (diff)
downloadfsf-binutils-gdb-7ab2607f97e5deaeae91018edf3ef5b4255a842c.zip
fsf-binutils-gdb-7ab2607f97e5deaeae91018edf3ef5b4255a842c.tar.gz
fsf-binutils-gdb-7ab2607f97e5deaeae91018edf3ef5b4255a842c.tar.bz2
gdbsupport: make gdb_abspath return an std::string
I'm trying to switch these functions to use std::string instead of char arrays, as much as possible. Some callers benefit from it (can avoid doing a copy of the result), while others suffer (have to make one more copy). Change-Id: Iced49b8ee2f189744c5072a3b217aab5af17a993
Diffstat (limited to 'gdbserver')
-rw-r--r--gdbserver/server.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 24925cb..33c4271 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -90,31 +90,31 @@ bool non_stop;
static struct {
/* Set the PROGRAM_PATH. Here we adjust the path of the provided
binary if needed. */
- void set (gdb::unique_xmalloc_ptr<char> &&path)
+ void set (const char *path)
{
- m_path = std::move (path);
+ m_path = path;
/* Make sure we're using the absolute path of the inferior when
creating it. */
- if (!contains_dir_separator (m_path.get ()))
+ if (!contains_dir_separator (m_path.c_str ()))
{
int reg_file_errno;
/* Check if the file is in our CWD. If it is, then we prefix
its name with CURRENT_DIRECTORY. Otherwise, we leave the
name as-is because we'll try searching for it in $PATH. */
- if (is_regular_file (m_path.get (), &reg_file_errno))
- m_path = gdb_abspath (m_path.get ());
+ if (is_regular_file (m_path.c_str (), &reg_file_errno))
+ m_path = gdb_abspath (m_path.c_str ());
}
}
/* Return the PROGRAM_PATH. */
- char *get ()
- { return m_path.get (); }
+ const char *get ()
+ { return m_path.empty () ? nullptr : m_path.c_str (); }
private:
/* The program name, adjusted if needed. */
- gdb::unique_xmalloc_ptr<char> m_path;
+ std::string m_path;
} program_path;
static std::vector<char *> program_args;
static std::string wrapper_argv;
@@ -3076,7 +3076,7 @@ handle_v_run (char *own_buf)
}
}
else
- program_path.set (gdb::unique_xmalloc_ptr<char> (new_program_name));
+ program_path.set (new_program_name);
/* Free the old argv and install the new one. */
free_vector_argv (program_args);
@@ -3933,7 +3933,7 @@ captured_main (int argc, char *argv[])
int i, n;
n = argc - (next_arg - argv);
- program_path.set (make_unique_xstrdup (next_arg[0]));
+ program_path.set (next_arg[0]);
for (i = 1; i < n; i++)
program_args.push_back (xstrdup (next_arg[i]));