mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-06 07:28:44 +08:00
Remove a cleanup in Python
This removes cleanups from gdbpy_decode_line, in favor of a use of unique_xmalloc_ptr. ChangeLog 2017-08-03 Tom Tromey <tom@tromey.com> * python/python.c (gdbpy_decode_line): Use unique_xmalloc_ptr.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
2017-08-03 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* python/python.c (gdbpy_decode_line): Use unique_xmalloc_ptr.
|
||||||
|
|
||||||
2017-08-03 Tom Tromey <tom@tromey.com>
|
2017-08-03 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* python/python.c (compute_python_string): Return std::string.
|
* python/python.c (compute_python_string): Return std::string.
|
||||||
|
@ -652,7 +652,6 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
|
|||||||
appease gcc. */
|
appease gcc. */
|
||||||
struct symtab_and_line sal;
|
struct symtab_and_line sal;
|
||||||
char *arg = NULL;
|
char *arg = NULL;
|
||||||
struct cleanup *cleanups;
|
|
||||||
gdbpy_ref<> result;
|
gdbpy_ref<> result;
|
||||||
gdbpy_ref<> unparsed;
|
gdbpy_ref<> unparsed;
|
||||||
event_location_up location;
|
event_location_up location;
|
||||||
@ -660,8 +659,6 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
|
|||||||
if (! PyArg_ParseTuple (args, "|s", &arg))
|
if (! PyArg_ParseTuple (args, "|s", &arg))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cleanups = make_cleanup (null_cleanup, NULL);
|
|
||||||
|
|
||||||
sals.sals = NULL;
|
sals.sals = NULL;
|
||||||
|
|
||||||
if (arg != NULL)
|
if (arg != NULL)
|
||||||
@ -685,12 +682,13 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
END_CATCH
|
END_CATCH
|
||||||
|
|
||||||
|
/* Ensure that the sals data is freed, when needed. */
|
||||||
|
gdb::unique_xmalloc_ptr<struct symtab_and_line> free_sals;
|
||||||
if (sals.sals != NULL && sals.sals != &sal)
|
if (sals.sals != NULL && sals.sals != &sal)
|
||||||
make_cleanup (xfree, sals.sals);
|
free_sals.reset (sals.sals);
|
||||||
|
|
||||||
if (except.reason < 0)
|
if (except.reason < 0)
|
||||||
{
|
{
|
||||||
do_cleanups (cleanups);
|
|
||||||
/* We know this will always throw. */
|
/* We know this will always throw. */
|
||||||
gdbpy_convert_exception (except);
|
gdbpy_convert_exception (except);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -702,20 +700,14 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
|
|||||||
|
|
||||||
result.reset (PyTuple_New (sals.nelts));
|
result.reset (PyTuple_New (sals.nelts));
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
{
|
|
||||||
do_cleanups (cleanups);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
for (i = 0; i < sals.nelts; ++i)
|
for (i = 0; i < sals.nelts; ++i)
|
||||||
{
|
{
|
||||||
PyObject *obj;
|
PyObject *obj;
|
||||||
|
|
||||||
obj = symtab_and_line_to_sal_object (sals.sals[i]);
|
obj = symtab_and_line_to_sal_object (sals.sals[i]);
|
||||||
if (! obj)
|
if (! obj)
|
||||||
{
|
|
||||||
do_cleanups (cleanups);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
PyTuple_SetItem (result.get (), i, obj);
|
PyTuple_SetItem (result.get (), i, obj);
|
||||||
}
|
}
|
||||||
@ -728,20 +720,14 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
|
|||||||
|
|
||||||
gdbpy_ref<> return_result (PyTuple_New (2));
|
gdbpy_ref<> return_result (PyTuple_New (2));
|
||||||
if (return_result == NULL)
|
if (return_result == NULL)
|
||||||
{
|
|
||||||
do_cleanups (cleanups);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (arg != NULL && strlen (arg) > 0)
|
if (arg != NULL && strlen (arg) > 0)
|
||||||
{
|
{
|
||||||
unparsed.reset (PyString_FromString (arg));
|
unparsed.reset (PyString_FromString (arg));
|
||||||
if (unparsed == NULL)
|
if (unparsed == NULL)
|
||||||
{
|
|
||||||
do_cleanups (cleanups);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unparsed.reset (Py_None);
|
unparsed.reset (Py_None);
|
||||||
@ -751,8 +737,6 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
|
|||||||
PyTuple_SetItem (return_result.get (), 0, unparsed.release ());
|
PyTuple_SetItem (return_result.get (), 0, unparsed.release ());
|
||||||
PyTuple_SetItem (return_result.get (), 1, result.release ());
|
PyTuple_SetItem (return_result.get (), 1, result.release ());
|
||||||
|
|
||||||
do_cleanups (cleanups);
|
|
||||||
|
|
||||||
return return_result.release ();
|
return return_result.release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user