Make relocate_{path,gdb_directory} return std::string

This simplifies memory management. I've also changed some global variables
to std::string accordingly (which store the result of these functions),
but not all because some are used with add_setshow_optional_filename_cmd
which requires a char*.

gdb/ChangeLog:

2019-09-11  Christian Biesinger  <cbiesinger@google.com>

	* auto-load.c (auto_load_expand_dir_vars): Update.
	* defs.h (gdb_datadir): Change to std::string.
	(python_libdir): Likewise.
	(relocate_gdb_directory): Change return type to std::string.
	* guile/guile.c (gdbscm_data_directory): Update.
	(initialize_scheme_side): Update.
	* jit.c (jit_reader_dir): Change to std::string.
	(jit_reader_load_command): Update.
	* main.c (gdb_datadir): Change to std::string.
	(python_libdir): Likewise.
	(set_gdb_data_directory): Update.
	(relocate_path): Change to return std::string.
	(relocate_gdb_directory): Change to return std::string.
	(relocate_gdbinit_path_maybe_in_datadir): Update.
	(captured_main_1): Update.
	* python/python.c (do_start_initialization): Update.
	* top.c (show_gdb_datadir): Update.
	* xml-syscall.c (xml_init_syscalls_info): Update.
	(init_syscalls_info): Update.
This commit is contained in:
Christian Biesinger
2019-09-09 12:55:39 -05:00
parent 9224a01377
commit f2aec7f6d1
9 changed files with 81 additions and 60 deletions

View File

@ -316,7 +316,8 @@ static struct syscalls_info *
xml_init_syscalls_info (const char *filename)
{
gdb::optional<gdb::char_vector> full_file
= xml_fetch_content_from_file (filename, gdb_datadir);
= xml_fetch_content_from_file (filename,
const_cast<char *>(gdb_datadir.c_str ()));
if (!full_file)
return NULL;
@ -336,7 +337,7 @@ init_syscalls_info (struct gdbarch *gdbarch)
/* Should we re-read the XML info for this target? */
if (syscalls_info != NULL && !syscalls_info->my_gdb_datadir.empty ()
&& filename_cmp (syscalls_info->my_gdb_datadir.c_str (),
gdb_datadir) != 0)
gdb_datadir.c_str ()) != 0)
{
/* The data-directory changed from the last time we used it.
It means that we have to re-read the XML info. */
@ -361,7 +362,7 @@ init_syscalls_info (struct gdbarch *gdbarch)
{
if (xml_syscall_file != NULL)
warning (_("Could not load the syscall XML file `%s/%s'."),
gdb_datadir, xml_syscall_file);
gdb_datadir.c_str (), xml_syscall_file);
else
warning (_("There is no XML file to open."));