#include "cli/cli-cmds.h"
#include "cli/cli-decode.h"
#include "cli/cli-setshow.h"
-#include "readline/tilde.h"
#include "completer.h"
#include "fnmatch.h"
#include "top.h"
for (size_t i = 0; i < len; i++)
{
gdb::unique_xmalloc_ptr<char> &in_vec = auto_load_safe_path_vec[i];
- gdb::unique_xmalloc_ptr<char> expanded (tilde_expand (in_vec.get ()));
+ gdb::unique_xmalloc_ptr<char> expanded
+ = gdb_rl_tilde_expand (in_vec.get ());
gdb::unique_xmalloc_ptr<char> real_path = gdb_realpath (expanded.get ());
/* Ensure the current entry is at least tilde_expand-ed. ORIGINAL makes
#include "cli/cli-decode.h"
#include "break-cond-parse.h"
-/* readline include files */
-#include "readline/tilde.h"
-
/* readline defines this. */
#undef savestring
return;
}
- gdb::unique_xmalloc_ptr<char> expanded_filename (tilde_expand (filename));
+ gdb::unique_xmalloc_ptr<char> expanded_filename
+ = gdb_rl_tilde_expand (filename);
stdio_file fp;
#include "arch-utils.h"
#include "exceptions.h"
-#include "readline/tilde.h"
#include "completer.h"
#include "target.h"
#include "gdbsupport/gdb_wait.h"
dont_repeat ();
gdb::unique_xmalloc_ptr<char> dir_holder
- (tilde_expand (dir != NULL ? dir : "~"));
+ = gdb_rl_tilde_expand (dir != NULL ? dir : "~");
dir = dir_holder.get ();
if (chdir (dir) < 0)
openp_flags search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH;
std::optional<open_script> opened;
- gdb::unique_xmalloc_ptr<char> file (tilde_expand (script_file));
+ gdb::unique_xmalloc_ptr<char> file
+ = gdb_rl_tilde_expand (script_file);
if (search_path)
search_flags |= OPF_SEARCH_IN_PATH;
#include "value.h"
#include "completer.h"
#include "target.h"
-#include "readline/tilde.h"
#include "gdbcore.h"
#include "cli/cli-utils.h"
#include "gdb_bfd.h"
}
gdb_assert (filename != NULL);
- return gdb::unique_xmalloc_ptr<char> (tilde_expand (filename.get ()));
+ return gdb_rl_tilde_expand (filename.get ());
}
static gdb_bfd_ref_ptr
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "readline/tilde.h"
#include "value.h"
#include "arch-utils.h"
#include "observable.h"
[[fallthrough]];
case var_optional_filename:
{
- char *val = NULL;
+ gdb::unique_xmalloc_ptr<char> val;
if (*arg != '\0')
{
gdb::unique_xmalloc_ptr<char> copy
= make_unique_xstrndup (arg, ptr + 1 - arg);
- val = tilde_expand (copy.get ());
+ val = gdb_rl_tilde_expand (copy.get ());
}
else
- val = xstrdup ("");
+ val = make_unique_xstrdup ("");
option_changed
- = c->var->set<std::string> (std::string (val));
- xfree (val);
+ = c->var->set<std::string> (std::string (val.get ()));
}
break;
case var_boolean:
#include "command.h"
#include "objfiles.h"
#include "gdbcore.h"
-#include "readline/tilde.h"
#include "bfdlink.h"
#include "cli/cli-cmds.h"
#include "regcache.h"
struct type *expect_return_type;
gdb::unique_xmalloc_ptr<char> filename
- (tilde_expand (file_names.object_file ()));
+ = gdb_rl_tilde_expand (file_names.object_file ());
gdb_bfd_ref_ptr abfd (gdb_bfd_open (filename.get (), gnutarget));
if (abfd == NULL)
const struct match_list_displayer *displayer)
{
int printed_len, extension_char, slen, tlen;
- char *s, c, *new_full_pathname;
+ char c, *new_full_pathname;
const char *dn;
extern int _rl_complete_mark_directories;
dn = "/"; /* don't turn /// into // */
else
dn = full_pathname;
- s = tilde_expand (dn);
+ char *s = gdb_rl_tilde_expand (dn).release ();
if (rl_directory_completion_hook)
(*rl_directory_completion_hook) (&s);
xfree (new_full_pathname);
to_print[-1] = c;
+
+ xfree (s);
}
else
{
- s = tilde_expand (full_pathname);
+ gdb::unique_xmalloc_ptr<char> s
+ = gdb_rl_tilde_expand (full_pathname);
#if defined (VISIBLE_STATS)
if (rl_visible_stats)
extension_char = stat_char (s);
else
#endif
- if (gdb_path_isdir (s))
+ if (gdb_path_isdir (s.get ()))
extension_char = '/';
}
- xfree (s);
if (extension_char)
{
displayer->putch (displayer, extension_char);
#include "regset.h"
#include "symfile.h"
#include "exec.h"
-#include "readline/tilde.h"
#include "solib.h"
#include "filenames.h"
#include "progspace.h"
#include "build-id.h"
#include <fcntl.h>
-#include "readline/tilde.h"
#include "gdbcore.h"
#include <sys/stat.h>
if (*argv == NULL)
error (_("No executable file name was specified"));
- gdb::unique_xmalloc_ptr<char> filename (tilde_expand (*argv));
+ gdb::unique_xmalloc_ptr<char> filename
+ = gdb_rl_tilde_expand (*argv);
exec_file_attach (filename.get (), from_tty);
}
else
#include "regcache.h"
#include "regset.h"
#include "gdb_bfd.h"
-#include "readline/tilde.h"
#include <algorithm>
#include "gdbsupport/gdb_unlinker.h"
#include "gdbsupport/byte-vector.h"
noprocess ();
if (args && *args)
- corefilename.reset (tilde_expand (args));
+ corefilename = gdb_rl_tilde_expand (args);
else
{
/* Default corefile name is "core.PID". */
#include "gdbsupport/gdb-dlfcn.h"
#include <sys/stat.h>
#include "gdb_bfd.h"
-#include "readline/tilde.h"
#include "completer.h"
#include <forward_list>
{
if (args == NULL)
error (_("No reader name provided."));
- gdb::unique_xmalloc_ptr<char> file (tilde_expand (args));
+ gdb::unique_xmalloc_ptr<char> file
+ = gdb_rl_tilde_expand (args);
if (loaded_jit_reader != NULL)
error (_("JIT reader already loaded. Run jit-reader-unload first."));
#include "gdbtypes.h"
#include "ui-out.h"
#include "command.h"
-#include "readline/tilde.h"
#include "gdbsupport/gdb_regex.h"
#include "dictionary.h"
#include "language.h"
if (argv[outfile_idx + 1] != NULL)
error (_("Junk at end of command"));
gdb::unique_xmalloc_ptr<char> outfile_name
- (tilde_expand (argv[outfile_idx]));
+ = gdb_rl_tilde_expand (argv[outfile_idx]);
if (!arg_outfile.open (outfile_name.get (), FOPEN_WT))
perror_with_name (outfile_name.get ());
outfile = &arg_outfile;
#include "value.h"
#include "language.h"
#include "gdbsupport/event-loop.h"
-#include "readline/tilde.h"
#include "python.h"
#include "extension-priv.h"
#include "cli/cli-utils.h"
#include "filenames.h"
#include "exec.h"
#include "observable.h"
-#include "readline/tilde.h"
#include "solib.h"
#include "interps.h"
#include "filesystem.h"
static int
solib_map_sections (solib &so)
{
- gdb::unique_xmalloc_ptr<char> filename (tilde_expand (so.name.c_str ()));
+ gdb::unique_xmalloc_ptr<char> filename
+ = gdb_rl_tilde_expand (so.name.c_str ());
gdb_bfd_ref_ptr abfd (so.ops ().bfd_open (filename.get ()));
/* If we have a core target then the core target might have some helpful
if (from_tty)
add_flags |= SYMFILE_VERBOSE;
- gdb::unique_xmalloc_ptr<char> filename (
- tilde_expand (so.original_name.c_str ()));
+ gdb::unique_xmalloc_ptr<char> filename
+ = gdb_rl_tilde_expand (so.original_name.c_str ());
gdb_bfd_ref_ptr abfd = so.ops ().bfd_open (filename.get ());
if (abfd != NULL)
#include "filenames.h"
#include "completer.h"
#include "ui-out.h"
-#include "readline/tilde.h"
#include "gdbsupport/enum-flags.h"
#include "gdbsupport/scoped_fd.h"
#include <algorithm>
if (name[0] == '\0')
goto skip_dup;
if (name[0] == '~')
- new_name_holder
- = gdb::unique_xmalloc_ptr<char[]> (tilde_expand (name)).get ();
+ new_name_holder = gdb_rl_tilde_expand (name).get ();
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
new_name_holder = std::string (name) + ".";
else if (strchr (dir, '~'))
{
/* See whether we need to expand the tilde. */
- filename = gdb::unique_xmalloc_ptr<char> (tilde_expand (dir)).get ();
+ filename = gdb_rl_tilde_expand (dir).get ();
}
else
{
#include "filenames.h"
#include "gdbsupport/gdb_obstack.h"
#include "completer.h"
-#include "readline/tilde.h"
#include "block.h"
#include "observable.h"
#include "exec.h"
gdb::unique_xmalloc_ptr<char> absolute_name;
if (!is_target_filename (name))
{
- gdb::unique_xmalloc_ptr<char> expanded_name (tilde_expand (name));
+ gdb::unique_xmalloc_ptr<char> expanded_name
+ = gdb_rl_tilde_expand (name);
/* Look down path for it, allocate 2nd new malloc'd copy. */
desc = openp (getenv ("PATH"),
gdb_argv argv (args);
- gdb::unique_xmalloc_ptr<char> filename (tilde_expand (argv[0]));
+ gdb::unique_xmalloc_ptr<char> filename
+ = gdb_rl_tilde_expand (argv[0]);
if (argv[1] != NULL)
{
if (filename == NULL)
{
/* First non-option argument is always the filename. */
- filename.reset (tilde_expand (arg));
+ filename = gdb_rl_tilde_expand (arg);
}
else if (!seen_addr)
{
#include "typeprint.h"
#include "cli/cli-cmds.h"
#include "source.h"
-#include "readline/tilde.h"
#include <cli/cli-style.h>
#include "gdbsupport/buildargv.h"
if (argv[outfile_idx + 1] != NULL)
error (_("Junk at end of command"));
gdb::unique_xmalloc_ptr<char> outfile_name
- (tilde_expand (argv[outfile_idx]));
+ = gdb_rl_tilde_expand (argv[outfile_idx]);
if (!arg_outfile.open (outfile_name.get (), FOPEN_WT))
perror_with_name (outfile_name.get ());
outfile = &arg_outfile;
if (argv[outfile_idx + 1] != NULL)
error (_("Junk at end of command"));
gdb::unique_xmalloc_ptr<char> outfile_name
- (tilde_expand (argv[outfile_idx]));
+ = gdb_rl_tilde_expand (argv[outfile_idx]);
if (!arg_outfile.open (outfile_name.get (), FOPEN_WT))
perror_with_name (outfile_name.get ());
outfile = &arg_outfile;
#include "inferior.h"
#include <algorithm>
#include "completer.h"
-#include "readline/tilde.h"
#include "cli/cli-style.h"
/* Types. */
if (dir == NULL)
error (_("Missing dir name"));
- gdb::unique_xmalloc_ptr<char> dir1 (tilde_expand (dir));
+ gdb::unique_xmalloc_ptr<char> dir1 = gdb_rl_tilde_expand (dir);
std::string feature_dir (dir1.get ());
unsigned int failed = 0;
#include "extract-store-integer.h"
#include "tracefile.h"
-#include "readline/tilde.h"
#include "gdbsupport/filestuff.h"
#include "gdbsupport/rsp-low.h"
#include "regcache.h"
struct tfile_trace_file_writer *writer
= (struct tfile_trace_file_writer *) self;
- writer->pathname = tilde_expand (filename);
+ writer->pathname = gdb_rl_tilde_expand (filename).release ();
writer->fp = gdb_fopen_cloexec (writer->pathname, "wb").release ();
if (writer->fp == NULL)
error (_("Unable to open file '%s' for saving trace data (%s)"),
#include "run-on-main-thread.h"
#include "gdbsupport/gdb_tilde_expand.h"
#include "gdbsupport/eintr.h"
+#include "readline/tilde.h"
void (*deprecated_error_begin_hook) (void);
/* See utils.h. */
+gdb::unique_xmalloc_ptr<char>
+gdb_rl_tilde_expand (const char *path)
+{
+ return gdb::unique_xmalloc_ptr<char> (tilde_expand (path));
+}
+
+/* See utils.h. */
+
void
copy_bitwise (gdb_byte *dest, ULONGEST dest_offset,
const gdb_byte *source, ULONGEST source_offset,
extern int count_path_elements (const char *path);
extern const char *strip_leading_path_elements (const char *path, int n);
-\f
+
+/* Wrapper around readline's tilde_expand, to return a unique pointer. */
+
+extern gdb::unique_xmalloc_ptr<char> gdb_rl_tilde_expand (const char *path);
+
/* GDB output, ui_file utilities. */
struct ui_file;