aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2018-03-02 23:22:06 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2018-03-02 23:22:07 -0500
commite80aaf6183c6692ecc167bf26cbdc53f8f1a55f0 (patch)
tree6964a92dd94620a07a9d63227c69d8662e99d7b0 /gdb/symfile.c
parenta6743a5420aa02a0550b0f7be004f6c06e90ce21 (diff)
downloadgdb-e80aaf6183c6692ecc167bf26cbdc53f8f1a55f0.zip
gdb-e80aaf6183c6692ecc167bf26cbdc53f8f1a55f0.tar.gz
gdb-e80aaf6183c6692ecc167bf26cbdc53f8f1a55f0.tar.bz2
Make delim_string_to_char_ptr_vec return an std::vector
This patch makes delim_string_to_char_ptr_vec and all related functions use std::vector of gdb::unique_xmalloc_ptr. This allows getting rid of make_cleanup_free_char_ptr_vec. Returning a vector of unique_xmalloc_ptr instead of std::string allows to minimize the impacts on the calling code. We can evaluate later whether we could/should return a vector of std::strings instead. gdb/ChangeLog: * common/gdb_vecs.h (make_cleanup_free_char_ptr_vec): Remove. (delim_string_to_char_ptr_vec): Return std::vector of gdb::unique_xmalloc_ptr. (dirnames_to_char_ptr_vec_append): Take std::vector of gdb::unique_xmalloc_ptr. (dirnames_to_char_ptr_vec): Return std::vector of gdb::unique_xmalloc_ptr. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Take std::vector of gdb::unique_xmalloc_ptr, adjust the code. (delim_string_to_char_ptr_vec): Return an std::vector of gdb::unique_xmalloc_ptr, adjust the code. (dirnames_to_char_ptr_vec_append): Take an std::vector of gdb::unique_xmalloc_ptr, adjust the code. (dirnames_to_char_ptr_vec): Return an std::vector of gdb::unique_xmalloc_ptr, adjust the code. * auto-load.c (auto_load_safe_path_vec): Change type to std::vector of gdb::unique_xmalloc_ptr. (auto_load_expand_dir_vars): Return an std::vector of gdb::unique_xmalloc_ptr, adjust the code. (auto_load_safe_path_vec_update): Adjust. (filename_is_in_auto_load_safe_path_vec): Adjust. (auto_load_objfile_script_1): Adjust. * build-id.c (build_id_to_debug_bfd): Adjust. * linux-thread-db.c (thread_db_load_search): Adjust. * source.c (add_path): Adjust. (openp): Adjust. * symfile.c (find_separate_debug_file): Adjust. * utils.c (do_free_char_ptr_vec): Remove. (make_cleanup_free_char_ptr_vec): Remove. gdb/gdbserver/ChangeLog: * server.c (parse_debug_format_options): Adjust to delim_string_to_char_ptr_vec changes. * thread-db.c (thread_db_load_search): Adjust to dirnames_to_char_ptr_vec changes.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 2a1428b..72bf0d8 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1439,12 +1439,8 @@ find_separate_debug_file (const char *dir,
const char *debuglink,
unsigned long crc32, struct objfile *objfile)
{
- char *debugdir;
char *debugfile;
int i;
- VEC (char_ptr) *debugdir_vec;
- struct cleanup *back_to;
- int ix;
if (separate_debug_file_debug)
printf_unfiltered (_("\nLooking for separate debug info (debug link) for "
@@ -1484,21 +1480,18 @@ find_separate_debug_file (const char *dir,
Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
cause "/..." lookups. */
- debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory);
- back_to = make_cleanup_free_char_ptr_vec (debugdir_vec);
+ std::vector<gdb::unique_xmalloc_ptr<char>> debugdir_vec
+ = dirnames_to_char_ptr_vec (debug_file_directory);
- for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix)
+ for (const gdb::unique_xmalloc_ptr<char> &debugdir : debugdir_vec)
{
- strcpy (debugfile, debugdir);
+ strcpy (debugfile, debugdir.get ());
strcat (debugfile, "/");
strcat (debugfile, dir);
strcat (debugfile, debuglink);
if (separate_debug_file_exists (debugfile, crc32, objfile))
- {
- do_cleanups (back_to);
- return debugfile;
- }
+ return debugfile;
/* If the file is in the sysroot, try using its base path in the
global debugfile directory. */
@@ -1507,20 +1500,16 @@ find_separate_debug_file (const char *dir,
strlen (gdb_sysroot)) == 0
&& IS_DIR_SEPARATOR (canon_dir[strlen (gdb_sysroot)]))
{
- strcpy (debugfile, debugdir);
+ strcpy (debugfile, debugdir.get ());
strcat (debugfile, canon_dir + strlen (gdb_sysroot));
strcat (debugfile, "/");
strcat (debugfile, debuglink);
if (separate_debug_file_exists (debugfile, crc32, objfile))
- {
- do_cleanups (back_to);
- return debugfile;
- }
+ return debugfile;
}
}
- do_cleanups (back_to);
xfree (debugfile);
return NULL;
}