mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 01:53:38 +08:00
gdb: add overloads of gdb_tilde_expand
Like the previous commit, add two overloads of gdb_tilde_expand, one takes std::string and other takes gdb::unique_xmalloc_ptr<char>. Make use of these overloads throughout GDB and gdbserver. There should be no user visible changes after this commit. Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
parent
88aad97c21
commit
632c537277
@ -236,7 +236,7 @@ filename_completer (struct cmd_list_element *ignore,
|
||||
trailing '/' ourselves now. */
|
||||
if (!tracker.from_readline ())
|
||||
{
|
||||
std::string expanded = gdb_tilde_expand (p_rl.get ());
|
||||
std::string expanded = gdb_tilde_expand (p_rl);
|
||||
struct stat finfo;
|
||||
const bool isdir = (stat (expanded.c_str (), &finfo) == 0
|
||||
&& S_ISDIR (finfo.st_mode));
|
||||
|
@ -321,7 +321,7 @@ fork_inferior (const char *exec_file, const std::string &allargs, char **env,
|
||||
{
|
||||
/* Expand before forking because between fork and exec, the child
|
||||
process may only execute async-signal-safe operations. */
|
||||
inferior_cwd = gdb_tilde_expand (inferior_cwd.c_str ());
|
||||
inferior_cwd = gdb_tilde_expand (inferior_cwd);
|
||||
}
|
||||
|
||||
/* If there's any initialization of the target layers that must
|
||||
|
@ -501,7 +501,7 @@ create_process (const char *program, char *args,
|
||||
/* current directory */
|
||||
(inferior_cwd.empty ()
|
||||
? NULL
|
||||
: gdb_tilde_expand (inferior_cwd.c_str ()).c_str()),
|
||||
: gdb_tilde_expand (inferior_cwd).c_str()),
|
||||
get_client_state ().disable_randomization,
|
||||
&si, /* start info */
|
||||
pi); /* proc info */
|
||||
|
@ -20,7 +20,21 @@
|
||||
#ifndef COMMON_GDB_TILDE_EXPAND_H
|
||||
#define COMMON_GDB_TILDE_EXPAND_H
|
||||
|
||||
/* Perform tilde expansion on DIR, and return the full path. */
|
||||
extern std::string gdb_tilde_expand (const char *dir);
|
||||
/* Perform tilde expansion on PATH, and return the full path. */
|
||||
extern std::string gdb_tilde_expand (const char *path);
|
||||
|
||||
/* Overload of gdb_tilde_expand that takes std::string. */
|
||||
static inline std::string
|
||||
gdb_tilde_expand (const std::string &path)
|
||||
{
|
||||
return gdb_tilde_expand (path.c_str ());
|
||||
}
|
||||
|
||||
/* Overload of gdb_tilde_expand that takes gdb::unique_xmalloc_ptr<char>. */
|
||||
static inline std::string
|
||||
gdb_tilde_expand (const gdb::unique_xmalloc_ptr<char> &path)
|
||||
{
|
||||
return gdb_tilde_expand (path.get ());
|
||||
}
|
||||
|
||||
#endif /* COMMON_GDB_TILDE_EXPAND_H */
|
||||
|
Loading…
Reference in New Issue
Block a user