diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2018-03-02 23:22:06 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2018-03-02 23:22:07 -0500 |
commit | e80aaf6183c6692ecc167bf26cbdc53f8f1a55f0 (patch) | |
tree | 6964a92dd94620a07a9d63227c69d8662e99d7b0 /gdb/gdbserver | |
parent | a6743a5420aa02a0550b0f7be004f6c06e90ce21 (diff) | |
download | gdb-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/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 29 | ||||
-rw-r--r-- | gdb/gdbserver/thread-db.c | 11 |
3 files changed, 22 insertions, 25 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 703bdfb..70a9387 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,10 @@ +2018-03-02 Simon Marchi <simon.marchi@polymtl.ca> + + * 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. + 2018-03-01 Markus Metzger <markus.t.metzger@intel.com> * target.h (target_enable_btrace, target_disable_btrace) diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index ad327be..afdd504 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -1309,8 +1309,8 @@ handle_detach (char *own_buf) ARG is the text after "--debug-format=" or "monitor set debug-format". IS_MONITOR is non-zero if we're invoked via "monitor set debug-format". This triggers calls to monitor_output. - The result is NULL if all options were parsed ok, otherwise an error - message which the caller must free. + The result is an empty string if all options were parsed ok, otherwise an + error message which the caller must free. N.B. These commands affect all debug format settings, they are not cumulative. If a format is not specified, it is turned off. @@ -1325,10 +1325,6 @@ handle_detach (char *own_buf) static std::string parse_debug_format_options (const char *arg, int is_monitor) { - VEC (char_ptr) *options; - int ix; - char *option; - /* First turn all debug format options off. */ debug_timestamp = 0; @@ -1336,23 +1332,24 @@ parse_debug_format_options (const char *arg, int is_monitor) while (isspace (*arg)) ++arg; - options = delim_string_to_char_ptr_vec (arg, ','); + std::vector<gdb::unique_xmalloc_ptr<char>> options + = delim_string_to_char_ptr_vec (arg, ','); - for (ix = 0; VEC_iterate (char_ptr, options, ix, option); ++ix) + for (const gdb::unique_xmalloc_ptr<char> &option : options) { - if (strcmp (option, "all") == 0) + if (strcmp (option.get (), "all") == 0) { debug_timestamp = 1; if (is_monitor) monitor_output ("All extra debug format options enabled.\n"); } - else if (strcmp (option, "none") == 0) + else if (strcmp (option.get (), "none") == 0) { debug_timestamp = 0; if (is_monitor) monitor_output ("All extra debug format options disabled.\n"); } - else if (strcmp (option, "timestamp") == 0) + else if (strcmp (option.get (), "timestamp") == 0) { debug_timestamp = 1; if (is_monitor) @@ -1364,16 +1361,10 @@ parse_debug_format_options (const char *arg, int is_monitor) continue; } else - { - std::string msg - = string_printf ("Unknown debug-format argument: \"%s\"\n", option); - - free_char_ptr_vec (options); - return msg; - } + return string_printf ("Unknown debug-format argument: \"%s\"\n", + option.get ()); } - free_char_ptr_vec (options); return std::string (); } diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c index 812aa0f..7dda2ed 100644 --- a/gdb/gdbserver/thread-db.c +++ b/gdb/gdbserver/thread-db.c @@ -683,17 +683,17 @@ try_thread_db_load_from_dir (const char *dir, size_t dir_len) static int thread_db_load_search (void) { - VEC (char_ptr) *dir_vec; - char *this_dir; - int i, rc = 0; + int rc = 0; if (libthread_db_search_path == NULL) libthread_db_search_path = xstrdup (LIBTHREAD_DB_SEARCH_PATH); - dir_vec = dirnames_to_char_ptr_vec (libthread_db_search_path); + std::vector<gdb::unique_xmalloc_ptr<char>> dir_vec + = dirnames_to_char_ptr_vec (libthread_db_search_path); - for (i = 0; VEC_iterate (char_ptr, dir_vec, i, this_dir); ++i) + for (const gdb::unique_xmalloc_ptr<char> &this_dir_up : dir_vec) { + char *this_dir = this_dir_up.get (); const int pdir_len = sizeof ("$pdir") - 1; size_t this_dir_len; @@ -725,7 +725,6 @@ thread_db_load_search (void) } } - free_char_ptr_vec (dir_vec); if (debug_threads) debug_printf ("thread_db_load_search returning %d\n", rc); return rc; |