From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16374 invoked by alias); 26 Feb 2013 11:00:39 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 16310 invoked by uid 9514); 26 Feb 2013 11:00:37 -0000 Date: Tue, 26 Feb 2013 11:00:00 -0000 Message-ID: <20130226110037.16268.qmail@sourceware.org> From: pmuldoon@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-pmuldoon-python-backtrace: Remove whitespace and clarify some comments. X-Git-Refname: refs/heads/archer-pmuldoon-python-backtrace X-Git-Reftype: branch X-Git-Oldrev: 79ce26e92f6596033a14bba223e4839725fed99c X-Git-Newrev: d39df4354f1b9037bc4879ad66f1aebb3181c50b X-SW-Source: 2013-q1/txt/msg00063.txt.bz2 List-Id: The branch, archer-pmuldoon-python-backtrace has been updated via d39df4354f1b9037bc4879ad66f1aebb3181c50b (commit) from 79ce26e92f6596033a14bba223e4839725fed99c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit d39df4354f1b9037bc4879ad66f1aebb3181c50b Author: Phil Muldoon Date: Tue Feb 26 11:00:13 2013 +0000 Remove whitespace and clarify some comments. ----------------------------------------------------------------------- Summary of changes: gdb/python/lib/gdb/command/frame_filters.py | 9 ++-- gdb/python/lib/gdb/frames.py | 7 +-- gdb/python/py-framefilter.c | 75 ++++++++++++++------------- gdb/python/python.h | 6 +- 4 files changed, 49 insertions(+), 48 deletions(-) First 500 lines of diff: diff --git a/gdb/python/lib/gdb/command/frame_filters.py b/gdb/python/lib/gdb/command/frame_filters.py index 4e464e9..01df066 100644 --- a/gdb/python/lib/gdb/command/frame_filters.py +++ b/gdb/python/lib/gdb/command/frame_filters.py @@ -203,7 +203,7 @@ class InfoFrameFilter(gdb.Command): specified by GDB user commands. """ - sorted_frame_filters = sorted (frame_filters.items(), + sorted_frame_filters = sorted (frame_filters.items(), key=lambda i: _get_priority(i[1]), reverse=True) @@ -266,7 +266,7 @@ def _do_enable_frame_filter(command_tuple, flag): _set_enabled(ff, flag) def _complete_frame_filter_list (text,word): - + filter_locations = ["global","progspace"] for objfile in gdb.objfiles(): filter_locations.append(objfile.filename) @@ -288,7 +288,7 @@ def _complete_frame_filter_list (text,word): return flist def _complete_frame_filter_name (word, printer_list): - + printer_keys = printer_list.keys() if (word == ""): return printer_keys @@ -374,7 +374,7 @@ class SetFrameFilterPriority(gdb.Command): super(SetFrameFilterPriority, self).__init__("set python " \ "frame-filter priority", gdb.COMMAND_DATA) - + def _parse_pri_arg(self, arg): """Internal worker to parse a priority from a tuple. @@ -537,4 +537,3 @@ EnableFrameFilter() DisableFrameFilter() SetFrameFilterPriority() ShowFrameFilterPriority() - diff --git a/gdb/python/lib/gdb/frames.py b/gdb/python/lib/gdb/frames.py index f637a7a..1fdca5a 100644 --- a/gdb/python/lib/gdb/frames.py +++ b/gdb/python/lib/gdb/frames.py @@ -94,7 +94,7 @@ def execute_frame_filters(frame, frame_low, frame_high): sliced.append(frame_item) return iter(sliced) - + # -1 for frame_high means until the end of the stack frame, and # None means to the end of the iterator to islice. if frame_high == -1: @@ -103,8 +103,7 @@ def execute_frame_filters(frame, frame_low, frame_high): # The end argument for islice is a count, not a position, so # add one as frames start as zero. frame_high = frame_high + 1; - - - sliced = itertools.islice(frame_iterator, frame_low, frame_high) + + sliced = itertools.islice(frame_iterator, frame_low, frame_high) return sliced diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index 0a118c5..3e075a8 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -28,7 +28,6 @@ #include "valprint.h" #include "annotate.h" #include "hashtab.h" -#include "mi/mi-cmds.h" #include "demangle.h" #include "mi/mi-cmds.h" #include "python-internal.h" @@ -41,6 +40,7 @@ typedef enum mi_print_types MI_PRINT_LOCALS } mi_print_types; + /* Helper function to extract a symbol, name and language definition from a Python object that conforms to the "Symbol Value" interface. OBJ is the Python object to extract the values from. NAME is a @@ -59,17 +59,17 @@ extract_sym (PyObject *obj, char **name, struct symbol **sym, const struct language_defn **language) { PyObject *result = PyObject_CallMethod (obj, "symbol", NULL); - + if (! result) return PY_BT_ERROR; - + /* For 'symbol' callback, the function can return a symbol or a string. */ if (PyString_Check (result)) { *name = python_string_to_host_string (result); Py_DECREF (result); - + if (! *name) return PY_BT_ERROR; *language = python_language; @@ -80,9 +80,9 @@ extract_sym (PyObject *obj, char **name, struct symbol **sym, /* This type checks 'result' during the conversion so we just call it unconditionally and check the return. */ *sym = symbol_object_to_symbol (result); - + Py_DECREF (result); - + if (! *sym) { PyErr_SetString (PyExc_RuntimeError, @@ -90,11 +90,11 @@ extract_sym (PyObject *obj, char **name, struct symbol **sym, "gdb.Symbol or a Python string.")); return PY_BT_ERROR; } - + /* Duplicate the symbol name, so the caller has consistency in garbage collection. */ *name = xstrdup (SYMBOL_PRINT_NAME (*sym)); - + if (language_mode == language_mode_auto) *language = language_def (SYMBOL_LANGUAGE (*sym)); else @@ -178,7 +178,7 @@ mi_should_print (struct symbol *sym, enum mi_print_types type) if (type == MI_PRINT_ALL) print_me = 1; else if (type == MI_PRINT_LOCALS) - print_me = !SYMBOL_IS_ARGUMENT (sym); + print_me = ! SYMBOL_IS_ARGUMENT (sym); else print_me = SYMBOL_IS_ARGUMENT (sym); } @@ -214,7 +214,7 @@ py_print_type (struct ui_out *out, struct value *val) gdbpy_convert_exception (except); return PY_BT_ERROR; } - + return 1; } @@ -237,7 +237,9 @@ py_print_value (struct ui_out *out, struct value *val, /* MI does not print certain values, differentiated by type, depending on what MI_PRINT_TYPE indicates. Test type against option. For CLI print all values. */ - if (args_type == MI_PRINT_SIMPLE_VALUES || args_type == MI_PRINT_ALL_VALUES) + if (args_type == MI_PRINT_SIMPLE_VALUES + || args_type == MI_PRINT_ALL_VALUES) + { struct type *type; @@ -291,7 +293,7 @@ get_py_iter_from_func (PyObject *filter, char *func) { PyObject *result = PyObject_CallMethod (filter, func, NULL); - if (result) + if (result) { if (result == Py_None) { @@ -301,9 +303,8 @@ get_py_iter_from_func (PyObject *filter, char *func) else { PyObject *iterator = PyObject_GetIter (result); - + Py_DECREF (result); - return iterator; } } @@ -349,7 +350,11 @@ py_print_single_arg (struct ui_out *out, val = fv; /* MI has varying rules for tuples, but generally if there is only - one element in each item in the list, do not start a tuple. */ + one element in each item in the list, do not start a tuple. The + exception is -stack-list-variables which emits an ARGS="1" field + if the value is a frame argument. This is denoted in this + function with PRINT_ARGS_FIELD which is flag from the caller to + emit the ARGS field. */ if (ui_out_is_mi_like_p (out)) { if (print_args_field || args_type != MI_PRINT_NO_VALUES) @@ -359,13 +364,13 @@ py_print_single_arg (struct ui_out *out, TRY_CATCH (except, RETURN_MASK_ALL) { annotate_arg_begin (); - + /* If frame argument is populated, check for entry-values and the entry value options. */ if (fa) { struct ui_file *stb; - + stb = mem_fileopen (); make_cleanup_ui_file_delete (stb); fprintf_symbol_filtered (stb, SYMBOL_PRINT_NAME (fa->sym), @@ -391,10 +396,10 @@ py_print_single_arg (struct ui_out *out, ui_out_field_string (out, "name", sym_name); annotate_arg_name_end (); - + if (! ui_out_is_mi_like_p (out)) ui_out_text (out, "="); - + if (print_args_field) ui_out_field_int (out, "arg", 1); } @@ -404,7 +409,9 @@ py_print_single_arg (struct ui_out *out, goto error; } - /* For MI print the type, but only for simple values. */ + /* For MI print the type, but only for simple values. This seems + weird, but this is how MI choose to format the various output + types. */ if (args_type == MI_PRINT_SIMPLE_VALUES) { if (! py_print_type (out, val)) @@ -420,10 +427,9 @@ py_print_single_arg (struct ui_out *out, gdbpy_convert_exception (except); goto error; } - - /* If the output is to the CLI, and the user option set print - frame-arguments is set to none, just output "...". */ + /* If the output is to the CLI, and the user option "set print + frame-arguments" is set to none, just output "...". */ if (args_type == CLI_NO_VALUES) { TRY_CATCH (except, RETURN_MASK_ALL) @@ -438,9 +444,8 @@ py_print_single_arg (struct ui_out *out, } else { - /* If CLI, and the first if condition above not true always - print values. For MI do not print values if the enumerator - is PRINT_NO_VALUES. */ + /* Otherwise, print the value for both MI and the CLI, except + for the case of MI_PRINT_NO_VALUES. */ if (args_type != MI_PRINT_NO_VALUES) { if (! py_print_value (out, val, opts, args_type, language)) @@ -665,7 +670,7 @@ enumerate_locals (PyObject *iter, int success = PY_BT_ERROR; struct symbol *sym; volatile struct gdb_exception except; - + success = extract_sym (item, &sym_name, &sym, &language); if (! success) { @@ -729,7 +734,7 @@ enumerate_locals (PyObject *iter, { ui_out_field_string (out, "name", sym_name); xfree (sym_name); - + if (! ui_out_is_mi_like_p (out)) ui_out_text (out, " = "); } @@ -738,7 +743,6 @@ enumerate_locals (PyObject *iter, gdbpy_convert_exception (except); goto error; } - if (args_type == MI_PRINT_SIMPLE_VALUES) { @@ -889,7 +893,7 @@ py_print_args (PyObject *filter, gdbpy_convert_exception (except); goto args_error; } - + do_cleanups (old_chain); return 1; @@ -1269,7 +1273,6 @@ py_print_frame (PyObject *filter, int flags, enum py_frame_args args_type, static PyObject * bootstrap_python_frame_filters (struct frame_info *frame, int frame_low, int frame_high) - { struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); @@ -1285,7 +1288,7 @@ bootstrap_python_frame_filters (struct frame_info *frame, int if (! module) goto error; make_cleanup_py_decref (module); - + sort_func = PyObject_GetAttrString (module, "execute_frame_filters"); if (! sort_func) goto error; @@ -1318,7 +1321,7 @@ bootstrap_python_frame_filters (struct frame_info *frame, int } else Py_RETURN_NONE; - + return iterator; error: @@ -1340,7 +1343,7 @@ bootstrap_python_frame_filters (struct frame_info *frame, int int apply_frame_filter (struct frame_info *frame, int flags, enum py_frame_args args_type, - struct ui_out *out, int frame_low, + struct ui_out *out, int frame_low, int frame_high) { @@ -1389,7 +1392,7 @@ int apply_frame_filter (struct frame_info *frame, int flags, { success = py_print_frame (item, flags, args_type, out, 0, levels_printed); - + /* Do not exit on error printing a single frame. Print the error and continue with other frames. */ if (success == PY_BT_ERROR) @@ -1401,7 +1404,7 @@ int apply_frame_filter (struct frame_info *frame, int flags, done: do_cleanups (cleanups); return success; - + error: gdbpy_print_stack (); do_cleanups (cleanups); diff --git a/gdb/python/python.h b/gdb/python/python.h index 3c47f58..2f8205e 100644 --- a/gdb/python/python.h +++ b/gdb/python/python.h @@ -67,11 +67,11 @@ typedef enum py_frame_args /* Print no values for arguments when invoked from the CLI. */ CLI_NO_VALUES, - /* Print only scalar values for arguments when invoked from the + /* Print only scalar values for arguments when invoked from the CLI. */ CLI_SCALAR_VALUES, - /* Print all values for arguments when invoked from the + /* Print all values for arguments when invoked from the CLI. */ CLI_ALL_VALUES, @@ -94,7 +94,7 @@ int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, int apply_frame_filter (struct frame_info *frame, int flags, enum py_frame_args args_type, - struct ui_out *out, int frame_low, + struct ui_out *out, int frame_low, int frame_high); void preserve_python_values (struct objfile *objfile, htab_t copied_types); hooks/post-receive -- Repository for Project Archer.