mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-02 04:27:46 +08:00
framefilter quit: Code cleanup: Reindentation
Nothing significant but I find code more clear with less deep indentation. gdb/ChangeLog 2015-02-11 Jan Kratochvil <jan.kratochvil@redhat.com> * python/py-framefilter.c (py_print_frame): Put conditional code paths with goto first, indent the former else codepath left. Put variable 'elided' to a new inner block.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2015-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
* python/py-framefilter.c (py_print_frame): Put conditional code paths
|
||||||
|
with goto first, indent the former else codepath left. Put variable
|
||||||
|
'elided' to a new inner block.
|
||||||
|
|
||||||
2015-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>
|
2015-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
* python/py-framefilter.c (py_print_frame): Whitespacing fixes.
|
* python/py-framefilter.c (py_print_frame): Whitespacing fixes.
|
||||||
|
@ -1016,7 +1016,7 @@ py_print_frame (PyObject *filter, int flags,
|
|||||||
struct frame_info *frame = NULL;
|
struct frame_info *frame = NULL;
|
||||||
struct cleanup *cleanup_stack = make_cleanup (null_cleanup, NULL);
|
struct cleanup *cleanup_stack = make_cleanup (null_cleanup, NULL);
|
||||||
struct value_print_options opts;
|
struct value_print_options opts;
|
||||||
PyObject *py_inf_frame, *elided;
|
PyObject *py_inf_frame;
|
||||||
int print_level, print_frame_info, print_args, print_locals;
|
int print_level, print_frame_info, print_args, print_locals;
|
||||||
volatile struct gdb_exception except;
|
volatile struct gdb_exception except;
|
||||||
|
|
||||||
@ -1058,11 +1058,8 @@ py_print_frame (PyObject *filter, int flags,
|
|||||||
if (py_mi_print_variables (filter, out, &opts,
|
if (py_mi_print_variables (filter, out, &opts,
|
||||||
args_type, frame) == EXT_LANG_BT_ERROR)
|
args_type, frame) == EXT_LANG_BT_ERROR)
|
||||||
goto error;
|
goto error;
|
||||||
else
|
do_cleanups (cleanup_stack);
|
||||||
{
|
return EXT_LANG_BT_COMPLETED;
|
||||||
do_cleanups (cleanup_stack);
|
|
||||||
return EXT_LANG_BT_COMPLETED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -stack-list-locals does not require a
|
/* -stack-list-locals does not require a
|
||||||
@ -1092,17 +1089,16 @@ py_print_frame (PyObject *filter, int flags,
|
|||||||
if (PyObject_HasAttrString (filter, "address"))
|
if (PyObject_HasAttrString (filter, "address"))
|
||||||
{
|
{
|
||||||
PyObject *paddr = PyObject_CallMethod (filter, "address", NULL);
|
PyObject *paddr = PyObject_CallMethod (filter, "address", NULL);
|
||||||
if (paddr != NULL)
|
|
||||||
{
|
if (paddr == NULL)
|
||||||
if (paddr != Py_None)
|
|
||||||
{
|
|
||||||
address = PyLong_AsLong (paddr);
|
|
||||||
has_addr = 1;
|
|
||||||
}
|
|
||||||
Py_DECREF (paddr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (paddr != Py_None)
|
||||||
|
{
|
||||||
|
address = PyLong_AsLong (paddr);
|
||||||
|
has_addr = 1;
|
||||||
|
}
|
||||||
|
Py_DECREF (paddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1167,64 +1163,61 @@ py_print_frame (PyObject *filter, int flags,
|
|||||||
if (PyObject_HasAttrString (filter, "function"))
|
if (PyObject_HasAttrString (filter, "function"))
|
||||||
{
|
{
|
||||||
PyObject *py_func = PyObject_CallMethod (filter, "function", NULL);
|
PyObject *py_func = PyObject_CallMethod (filter, "function", NULL);
|
||||||
|
const char *function = NULL;
|
||||||
|
|
||||||
if (py_func != NULL)
|
if (py_func == NULL)
|
||||||
{
|
|
||||||
const char *function = NULL;
|
|
||||||
|
|
||||||
if (gdbpy_is_string (py_func))
|
|
||||||
{
|
|
||||||
char *function_to_free;
|
|
||||||
|
|
||||||
function = function_to_free =
|
|
||||||
python_string_to_host_string (py_func);
|
|
||||||
|
|
||||||
if (function == NULL)
|
|
||||||
{
|
|
||||||
Py_DECREF (py_func);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
make_cleanup (xfree, function_to_free);
|
|
||||||
}
|
|
||||||
else if (PyLong_Check (py_func))
|
|
||||||
{
|
|
||||||
CORE_ADDR addr = PyLong_AsUnsignedLongLong (py_func);
|
|
||||||
struct bound_minimal_symbol msymbol;
|
|
||||||
|
|
||||||
if (PyErr_Occurred ())
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
msymbol = lookup_minimal_symbol_by_pc (addr);
|
|
||||||
if (msymbol.minsym != NULL)
|
|
||||||
function = MSYMBOL_PRINT_NAME (msymbol.minsym);
|
|
||||||
}
|
|
||||||
else if (py_func != Py_None)
|
|
||||||
{
|
|
||||||
PyErr_SetString (PyExc_RuntimeError,
|
|
||||||
_("FrameDecorator.function: expecting a " \
|
|
||||||
"String, integer or None."));
|
|
||||||
Py_DECREF (py_func);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
||||||
{
|
|
||||||
annotate_frame_function_name ();
|
|
||||||
if (function == NULL)
|
|
||||||
ui_out_field_skip (out, "func");
|
|
||||||
else
|
|
||||||
ui_out_field_string (out, "func", function);
|
|
||||||
}
|
|
||||||
if (except.reason < 0)
|
|
||||||
{
|
|
||||||
Py_DECREF (py_func);
|
|
||||||
gdbpy_convert_exception (except);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
Py_DECREF (py_func);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (gdbpy_is_string (py_func))
|
||||||
|
{
|
||||||
|
char *function_to_free;
|
||||||
|
|
||||||
|
function = function_to_free =
|
||||||
|
python_string_to_host_string (py_func);
|
||||||
|
|
||||||
|
if (function == NULL)
|
||||||
|
{
|
||||||
|
Py_DECREF (py_func);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
make_cleanup (xfree, function_to_free);
|
||||||
|
}
|
||||||
|
else if (PyLong_Check (py_func))
|
||||||
|
{
|
||||||
|
CORE_ADDR addr = PyLong_AsUnsignedLongLong (py_func);
|
||||||
|
struct bound_minimal_symbol msymbol;
|
||||||
|
|
||||||
|
if (PyErr_Occurred ())
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
msymbol = lookup_minimal_symbol_by_pc (addr);
|
||||||
|
if (msymbol.minsym != NULL)
|
||||||
|
function = MSYMBOL_PRINT_NAME (msymbol.minsym);
|
||||||
|
}
|
||||||
|
else if (py_func != Py_None)
|
||||||
|
{
|
||||||
|
PyErr_SetString (PyExc_RuntimeError,
|
||||||
|
_("FrameDecorator.function: expecting a " \
|
||||||
|
"String, integer or None."));
|
||||||
|
Py_DECREF (py_func);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||||
|
{
|
||||||
|
annotate_frame_function_name ();
|
||||||
|
if (function == NULL)
|
||||||
|
ui_out_field_skip (out, "func");
|
||||||
|
else
|
||||||
|
ui_out_field_string (out, "func", function);
|
||||||
|
}
|
||||||
|
if (except.reason < 0)
|
||||||
|
{
|
||||||
|
Py_DECREF (py_func);
|
||||||
|
gdbpy_convert_exception (except);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
Py_DECREF (py_func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1254,38 +1247,36 @@ py_print_frame (PyObject *filter, int flags,
|
|||||||
{
|
{
|
||||||
PyObject *py_fn = PyObject_CallMethod (filter, "filename", NULL);
|
PyObject *py_fn = PyObject_CallMethod (filter, "filename", NULL);
|
||||||
|
|
||||||
if (py_fn != NULL)
|
if (py_fn == NULL)
|
||||||
{
|
|
||||||
if (py_fn != Py_None)
|
|
||||||
{
|
|
||||||
char *filename = python_string_to_host_string (py_fn);
|
|
||||||
|
|
||||||
if (filename == NULL)
|
|
||||||
{
|
|
||||||
Py_DECREF (py_fn);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
make_cleanup (xfree, filename);
|
|
||||||
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
||||||
{
|
|
||||||
ui_out_wrap_hint (out, " ");
|
|
||||||
ui_out_text (out, " at ");
|
|
||||||
annotate_frame_source_file ();
|
|
||||||
ui_out_field_string (out, "file", filename);
|
|
||||||
annotate_frame_source_file_end ();
|
|
||||||
}
|
|
||||||
if (except.reason < 0)
|
|
||||||
{
|
|
||||||
Py_DECREF (py_fn);
|
|
||||||
gdbpy_convert_exception (except);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Py_DECREF (py_fn);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (py_fn != Py_None)
|
||||||
|
{
|
||||||
|
char *filename = python_string_to_host_string (py_fn);
|
||||||
|
|
||||||
|
if (filename == NULL)
|
||||||
|
{
|
||||||
|
Py_DECREF (py_fn);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
make_cleanup (xfree, filename);
|
||||||
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||||
|
{
|
||||||
|
ui_out_wrap_hint (out, " ");
|
||||||
|
ui_out_text (out, " at ");
|
||||||
|
annotate_frame_source_file ();
|
||||||
|
ui_out_field_string (out, "file", filename);
|
||||||
|
annotate_frame_source_file_end ();
|
||||||
|
}
|
||||||
|
if (except.reason < 0)
|
||||||
|
{
|
||||||
|
Py_DECREF (py_fn);
|
||||||
|
gdbpy_convert_exception (except);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Py_DECREF (py_fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PyObject_HasAttrString (filter, "line"))
|
if (PyObject_HasAttrString (filter, "line"))
|
||||||
@ -1293,28 +1284,26 @@ py_print_frame (PyObject *filter, int flags,
|
|||||||
PyObject *py_line = PyObject_CallMethod (filter, "line", NULL);
|
PyObject *py_line = PyObject_CallMethod (filter, "line", NULL);
|
||||||
int line;
|
int line;
|
||||||
|
|
||||||
if (py_line != NULL)
|
if (py_line == NULL)
|
||||||
{
|
|
||||||
if (py_line != Py_None)
|
|
||||||
{
|
|
||||||
line = PyLong_AsLong (py_line);
|
|
||||||
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
||||||
{
|
|
||||||
ui_out_text (out, ":");
|
|
||||||
annotate_frame_source_line ();
|
|
||||||
ui_out_field_int (out, "line", line);
|
|
||||||
}
|
|
||||||
if (except.reason < 0)
|
|
||||||
{
|
|
||||||
Py_DECREF (py_line);
|
|
||||||
gdbpy_convert_exception (except);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Py_DECREF (py_line);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (py_line != Py_None)
|
||||||
|
{
|
||||||
|
line = PyLong_AsLong (py_line);
|
||||||
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||||
|
{
|
||||||
|
ui_out_text (out, ":");
|
||||||
|
annotate_frame_source_line ();
|
||||||
|
ui_out_field_int (out, "line", line);
|
||||||
|
}
|
||||||
|
if (except.reason < 0)
|
||||||
|
{
|
||||||
|
Py_DECREF (py_line);
|
||||||
|
gdbpy_convert_exception (except);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Py_DECREF (py_line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1341,38 +1330,42 @@ py_print_frame (PyObject *filter, int flags,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally recursively print elided frames, if any. */
|
{
|
||||||
elided = get_py_iter_from_func (filter, "elided");
|
PyObject *elided;
|
||||||
if (elided == NULL)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
make_cleanup_py_decref (elided);
|
/* Finally recursively print elided frames, if any. */
|
||||||
if (elided != Py_None)
|
elided = get_py_iter_from_func (filter, "elided");
|
||||||
{
|
if (elided == NULL)
|
||||||
PyObject *item;
|
goto error;
|
||||||
|
|
||||||
make_cleanup_ui_out_list_begin_end (out, "children");
|
make_cleanup_py_decref (elided);
|
||||||
|
if (elided != Py_None)
|
||||||
|
{
|
||||||
|
PyObject *item;
|
||||||
|
|
||||||
if (! ui_out_is_mi_like_p (out))
|
make_cleanup_ui_out_list_begin_end (out, "children");
|
||||||
indent++;
|
|
||||||
|
|
||||||
while ((item = PyIter_Next (elided)))
|
if (! ui_out_is_mi_like_p (out))
|
||||||
{
|
indent++;
|
||||||
enum ext_lang_bt_status success = py_print_frame (item, flags,
|
|
||||||
args_type, out,
|
|
||||||
indent,
|
|
||||||
levels_printed);
|
|
||||||
|
|
||||||
if (success == EXT_LANG_BT_ERROR)
|
while ((item = PyIter_Next (elided)))
|
||||||
{
|
{
|
||||||
Py_DECREF (item);
|
enum ext_lang_bt_status success = py_print_frame (item, flags,
|
||||||
goto error;
|
args_type, out,
|
||||||
}
|
indent,
|
||||||
|
levels_printed);
|
||||||
|
|
||||||
Py_DECREF (item);
|
if (success == EXT_LANG_BT_ERROR)
|
||||||
}
|
{
|
||||||
if (item == NULL && PyErr_Occurred ())
|
Py_DECREF (item);
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_DECREF (item);
|
||||||
|
}
|
||||||
|
if (item == NULL && PyErr_Occurred ())
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user