Use gdbpy_ref rather than make_cleanup_py_decref
This changes some spots in py-framefilter.c to use gdbpy_ref rather than make_cleanup_py_decref or make_cleanup_py_xdecref. 2017-01-10 Tom Tromey <tom@tromey.com> * python/py-framefilter.c (py_mi_print_variables): Use gdbpy_ref. (py_print_locals, enumerate_locals, py_print_args): Use gdbpy_ref.
This commit is contained in:
parent
06fc9bf7d9
commit
13df46cc0f
2 changed files with 33 additions and 31 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2017-01-10 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* python/py-framefilter.c (py_mi_print_variables): Use gdbpy_ref.
|
||||||
|
(py_print_locals, enumerate_locals, py_print_args): Use gdbpy_ref.
|
||||||
|
|
||||||
2017-01-10 Tom Tromey <tom@tromey.com>
|
2017-01-10 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* python/py-framefilter.c (enumerate_args): Use gdbpy_ref.
|
* python/py-framefilter.c (enumerate_args): Use gdbpy_ref.
|
||||||
|
|
|
@ -693,13 +693,12 @@ enumerate_locals (PyObject *iter,
|
||||||
int print_args_field,
|
int print_args_field,
|
||||||
struct frame_info *frame)
|
struct frame_info *frame)
|
||||||
{
|
{
|
||||||
PyObject *item;
|
|
||||||
struct value_print_options opts;
|
struct value_print_options opts;
|
||||||
|
|
||||||
get_user_print_options (&opts);
|
get_user_print_options (&opts);
|
||||||
opts.deref_ref = 1;
|
opts.deref_ref = 1;
|
||||||
|
|
||||||
while ((item = PyIter_Next (iter)))
|
while (true)
|
||||||
{
|
{
|
||||||
const struct language_defn *language;
|
const struct language_defn *language;
|
||||||
gdb::unique_xmalloc_ptr<char> sym_name;
|
gdb::unique_xmalloc_ptr<char> sym_name;
|
||||||
|
@ -710,16 +709,21 @@ enumerate_locals (PyObject *iter,
|
||||||
int local_indent = 8 + (8 * indent);
|
int local_indent = 8 + (8 * indent);
|
||||||
struct cleanup *locals_cleanups;
|
struct cleanup *locals_cleanups;
|
||||||
|
|
||||||
locals_cleanups = make_cleanup_py_decref (item);
|
gdbpy_ref item (PyIter_Next (iter));
|
||||||
|
if (item == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
success = extract_sym (item, &sym_name, &sym, &sym_block, &language);
|
locals_cleanups = make_cleanup (null_cleanup, NULL);
|
||||||
|
|
||||||
|
success = extract_sym (item.get (), &sym_name, &sym, &sym_block,
|
||||||
|
&language);
|
||||||
if (success == EXT_LANG_BT_ERROR)
|
if (success == EXT_LANG_BT_ERROR)
|
||||||
{
|
{
|
||||||
do_cleanups (locals_cleanups);
|
do_cleanups (locals_cleanups);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
success = extract_value (item, &val);
|
success = extract_value (item.get (), &val);
|
||||||
if (success == EXT_LANG_BT_ERROR)
|
if (success == EXT_LANG_BT_ERROR)
|
||||||
{
|
{
|
||||||
do_cleanups (locals_cleanups);
|
do_cleanups (locals_cleanups);
|
||||||
|
@ -827,9 +831,7 @@ enumerate_locals (PyObject *iter,
|
||||||
END_CATCH
|
END_CATCH
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == NULL && PyErr_Occurred ())
|
if (!PyErr_Occurred ())
|
||||||
goto error;
|
|
||||||
|
|
||||||
return EXT_LANG_BT_OK;
|
return EXT_LANG_BT_OK;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -846,28 +848,24 @@ py_mi_print_variables (PyObject *filter, struct ui_out *out,
|
||||||
struct frame_info *frame)
|
struct frame_info *frame)
|
||||||
{
|
{
|
||||||
struct cleanup *old_chain;
|
struct cleanup *old_chain;
|
||||||
PyObject *args_iter;
|
|
||||||
PyObject *locals_iter;
|
|
||||||
|
|
||||||
args_iter = get_py_iter_from_func (filter, "frame_args");
|
gdbpy_ref args_iter (get_py_iter_from_func (filter, "frame_args"));
|
||||||
old_chain = make_cleanup_py_xdecref (args_iter);
|
|
||||||
if (args_iter == NULL)
|
if (args_iter == NULL)
|
||||||
goto error;
|
return EXT_LANG_BT_ERROR;
|
||||||
|
|
||||||
locals_iter = get_py_iter_from_func (filter, "frame_locals");
|
gdbpy_ref locals_iter (get_py_iter_from_func (filter, "frame_locals"));
|
||||||
if (locals_iter == NULL)
|
if (locals_iter == NULL)
|
||||||
goto error;
|
return EXT_LANG_BT_ERROR;
|
||||||
|
|
||||||
make_cleanup_py_decref (locals_iter);
|
old_chain = make_cleanup_ui_out_list_begin_end (out, "variables");
|
||||||
make_cleanup_ui_out_list_begin_end (out, "variables");
|
|
||||||
|
|
||||||
if (args_iter != Py_None)
|
if (args_iter != Py_None)
|
||||||
if (enumerate_args (args_iter, out, args_type, 1, frame)
|
if (enumerate_args (args_iter.get (), out, args_type, 1, frame)
|
||||||
== EXT_LANG_BT_ERROR)
|
== EXT_LANG_BT_ERROR)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (locals_iter != Py_None)
|
if (locals_iter != Py_None)
|
||||||
if (enumerate_locals (locals_iter, out, 1, args_type, 1, frame)
|
if (enumerate_locals (locals_iter.get (), out, 1, args_type, 1, frame)
|
||||||
== EXT_LANG_BT_ERROR)
|
== EXT_LANG_BT_ERROR)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -890,17 +888,16 @@ py_print_locals (PyObject *filter,
|
||||||
int indent,
|
int indent,
|
||||||
struct frame_info *frame)
|
struct frame_info *frame)
|
||||||
{
|
{
|
||||||
PyObject *locals_iter = get_py_iter_from_func (filter,
|
struct cleanup *old_chain;
|
||||||
"frame_locals");
|
|
||||||
struct cleanup *old_chain = make_cleanup_py_xdecref (locals_iter);
|
|
||||||
|
|
||||||
|
gdbpy_ref locals_iter (get_py_iter_from_func (filter, "frame_locals"));
|
||||||
if (locals_iter == NULL)
|
if (locals_iter == NULL)
|
||||||
goto locals_error;
|
return EXT_LANG_BT_ERROR;
|
||||||
|
|
||||||
make_cleanup_ui_out_list_begin_end (out, "locals");
|
old_chain = make_cleanup_ui_out_list_begin_end (out, "locals");
|
||||||
|
|
||||||
if (locals_iter != Py_None)
|
if (locals_iter != Py_None)
|
||||||
if (enumerate_locals (locals_iter, out, indent, args_type,
|
if (enumerate_locals (locals_iter.get (), out, indent, args_type,
|
||||||
0, frame) == EXT_LANG_BT_ERROR)
|
0, frame) == EXT_LANG_BT_ERROR)
|
||||||
goto locals_error;
|
goto locals_error;
|
||||||
|
|
||||||
|
@ -923,13 +920,13 @@ py_print_args (PyObject *filter,
|
||||||
enum ext_lang_frame_args args_type,
|
enum ext_lang_frame_args args_type,
|
||||||
struct frame_info *frame)
|
struct frame_info *frame)
|
||||||
{
|
{
|
||||||
PyObject *args_iter = get_py_iter_from_func (filter, "frame_args");
|
struct cleanup *old_chain;
|
||||||
struct cleanup *old_chain = make_cleanup_py_xdecref (args_iter);
|
|
||||||
|
|
||||||
|
gdbpy_ref args_iter (get_py_iter_from_func (filter, "frame_args"));
|
||||||
if (args_iter == NULL)
|
if (args_iter == NULL)
|
||||||
goto args_error;
|
return EXT_LANG_BT_ERROR;
|
||||||
|
|
||||||
make_cleanup_ui_out_list_begin_end (out, "args");
|
old_chain = make_cleanup_ui_out_list_begin_end (out, "args");
|
||||||
|
|
||||||
TRY
|
TRY
|
||||||
{
|
{
|
||||||
|
@ -945,7 +942,7 @@ py_print_args (PyObject *filter,
|
||||||
END_CATCH
|
END_CATCH
|
||||||
|
|
||||||
if (args_iter != Py_None)
|
if (args_iter != Py_None)
|
||||||
if (enumerate_args (args_iter, out, args_type, 0, frame)
|
if (enumerate_args (args_iter.get (), out, args_type, 0, frame)
|
||||||
== EXT_LANG_BT_ERROR)
|
== EXT_LANG_BT_ERROR)
|
||||||
goto args_error;
|
goto args_error;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue