Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1850)

Unified Diff: gdb/python/py-cmd.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/python/py-breakpoint.c ('k') | gdb/python/py-continueevent.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/python/py-cmd.c
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index aad1ab466cdc3cf7e0f29b6295be14b5c0ba7fc1..d8e375c82ceee8b93030f476f93402eb165c2771 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -35,7 +35,7 @@ struct cmdpy_completer
/* Python symbol name. */
char *name;
/* Completion function. */
- char **(*completer) (struct cmd_list_element *, char *, char *);
+ completer_ftype *completer;
};
static struct cmdpy_completer completers[] =
@@ -206,12 +206,12 @@ cmdpy_function (struct cmd_list_element *command, char *args, int from_tty)
/* Called by gdb for command completion. */
-static char **
+static VEC (char_ptr) *
cmdpy_completer (struct cmd_list_element *command, char *text, char *word)
{
cmdpy_object *obj = (cmdpy_object *) get_cmd_context (command);
PyObject *textobj, *wordobj, *resultobj = NULL;
- char **result = NULL;
+ VEC (char_ptr) *result = NULL;
struct cleanup *cleanup;
cleanup = ensure_python_env (get_current_arch (), current_language);
@@ -253,10 +253,10 @@ cmdpy_completer (struct cmd_list_element *command, char *text, char *word)
if (len < 0)
goto done;
- result = (char **) xmalloc ((len + 1) * sizeof (char *));
for (i = out = 0; i < len; ++i)
{
PyObject *elt = PySequence_GetItem (resultobj, i);
+ char *item;
if (elt == NULL || ! gdbpy_is_string (elt))
{
@@ -264,16 +264,15 @@ cmdpy_completer (struct cmd_list_element *command, char *text, char *word)
PyErr_Clear ();
continue;
}
- result[out] = python_string_to_host_string (elt);
- if (result[out] == NULL)
+ item = python_string_to_host_string (elt);
+ if (item == NULL)
{
/* Skip problem elements. */
PyErr_Clear ();
continue;
}
- ++out;
+ VEC_safe_push (char_ptr, result, item);
}
- result[out] = NULL;
}
else if (PyInt_Check (resultobj))
{
@@ -436,7 +435,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
&& cmdtype != class_files && cmdtype != class_support
&& cmdtype != class_info && cmdtype != class_breakpoint
&& cmdtype != class_trace && cmdtype != class_obscure
- && cmdtype != class_maintenance)
+ && cmdtype != class_maintenance && cmdtype != class_user)
{
PyErr_Format (PyExc_RuntimeError, _("Invalid command class argument."));
return -1;
@@ -578,7 +577,8 @@ gdbpy_initialize_commands (void)
|| PyModule_AddIntConstant (gdb_module, "COMMAND_OBSCURE",
class_obscure) < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_MAINTENANCE",
- class_maintenance) < 0)
+ class_maintenance) < 0
+ || PyModule_AddIntConstant (gdb_module, "COMMAND_USER", class_user) < 0)
return;
for (i = 0; i < N_COMPLETERS; ++i)
« no previous file with comments | « gdb/python/py-breakpoint.c ('k') | gdb/python/py-continueevent.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698