public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-pmuldoon-python-backtrace: Use a flags integer instead of explicit parameters.
@ 2012-10-01 14:59 pmuldoon
0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2012-10-01 14:59 UTC (permalink / raw)
To: archer-commits
The branch, archer-pmuldoon-python-backtrace has been updated
via c77c423e819ce42fc776b3ada0cb369f17312c30 (commit)
from 78f6a8a88dd85365967299efc21ec6282687cd15 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit c77c423e819ce42fc776b3ada0cb369f17312c30
Author: Phil Muldoon <pmuldoon@redhat.com>
Date: Mon Oct 1 15:59:16 2012 +0100
Use a flags integer instead of explicit parameters.
-----------------------------------------------------------------------
Summary of changes:
gdb/mi/mi-cmd-stack.c | 51 +++++++++++----------------------------
gdb/python/lib/gdb/__init__.py | 3 ++
gdb/python/py-framefilter.c | 47 +++++++++++++++++++++---------------
gdb/python/python.h | 23 +++++++++++++++--
gdb/stack.c | 19 ++++++++-------
5 files changed, 75 insertions(+), 68 deletions(-)
First 500 lines of diff:
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 773ab75..c99ab05 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -112,18 +112,13 @@ mi_cmd_stack_list_frames (char *command, char **argv, int argc)
if (! raw_arg && frame_filters)
{
int count = frame_high;
+ int flags = PRINT_LEVEL | PRINT_FRAME_INFO;
if (frame_high != -1)
count = (frame_high - frame_low) + 1;
- result = apply_frame_filter (fi,/* frame */
- 1, /* print_level */
- 1, /* print_frame_info */
- 0, /* print_args */
- 0, /* print_locals */
- 0, /* mi_print_args_type */
- 0, /* cli_print_args_type */
- current_uiout, /* out */
- count /* count */);
+
+ result = apply_frame_filter (fi, flags, 0, NULL, current_uiout,
+ count);
}
/* Run the inbuilt backtrace if there are no filters registered, or
@@ -216,15 +211,10 @@ mi_cmd_stack_list_locals (char *command, char **argv, int argc)
if (! raw_arg && frame_filters)
{
- result = apply_frame_filter (frame,/* frame */
- 1, /* print_level */
- 0, /* print_frame_info */
- 0, /* print_args */
- 1, /* print_locals */
- print_value, /* mi_print_args_type */
- 0, /* cli_print_args_type */
- current_uiout, /* out */
- 1 /* count */);
+ int flags = PRINT_LEVEL | PRINT_LOCALS;
+
+ result = apply_frame_filter (frame, flags, print_value,
+ NULL, current_uiout, 1);
}
if (! frame_filters || raw_arg || result == PY_BT_ERROR
@@ -289,19 +279,13 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc)
if (! raw_arg && frame_filters)
{
int count = frame_high;
+ int flags = PRINT_LEVEL | PRINT_ARGS;
if (frame_high != -1)
count = (frame_high - frame_low) + 1;
- result = apply_frame_filter (fi,/* frame */
- 1, /* print_level */
- 0, /* print_frame_info */
- 1, /* print_args */
- 0, /* print_locals */
- print_values, /* mi_print_args_type */
- 0, /* cli_print_args_type */
- current_uiout, /* out */
- count /* count */);
+ result = apply_frame_filter (fi, flags, print_values, NULL,
+ current_uiout, count);
}
if (! frame_filters || raw_arg || result == PY_BT_ERROR
@@ -352,15 +336,10 @@ mi_cmd_stack_list_variables (char *command, char **argv, int argc)
if (! raw_arg && frame_filters)
{
- result = apply_frame_filter (frame,/* frame */
- 1, /* print_level */
- 0, /* print_frame_info */
- 1, /* print_args */
- 1, /* print_locals */
- print_value, /* mi_print_args_type */
- 0, /* cli_print_args_type */
- current_uiout, /* out */
- 1 /* count */);
+ int flags = PRINT_LEVEL | PRINT_ARGS | PRINT_LOCALS;
+
+ result = apply_frame_filter (frame, flags, print_value, NULL,
+ current_uiout, 1);
}
if (! frame_filters || raw_arg || result == PY_BT_ERROR
diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
index 0e020fe..750e29e 100644
--- a/gdb/python/lib/gdb/__init__.py
+++ b/gdb/python/lib/gdb/__init__.py
@@ -70,6 +70,9 @@ sys.argv = ['']
# Initial pretty printers.
pretty_printers = []
+# Initial frame filters.
+frame_filters = {}
+
# Convenience variable to GDB's python directory
PYTHONDIR = os.path.dirname(os.path.dirname(__file__))
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index f3b0aaa..d806ceb 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -30,6 +30,7 @@
#include "hashtab.h"
#include "mi/mi-cmds.h"
#include "demangle.h"
+#include "mi/mi-cmds.h"
#ifdef HAVE_PYTHON
#include "python-internal.h"
@@ -1225,24 +1226,24 @@ bootstrap_python_frame_filters (struct frame_info *frame)
/* Public and dispatch function for frame filters. This is the only
publicly exported function in this file. FRAME is the source
- frame to start frame-filter invocation. PRINT_LEVEL is a flag
- indicating whether to print the frame's relative level in the
+ frame to start frame-filter invocation. FLAGS is an integer
+ holding the flags for printing. The following elements of the
+ FRAME_FILTER_FLAGS enum denotes makeup of FLAGS: PRINT_LEVEL is a
+ flag indicating whether to print the frame's relative level in the
output. PRINT_FRAME_INFO is a flag that indicates whether this
function should print the frame information, PRINT_ARGS is a flag
that indicates whether to print frame arguments, and PRINT_LOCALS,
likewise, with frame local variables. MI_PRINT_ARGS_TYPE is an
- element from an internal enumerator from MI that indicates which
- values types to print. This parameter is ignored if the output is
- detected to be CLI. CLI_PRINT_FRAME_ARGS_TYPE likewise is a an
- element of what value types to print from CLI. OUT is the output
- stream to print, and COUNT is a delimiter (required for MI
- slices). */
-int
-apply_frame_filter (struct frame_info *frame, int print_level,
- int print_frame_info, int print_args,
- int print_locals, int mi_print_args_type,
- const char *cli_print_frame_args_type,
- struct ui_out *out, int count)
+ enum from MI that indicates which values types to print. This
+ parameter is ignored if the output is detected to be CLI.
+ CLI_PRINT_FRAME_ARGS_TYPE likewise is a an element of what value
+ types to print from CLI. OUT is the output stream to print, and
+ COUNT is a delimiter (required for MI slices). */
+
+int apply_frame_filter (struct frame_info *frame, int flags,
+ enum print_values mi_print_args_type,
+ const char *cli_print_frame_args_type,
+ struct ui_out *out, int count)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
struct cleanup *cleanups;
@@ -1250,6 +1251,13 @@ apply_frame_filter (struct frame_info *frame, int print_level,
int print_result = 0;
int success = 0;
PyObject *iterable;
+ int print_level, print_frame_info, print_args, print_locals;
+
+ /* Extract print settings from FLAGS. */
+ print_level = (flags & PRINT_LEVEL) ? 1 : 0;
+ print_frame_info = (flags & PRINT_FRAME_INFO) ? 1 : 0;
+ print_args = (flags & PRINT_ARGS) ? 1 : 0;
+ print_locals = (flags & PRINT_LOCALS) ? 1 : 0;
cleanups = ensure_python_env (gdbarch, current_language);
@@ -1319,13 +1327,12 @@ apply_frame_filter (struct frame_info *frame, int print_level,
#else /* HAVE_PYTHON */
int
-apply_frame_filter (struct frame_info *frame, int print_level,
- int print_frame_info, int print_args,
- int print_locals, int mi_print_args_type,
- const char *cli_print_frame_args_type,
- struct ui_out *out, int count)
+int apply_frame_filter (struct frame_info *frame, int flags,
+ enum print_values mi_print_args_type,
+ const char *cli_print_args_type,
+ struct ui_out *out, int count)
{
- return PY_BT_NO_FILTERS
+ return PY_BT_NO_FILTERS;
}
#endif /* HAVE_PYTHON */
diff --git a/gdb/python/python.h b/gdb/python/python.h
index e06647c..4918757 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;
@@ -33,6 +34,23 @@ static const int PY_BT_ERROR = 0;
static const int PY_BT_COMPLETED = 1;
static const int PY_BT_NO_FILTERS = 2;
+/* 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,
+ };
+
extern void finish_python_initialization (void);
void eval_python_from_control_command (struct command_line *);
@@ -46,9 +64,8 @@ int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
const struct value_print_options *options,
const struct language_defn *language);
-int apply_frame_filter (struct frame_info *frame, int print_level,
- int print_frame_info, int print_args,
- int print_locals, int mi_print_args_type,
+int apply_frame_filter (struct frame_info *frame, int flags,
+ enum print_values mi_print_args_type,
const char *cli_print_args_type,
struct ui_out *out, int count);
diff --git a/gdb/stack.c b/gdb/stack.c
index 368a8c8..46add40 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1724,16 +1724,17 @@ backtrace_command_1 (char *count_exp, int show_locals, int raw,
}
if (! raw)
- result = apply_frame_filter (trailing, /* frame */
- 1, /* print_level */
- 1, /* print_frame_info */
- 1, /* print_args */
- show_locals, /* print_locals */
- 0, /* mi_print_args_type */
- print_frame_arguments, /* cli_print_args_type */
- current_uiout, /* out */
- count /* count */);
+ {
+ int flags = PRINT_LEVEL | PRINT_FRAME_INFO | PRINT_ARGS;
+
+ if (show_locals)
+ flags |= PRINT_LOCALS;
+ result = apply_frame_filter (trailing, flags, 0,
+ print_frame_arguments,
+ current_uiout, count);
+
+ }
/* Run the inbuilt backtrace if there are no filters registered, or
if there was an error in the Python backtracing output. */
if (raw || result == PY_BT_ERROR || result == PY_BT_NO_FILTERS)
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-10-01 14:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-01 14:59 [SCM] archer-pmuldoon-python-backtrace: Use a flags integer instead of explicit parameters pmuldoon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).