mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-21 01:12:32 +08:00
gdb: add overloads of gdb_abspath
Add two overloads of gdb_abspath, one which takes std::string and one which takes gdb::unique_xmalloc_ptr<char>, then 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
973563710c
commit
88aad97c21
@ -117,7 +117,7 @@ bsd_kvm_target_open (const char *arg, int from_tty)
|
||||
{
|
||||
filename = gdb_tilde_expand (arg);
|
||||
if (!IS_ABSOLUTE_PATH (filename))
|
||||
filename = gdb_abspath (filename.c_str ());
|
||||
filename = gdb_abspath (filename);
|
||||
}
|
||||
|
||||
const char *execfile = current_program_space->exec_filename ();
|
||||
|
@ -626,7 +626,7 @@ core_target_open (const char *arg, int from_tty)
|
||||
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
|
||||
if (strlen (filename.get ()) != 0
|
||||
&& !IS_ABSOLUTE_PATH (filename.get ()))
|
||||
filename = make_unique_xstrdup (gdb_abspath (filename.get ()).c_str ());
|
||||
filename = make_unique_xstrdup (gdb_abspath (filename).c_str ());
|
||||
|
||||
flags = O_BINARY | O_LARGEFILE;
|
||||
if (write_files)
|
||||
|
@ -324,7 +324,7 @@ set_index_cache_directory_command (const char *arg, int from_tty,
|
||||
cmd_list_element *element)
|
||||
{
|
||||
/* Make sure the index cache directory is absolute and tilde-expanded. */
|
||||
index_cache_directory = gdb_abspath (index_cache_directory.c_str ());
|
||||
index_cache_directory = gdb_abspath (index_cache_directory);
|
||||
global_index_cache.set_directory (index_cache_directory);
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ set_gdb_data_directory (const char *new_datadir)
|
||||
"../foo" and "../foo" doesn't exist then we'll record $(pwd)/../foo which
|
||||
isn't canonical, but that's ok. */
|
||||
if (!IS_ABSOLUTE_PATH (gdb_datadir.c_str ()))
|
||||
gdb_datadir = gdb_abspath (gdb_datadir.c_str ());
|
||||
gdb_datadir = gdb_abspath (gdb_datadir);
|
||||
}
|
||||
|
||||
/* Relocate a file or directory. PROGNAME is the name by which gdb
|
||||
|
@ -2097,7 +2097,7 @@ set_history_filename (const char *args,
|
||||
that was read. */
|
||||
if (!history_filename.empty ()
|
||||
&& !IS_ABSOLUTE_PATH (history_filename.c_str ()))
|
||||
history_filename = gdb_abspath (history_filename.c_str ());
|
||||
history_filename = gdb_abspath (history_filename);
|
||||
}
|
||||
|
||||
/* Whether we're in quiet startup mode. */
|
||||
|
@ -467,7 +467,7 @@ tfile_target_open (const char *arg, int from_tty)
|
||||
|
||||
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
|
||||
if (!IS_ABSOLUTE_PATH (filename.get ()))
|
||||
filename = make_unique_xstrdup (gdb_abspath (filename.get ()).c_str ());
|
||||
filename = make_unique_xstrdup (gdb_abspath (filename).c_str ());
|
||||
|
||||
flags = O_BINARY | O_LARGEFILE;
|
||||
flags |= O_RDONLY;
|
||||
|
@ -109,7 +109,7 @@ static struct {
|
||||
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.c_str (), ®_file_errno))
|
||||
m_path = gdb_abspath (m_path.c_str ());
|
||||
m_path = gdb_abspath (m_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,22 @@ extern std::string gdb_realpath_keepfile (const char *filename);
|
||||
|
||||
extern std::string gdb_abspath (const char *path);
|
||||
|
||||
/* Overload of gdb_abspath which takes std::string. */
|
||||
|
||||
static inline std::string
|
||||
gdb_abspath (const std::string &path)
|
||||
{
|
||||
return gdb_abspath (path.c_str ());
|
||||
}
|
||||
|
||||
/* Overload of gdb_abspath which takes gdb::unique_xmalloc_ptr<char>. */
|
||||
|
||||
static inline std::string
|
||||
gdb_abspath (const gdb::unique_xmalloc_ptr<char> &path)
|
||||
{
|
||||
return gdb_abspath (path.get ());
|
||||
}
|
||||
|
||||
/* If the path in CHILD is a child of the path in PARENT, return a
|
||||
pointer to the first component in the CHILD's pathname below the
|
||||
PARENT. Otherwise, return NULL. */
|
||||
|
Loading…
Reference in New Issue
Block a user