diff options
author | Pedro Alves <palves@redhat.com> | 2016-11-08 15:26:45 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-11-08 15:26:45 +0000 |
commit | db1ec11fff1a46f7046bcbd971a42632d2ea795c (patch) | |
tree | 99dbce3d4e42a2b9ce26f5cba1fd8e1f9992973c /gdb/python | |
parent | 3ab692db7f4d96022a132379614031a852de6f35 (diff) | |
download | gdb-db1ec11fff1a46f7046bcbd971a42632d2ea795c.zip gdb-db1ec11fff1a46f7046bcbd971a42632d2ea795c.tar.gz gdb-db1ec11fff1a46f7046bcbd971a42632d2ea795c.tar.bz2 |
Use ui_file_as_string in execute_command_to_string
... and then return std::string and adjust all callers.
gdb/ChangeLog:
2016-11-08 Pedro Alves <palves@redhat.com>
* gdbcmd.h (execute_command_to_string): Now returns std::string.
(lookup_struct_elt_type): Adjust to use std::string.
* top.c (execute_command_to_string): Use ui_file_as_string and
return std::string.
* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
std::string.
* python/python.c (execute_gdb_command): Adjust to use
std::string.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/python.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/gdb/python/python.c b/gdb/python/python.c index d6bd6bf..d9940c2 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -614,7 +614,6 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) PyObject *from_tty_obj = NULL, *to_string_obj = NULL; int from_tty, to_string; static char *keywords[] = {"command", "from_tty", "to_string", NULL }; - char *result = NULL; if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!", keywords, &arg, &PyBool_Type, &from_tty_obj, @@ -639,6 +638,8 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) to_string = cmp; } + std::string to_string_res; + TRY { /* Copy the argument text in case the command modifies it. */ @@ -657,13 +658,9 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) prevent_dont_repeat (); if (to_string) - result = execute_command_to_string (copy, from_tty); + to_string_res = execute_command_to_string (copy, from_tty); else - { - result = NULL; - execute_command (copy, from_tty); - } - + execute_command (copy, from_tty); do_cleanups (cleanup); } CATCH (except, RETURN_MASK_ALL) @@ -675,12 +672,8 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); - if (result) - { - PyObject *r = PyString_FromString (result); - xfree (result); - return r; - } + if (to_string) + return PyString_FromString (to_string_res.c_str ()); Py_RETURN_NONE; } |