+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.
+
2019-06-04 Christian Biesinger <cbiesinger@google.com>
Add objfile property to gdb.Type.
for (const ada_exc_info &info : exceptions)
{
if (startswith (info.name, word))
- tracker.add_completion
- (gdb::unique_xmalloc_ptr<char> (xstrdup (info.name)));
+ tracker.add_completion (make_unique_xstrdup (info.name));
}
}
xsnprintf (number, sizeof (number), "%d", b->number);
if (strncmp (number, text, len) == 0)
- {
- gdb::unique_xmalloc_ptr<char> copy (xstrdup (number));
- tracker.add_completion (std::move (copy));
- }
+ tracker.add_completion (make_unique_xstrdup (number));
}
return;
scan_expression (const char **cmd, const char *def)
{
if ((*cmd) == NULL || (**cmd) == '\0')
- return gdb::unique_xmalloc_ptr<char> (xstrdup (def));
+ return make_unique_xstrdup (def);
else
{
char *exp;
bool
mkdir_recursive (const char *dir)
{
- gdb::unique_xmalloc_ptr<char> holder (xstrdup (dir));
+ auto holder = make_unique_xstrdup (dir);
char * const start = holder.get ();
char *component_start = start;
char *component_end = start;
gdb_assert (glob.pathc () > 0);
/* "glob" may return more than one match to the path provided by the
user, but we are only interested in the first match. */
- return gdb::unique_xmalloc_ptr<char> (xstrdup (glob.pathv ()[0]));
+ return make_unique_xstrdup (glob.pathv ()[0]);
}
} /* namespace gdb */
+/* Dup STR and return a unique_xmalloc_ptr for the result. */
+
+static inline gdb::unique_xmalloc_ptr<char>
+make_unique_xstrdup (const char *str)
+{
+ return gdb::unique_xmalloc_ptr<char> (xstrdup (str));
+}
+
#endif /* COMMON_GDB_UNIQUE_PTR_H */
we might not be able to display the original casing in a given
path. */
if (len > 0 && len < MAX_PATH)
- return gdb::unique_xmalloc_ptr<char> (xstrdup (buf));
+ return make_unique_xstrdup (buf);
}
#else
{
#endif
/* This system is a lost cause, just dup the buffer. */
- return gdb::unique_xmalloc_ptr<char> (xstrdup (filename));
+ return make_unique_xstrdup (filename);
}
/* See common/pathstuff.h. */
/* Extract the basename of filename, and return immediately
a copy of filename if it does not contain any directory prefix. */
if (base_name == filename)
- return gdb::unique_xmalloc_ptr<char> (xstrdup (filename));
+ return make_unique_xstrdup (filename);
dir_name = (char *) alloca ((size_t) (base_name - filename + 2));
/* Allocate enough space to store the dir_name + plus one extra
return gdb_tilde_expand_up (path);
if (IS_ABSOLUTE_PATH (path))
- return gdb::unique_xmalloc_ptr<char> (xstrdup (path));
+ return make_unique_xstrdup (path);
/* Beware the // my son, the Emacs barfs, the botch that catch... */
return gdb::unique_xmalloc_ptr<char>
if (name != nullptr)
return name;
- return gdb::unique_xmalloc_ptr<char> (xstrdup (natural));
+ return make_unique_xstrdup (natural);
}
/* Get the access flag for the NUM'th field of TYPE. */
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] == ' ')
{
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));
}
}
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));
}
}
{
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));
}
}
}
we're completing / matching everything, avoid returning NULL
which would make callers interpret the result as an error. */
if (demangled_name[0] == '\0' && completion_mode)
- return gdb::unique_xmalloc_ptr<char> (xstrdup (""));
+ return make_unique_xstrdup ("");
gdb::unique_xmalloc_ptr<char> without_params
= cp_remove_params_1 (demangled_name, false);
&& bfd_get_signed_32 (core_bfd, descdata + KF_FD) == fd)
{
char *path = (char *) descdata + KF_PATH;
- return gdb::unique_xmalloc_ptr<char> (xstrdup (path));
+ return make_unique_xstrdup (path);
}
descdata += structsize;
+2019-06-04 Pedro Alves <palves@redhat.com>
+
+ * server.c (captured_main): Use make_unique_xstrdup.
+
2019-06-02 Tom Tromey <tom@tromey.com>
* gdbreplay.c (fromhex): Remove.
int i, n;
n = argc - (next_arg - argv);
- program_path.set (gdb::unique_xmalloc_ptr<char> (xstrdup (next_arg[0])));
+ program_path.set (make_unique_xstrdup (next_arg[0]));
for (i = 1; i < n; i++)
program_args.push_back (xstrdup (next_arg[i]));
program_args.push_back (NULL);
result = gdbscm_with_guile (scscm_eval_scheme_string, (void *) &data);
if (result != NULL)
- return gdb::unique_xmalloc_ptr<char> (xstrdup (result));
+ return make_unique_xstrdup (result);
return NULL;
}
\f
}
*bg_char_p = 0;
- return gdb::unique_xmalloc_ptr<char> (xstrdup (args));
+ return make_unique_xstrdup (args);
}
/* Common actions to take after creating any sort of inferior, by any
const char *str, *s;
if (token.type == LSTOKEN_KEYWORD)
- return gdb::unique_xmalloc_ptr<char> (xstrdup (LS_TOKEN_KEYWORD (token)));
+ return make_unique_xstrdup (LS_TOKEN_KEYWORD (token));
str = LS_TOKEN_STOKEN (token).ptr;
s = remove_trailing_whitespace (str, str + LS_TOKEN_STOKEN (token).length);
output_cores (struct ui_out *uiout, const char *field_name, const char *xcores)
{
ui_out_emit_list list_emitter (uiout, field_name);
- gdb::unique_xmalloc_ptr<char> cores (xstrdup (xcores));
+ auto cores = make_unique_xstrdup (xcores);
char *p = cores.get ();
for (p = strtok (p, ","); p; p = strtok (NULL, ","))
break;
}
- return gdb::unique_xmalloc_ptr<char> (xstrdup (name));
+ return make_unique_xstrdup (name);
}
/* Look, in partial_symtab PST, for symbol whose natural name is NAME.
SELF_CHECK (lang == language_unknown);
/* Test adding a new extension using the CLI command. */
- gdb::unique_xmalloc_ptr<char> args_holder (xstrdup (".hello rust"));
+ auto args_holder = make_unique_xstrdup (".hello rust");
ext_args = args_holder.get ();
set_ext_lang_command (NULL, 1, NULL);
return gdb::unique_xmalloc_ptr<char> (nullptr);
if (transferred == 0)
- return gdb::unique_xmalloc_ptr<char> (xstrdup (""));
+ return make_unique_xstrdup ("");
bufstr[transferred] = 0;
for (tmp = extra; *tmp != NULL; ++tmp)
{
if (strncmp (word, *tmp, len) == 0)
- tracker.add_completion (gdb::unique_xmalloc_ptr<char> (xstrdup (*tmp)));
+ tracker.add_completion (make_unique_xstrdup (*tmp));
}
}
for (var = internalvars; var; var = var->next)
if (strncmp (var->name, name, len) == 0)
- {
- gdb::unique_xmalloc_ptr<char> copy (xstrdup (var->name));
-
- tracker.add_completion (std::move (copy));
- }
+ tracker.add_completion (make_unique_xstrdup (var->name));
}
/* Create an internal variable with name NAME and with a void value.