aboutsummaryrefslogtreecommitdiff
path: root/gdb/completer.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2019-06-04 22:40:54 +0100
committerPedro Alves <palves@redhat.com>2019-06-04 22:48:32 +0100
commitb02f78f9285728ce2d05ce01e7b14880f70cd6e6 (patch)
tree44de7b0901c72644693ebd089dd24f6f26fa6097 /gdb/completer.c
parentd3238f7d90715dad7e8da2a8c2486d26124b0c84 (diff)
downloadgdb-b02f78f9285728ce2d05ce01e7b14880f70cd6e6.zip
gdb-b02f78f9285728ce2d05ce01e7b14880f70cd6e6.tar.gz
gdb-b02f78f9285728ce2d05ce01e7b14880f70cd6e6.tar.bz2
Introduce and use make_unique_xstrdup
Adds an utility function to make it shorter to write the common case of wrapping an xstrdup with a unique_xmalloc_ptr, and uses it throughout. Note: I tried to put this in common/common-utils.h near skip_spaces, etc. but that is included in common/common-defs.h before common/gdb_unique_ptr.h is included, so it would fail to compile because gdb::unique_xmalloc_ptr isn't defined at that point yet. I tried moving the gdb_unique_ptr.h inclusion before common-utils.h, but that doesn't work because gdb_unique_ptr.h depends on common-utils.h for xfree. gdb/ChangeLog: 2019-06-04 Pedro Alves <palves@redhat.com> * common/gdb_unique_ptr.h (make_unique_xstrdup): New. * ada-lang.c (catch_ada_completer): Use make_unique_xstrdup. * breakpoint.c (condition_completer): Likewise. * cli/cli-dump.c (scan_expression): Likewise. * common/filestuff.c (mkdir_recursive): Likewise. * common/gdb_tilde_expand.c (gdb_tilde_expand_up) * common/pathstuff.c (gdb_realpath, gdb_realpath_keepfile) (gdb_abspath): Likewise. * compile/compile-cplus-types.c (compile_cplus_instance::decl_name): Likewise. * completer.c (complete_explicit_location): (signal_completer, reg_or_group_completer_1): Likewise. * cp-support.c (cp_remove_params_if_any): Likewise. * fbsd-tdep.c (fbsd_core_vnode_path): Likewise. * guile/scm-safe-call.c (gdbscm_safe_eval_string): Likewise. * infcmd.c (strip_bg_char): Likewise. * linespec.c (copy_token_string): Likewise. * mi/mi-main.c (output_cores): Likewise. * psymtab.c (psymtab_search_name): * symfile.c (test_set_ext_lang_command): Likewise. * target.c (target_fileio_read_stralloc): Likewise. * tui/tui-regs.c (tui_reggroup_completer): Likewise. * value.c (complete_internalvar): Likewise. gdb/gdbserver/ChangeLog: 2019-06-04 Pedro Alves <palves@redhat.com> * server.c (captured_main): Use make_unique_xstrdup.
Diffstat (limited to 'gdb/completer.c')
-rw-r--r--gdb/completer.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/gdb/completer.c b/gdb/completer.c
index 24c8446..d4773f2 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -798,9 +798,7 @@ complete_explicit_location (completion_tracker &tracker,
before: "b -function 'not_loaded_function_yet()'"
after: "b -function 'not_loaded_function_yet()' "
*/
- gdb::unique_xmalloc_ptr<char> text_copy
- (xstrdup (text));
- tracker.add_completion (std::move (text_copy));
+ tracker.add_completion (make_unique_xstrdup (text));
}
else if (quoted_arg_end[1] == ' ')
{
@@ -1723,10 +1721,7 @@ signal_completer (struct cmd_list_element *ignore,
continue;
if (strncasecmp (signame, word, len) == 0)
- {
- gdb::unique_xmalloc_ptr<char> copy (xstrdup (signame));
- tracker.add_completion (std::move (copy));
- }
+ tracker.add_completion (make_unique_xstrdup (signame));
}
}
@@ -1765,10 +1760,7 @@ reg_or_group_completer_1 (completion_tracker &tracker,
i++)
{
if (*name != '\0' && strncmp (word, name, len) == 0)
- {
- gdb::unique_xmalloc_ptr<char> copy (xstrdup (name));
- tracker.add_completion (std::move (copy));
- }
+ tracker.add_completion (make_unique_xstrdup (name));
}
}
@@ -1782,10 +1774,7 @@ reg_or_group_completer_1 (completion_tracker &tracker,
{
name = reggroup_name (group);
if (strncmp (word, name, len) == 0)
- {
- gdb::unique_xmalloc_ptr<char> copy (xstrdup (name));
- tracker.add_completion (std::move (copy));
- }
+ tracker.add_completion (make_unique_xstrdup (name));
}
}
}