From 1e611234ee3f4a1d2434f3fe7530cab87c936e0d Mon Sep 17 00:00:00 2001 From: Phil Muldoon Date: Fri, 10 May 2013 10:26:03 +0000 Subject: 2013-05-10 Phil Muldoon * stack.c (backtrace_command_1): Add "no-filters", and Python frame filter logic. (backtrace_command): Add "no-filters" option parsing. (_initialize_stack): Alter help to reflect "no-filters" option. * Makefile.in (SUBDIR_PYTHON_OBS): Add py-framefilter.o (SUBDIR_PYTHON_SRCS): Add py-framefilter.c (py-frame.o): Add target * data-directory/Makefile.in (PYTHON_DIR): Add Python frame filter files. * python/python.h: Add new frame filter constants, and flag enum. (apply_frame_filter): Add definition. * python/python.c (apply_frame_filter): New non-Python enabled function. * python/py-utils.c (py_xdecref): New function. (make_cleanup_py_xdecref): Ditto. * python/py-objfile.c: Declare frame_filters dictionary. (objfpy_dealloc): Add frame_filters dealloc. (objfpy_new): Initialize frame_filters attribute. (objfile_to_objfile_object): Ditto. (objfpy_get_frame_filters): New function. (objfpy_set_frame_filters): New function. * python/py-progspace.c: Declare frame_filters dictionary. (pspy_dealloc): Add frame_filters dealloc. (pspy_new): Initialize frame_filters attribute. (pspacee_to_pspace_object): Ditto. (pspy_get_frame_filters): New function. (pspy_set_frame_filters): New function. * python/py-framefilter.c: New file. * python/lib/gdb/command/frame_filters.py: New file. * python/lib/gdb/frames.py: New file. * python/lib/gdb/__init__.py: Initialize global frame_filters dictionary * python/lib/gdb/FrameDecorator.py: New file. * python/lib/gdb/FrameIterator.py: New file. * mi/mi-cmds.c (mi_cmds): Add frame filters command. * mi/mi-cmds.h: Declare. * mi/mi-cmd-stack.c (mi_cmd_stack_list_frames): Add --no-frame-filter logic, and Python frame filter logic. (stack_enable_frame_filters): New function. (parse_no_frame_option): Ditto. (mi_cmd_stack_list_frames): Add --no-frame-filter and Python frame filter logic. (mi_cmd_stack_list_locals): Ditto. (mi_cmd_stack_list_args): Ditto. (mi_cmd_stack_list_variables): Ditto. * NEWS: Add frame filter note. 2013-05-10 Phil Muldoon * gdb.python/py-framefilter.py: New File. * gdb.python/py-framefilter-mi.exp: Ditto. * gdb.python/py-framefilter.c: Ditto. * gdb.python/py-framefilter-mi.exp: Ditto. * gdb.python/py-framefilter-mi.c: Ditto, * gdb.python/py-framefilter-gdb.py.in: Ditto. 2013-05-10 Phil Muldoon * gdb.texinfo (Backtrace): Add "no-filter" argument. (Python API): Add Frame Filters API, Frame Wrapper API, Writing a Frame Filter/Wrapper, Managing Management of Frame Filters chapter entries. (Frame Filters API): New Node. (Frame Wrapper API): New Node. (Writing a Frame Filter): New Node. (Managing Frame Filters): New Node. (Progspaces In Python): Add note about frame_filters attribute. (Objfiles in Python): Ditto. (GDB/MI Stack Manipulation): Add -enable-frame-filters command, @anchors and --no-frame-filters option to -stack-list-variables, -stack-list-frames, -stack-list-locals and -stack-list-arguments commands. --- gdb/python/python.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'gdb/python/python.h') diff --git a/gdb/python/python.h b/gdb/python/python.h index 24e3077..1a1e5c2 100644 --- a/gdb/python/python.h +++ b/gdb/python/python.h @@ -21,6 +21,7 @@ #define GDB_PYTHON_H #include "value.h" +#include "mi/mi-cmds.h" struct breakpoint_object; @@ -28,6 +29,66 @@ struct breakpoint_object; E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */ #define GDBPY_AUTO_FILE_NAME "-gdb.py" +/* Python frame-filter status return values. */ +enum py_bt_status + { + /* Return when an error has occurred in processing frame filters, + or when printing the stack. */ + PY_BT_ERROR = -1, + + /* Return from internal routines to indicate that the function + succeeded. */ + PY_BT_OK = 1, + + /* Return when the frame filter process is complete, and all + operations have succeeded. */ + PY_BT_COMPLETED = 2, + + /* Return when the frame filter process is complete, but there + were no filter registered and enabled to process. */ + PY_BT_NO_FILTERS = 3 + }; + +/* Flags to pass to apply_frame_filter. */ + +enum frame_filter_flags + { + /* Set this flag if frame level is to be printed. */ + PRINT_LEVEL = 1, + + /* Set this flag if frame information is to be printed. */ + PRINT_FRAME_INFO = 2, + + /* Set this flag if frame arguments are to be printed. */ + PRINT_ARGS = 4, + + /* Set this flag if frame locals are to be printed. */ + PRINT_LOCALS = 8, + }; + +/* A choice of the different frame argument printing strategies that + can occur in different cases of frame filter instantiation. */ +typedef enum py_frame_args +{ + /* Print no values for arguments when invoked from the MI. */ + NO_VALUES = PRINT_NO_VALUES, + + MI_PRINT_ALL_VALUES = PRINT_ALL_VALUES, + + /* Print only simple values (what MI defines as "simple") for + arguments when invoked from the MI. */ + MI_PRINT_SIMPLE_VALUES = PRINT_SIMPLE_VALUES, + + + /* Print only scalar values for arguments when invoked from the + CLI. */ + CLI_SCALAR_VALUES, + + /* Print all values for arguments when invoked from the + CLI. */ + CLI_ALL_VALUES +} py_frame_args; + extern void finish_python_initialization (void); void eval_python_from_control_command (struct command_line *); @@ -41,6 +102,11 @@ int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, const struct value_print_options *options, const struct language_defn *language); +enum py_bt_status apply_frame_filter (struct frame_info *frame, int flags, + enum py_frame_args args_type, + struct ui_out *out, int frame_low, + int frame_high); + void preserve_python_values (struct objfile *objfile, htab_t copied_types); void gdbpy_load_auto_scripts_for_objfile (struct objfile *objfile); -- cgit v1.1