public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-pmuldoon-python-backtrace: Add -stack-list-arguments support. Add some tests for MI. Rewrite py_print_frame to cope with frame/args/local request differences between MI and CLI.
@ 2012-08-01 16:58 pmuldoon
0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2012-08-01 16:58 UTC (permalink / raw)
To: archer-commits
The branch, archer-pmuldoon-python-backtrace has been updated
via 3655d06a8c222a30b01dcae78315f443f8401da2 (commit)
from 69d61b34b067f3be63fe01f99c6904d1b2e38200 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 3655d06a8c222a30b01dcae78315f443f8401da2
Author: Phil Muldoon <pmuldoon@redhat.com>
Date: Wed Aug 1 17:57:54 2012 +0100
Add -stack-list-arguments support. Add some tests for MI. Rewrite
py_print_frame to cope with frame/args/local request differences
between MI and CLI.
-----------------------------------------------------------------------
Summary of changes:
gdb/mi/mi-cmd-stack.c | 81 ++++--
gdb/python/py-framefilter.c | 391 ++++++++++++++----------
gdb/python/python.h | 13 +-
gdb/stack.c | 13 +-
gdb/testsuite/gdb.python/py-framefilter-mi.exp | 35 ++-
5 files changed, 342 insertions(+), 191 deletions(-)
First 500 lines of diff:
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 82451bc..c69be24 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -113,9 +113,16 @@ mi_cmd_stack_list_frames (char *command, char **argv, int argc)
if (frame_high != -1)
count = (frame_high - frame_low) + 1;
- result = apply_frame_filter (fi, 1, LOC_AND_ADDRESS, 0,
- 0 /* print args */, current_uiout,
- 0 /* show locals */, count);
+ result = apply_frame_filter (fi,/* frame */
+ 1, /* print_level */
+ LOC_AND_ADDRESS, /* print_what */
+ 1, /* print_frame_info */
+ 0, /* print_args */
+ 0, /* mi_print_args_type */
+ 0, /* cli_print_args_type */
+ current_uiout, /* out */
+ 0, /* print_locals */
+ count /* count */);
}
/* Run the inbuilt backtrace if there are no filters registered, or
@@ -215,15 +222,28 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc)
struct cleanup *cleanup_stack_args;
enum print_values print_values;
struct ui_out *uiout = current_uiout;
+ int raw_arg = 0;
+ int result = 0;
+
+ if (argc > 1)
+ {
+ int j;
+ /* Find 'raw-frames' at argv[1] if passed as an argument */
+ for (j = 0; j < strlen (argv[1]); j++)
+ argv[1][j] = tolower (argv[1][j]);
+
+ if (subset_compare (argv[1], "raw-frames"))
+ raw_arg = 1;
+ }
- if (argc < 1 || argc > 3 || argc == 2)
+ if (argc < 1 || (argc > 3 && ! raw_arg) || (argc == 2 && ! raw_arg))
error (_("-stack-list-arguments: Usage: "
- "PRINT_VALUES [FRAME_LOW FRAME_HIGH]"));
+ "PRINT_VALUES [RAW FRAME_LOW FRAME_HIGH]"));
- if (argc == 3)
+ if (argc >= 3)
{
- frame_low = atoi (argv[1]);
- frame_high = atoi (argv[2]);
+ frame_low = atoi (argv[1] + raw_arg);
+ frame_high = atoi (argv[2] + raw_arg);
}
else
{
@@ -248,21 +268,44 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc)
cleanup_stack_args
= make_cleanup_ui_out_list_begin_end (uiout, "stack-args");
- /* Now let's print the frames up to frame_high, or until there are
- frames in the stack. */
- for (;
- fi && (i <= frame_high || frame_high == -1);
- i++, fi = get_prev_frame (fi))
+ if (! raw_arg && frame_filters)
{
- struct cleanup *cleanup_frame;
+ int count = frame_high;
+
+ if (frame_high != -1)
+ count = (frame_high - frame_low) + 1;
- QUIT;
- cleanup_frame = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
- ui_out_field_int (uiout, "level", i);
- list_args_or_locals (arguments, print_values, fi);
- do_cleanups (cleanup_frame);
+ result = apply_frame_filter (fi,/* frame */
+ 1, /* print_level */
+ LOC_AND_ADDRESS, /* print_what */
+ 0, /* print_frame_info */
+ 1, /* print_args */
+ print_values, /* mi_print_args_type */
+ 0, /* cli_print_args_type */
+ current_uiout, /* out */
+ 0, /* print_locals */
+ count /* count */);
}
+ if (! frame_filters || raw_arg || result == PY_BT_ERROR
+ || result == PY_BT_NO_FILTERS)
+ {
+
+ /* Now let's print the frames up to frame_high, or until there are
+ frames in the stack. */
+ for (;
+ fi && (i <= frame_high || frame_high == -1);
+ i++, fi = get_prev_frame (fi))
+ {
+ struct cleanup *cleanup_frame;
+
+ QUIT;
+ cleanup_frame = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
+ ui_out_field_int (uiout, "level", i);
+ list_args_or_locals (arguments, print_values, fi);
+ do_cleanups (cleanup_frame);
+ }
+ }
do_cleanups (cleanup_stack_args);
}
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 7dd7aaa..05db015 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -29,6 +29,7 @@
#include "valprint.h"
#include "annotate.h"
#include "hashtab.h"
+#include "mi/mi-cmds.h"
#ifdef HAVE_PYTHON
#include "python-internal.h"
@@ -210,16 +211,21 @@ py_print_locals (PyObject *filter,
static int
py_print_args (PyObject *filter,
- struct ui_out *out,
- struct value_print_options opts,
- const char *print_args_type)
+ struct ui_out *out,
+ struct value_print_options opts,
+ int print_type,
+ const char *print_args_type)
{
- struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
+ struct cleanup *old_chain;
PyObject *result = NULL;
+ old_chain = make_cleanup_ui_out_list_begin_end (out, "args");
+
/* Frame arguments. */
annotate_frame_args ();
- ui_out_text (out, " (");
+
+ if (! ui_out_is_mi_like_p (out))
+ ui_out_text (out, " (");
if (PyObject_HasAttrString (filter, "frame_args"))
{
@@ -264,6 +270,8 @@ py_print_args (PyObject *filter,
int value_success = 0;
volatile struct gdb_exception except;
struct ui_file *stb;
+ struct cleanup *inner_cleanup =
+ make_cleanup (null_cleanup, NULL);
value_success = extract_sym_and_value (item,
&sym_name,
@@ -275,31 +283,71 @@ py_print_args (PyObject *filter,
if (! value_success)
goto args_error;
+ if (ui_out_is_mi_like_p (out))
+ {
+ if(print_type != PRINT_NO_VALUES)
+ {
+ inner_cleanup =
+ make_cleanup_ui_out_tuple_begin_end (out,
+ NULL);
+ }
+ }
+
annotate_arg_begin ();
ui_out_field_string (out, "name", sym_name);
- ui_out_text (out, "=");
- annotate_arg_value (value_type (val));
- opts.deref_ref = 1;
- /* True in "summary" mode, false otherwise. */
- opts.summary = !strcmp (print_args_type, "scalars");
+ if (! ui_out_is_mi_like_p (out))
+ ui_out_text (out, "=");
- stb = mem_fileopen ();
- make_cleanup_ui_file_delete (stb);
+ annotate_arg_value (value_type (val));
+ opts.deref_ref = 1;
- TRY_CATCH (except, RETURN_MASK_ALL)
+ if (ui_out_is_mi_like_p (out)
+ && print_type == PRINT_SIMPLE_VALUES)
{
- common_val_print (val, stb, 2, &opts, language);
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ struct type *type;
+ stb = mem_fileopen ();
+ make_cleanup_ui_file_delete (stb);
+ type = check_typedef (value_type (val));
+ type_print (type, "", stb, -1);
+ ui_out_field_stream (out, "type", stb);
+ }
+ if (except.reason > 0)
+ {
+ PyErr_SetString (PyExc_RuntimeError,
+ except.message);
+ goto args_error;
+ }
}
- if (except.reason > 0)
+
+ if (! ui_out_is_mi_like_p (out))
{
- PyErr_SetString (PyExc_RuntimeError,
- except.message);
- goto args_error;
+ opts.summary = !strcmp (print_args_type, "scalars");
}
- ui_out_field_stream (out, "value", stb);
+ if (ui_out_is_mi_like_p (out)
+ && print_type != PRINT_NO_VALUES)
+ {
+ stb = mem_fileopen ();
+ make_cleanup_ui_file_delete (stb);
+
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ common_val_print (val, stb, 2, &opts, language);
+ }
+ if (except.reason > 0)
+ {
+ PyErr_SetString (PyExc_RuntimeError,
+ except.message);
+ goto args_error;
+ }
+
+ ui_out_field_stream (out, "value", stb);
+ }
+ do_cleanups (inner_cleanup);
/* Collect the next item from the iterator. If
this is the last item, we do not print the
",". */
@@ -319,7 +367,8 @@ py_print_args (PyObject *filter,
goto args_error;
}
- ui_out_text (out, ")");
+ if (! ui_out_is_mi_like_p (out))
+ ui_out_text (out, ")");
do_cleanups (old_chain);
return 1;
@@ -355,7 +404,9 @@ static int
py_print_frame (PyObject *filter,
int print_level,
enum print_what print_what,
+ int print_frame_info,
int print_args,
+ int mi_print_args_type,
const char *print_args_type,
int print_locals,
struct ui_out *out,
@@ -367,6 +418,9 @@ py_print_frame (PyObject *filter,
CORE_ADDR address = 0;
struct gdbarch *gdbarch = NULL;
struct frame_info *frame = NULL;
+ struct cleanup *cleanup_stack = make_cleanup (null_cleanup, NULL);
+
+ cleanup_stack = make_cleanup_ui_out_tuple_begin_end (out, "frame");
/* Get the underlying frame. */
if (PyObject_HasAttrString (filter, "inferior_frame"))
@@ -392,29 +446,32 @@ py_print_frame (PyObject *filter,
goto error;
}
- /* Elided frames are also printed with this function (recursively)
- and are printed with indention. */
- if (indent > 0)
- ui_out_spaces (out, indent);
-
- /* The address is required for frame annotations, and also for
- address printing. */
- if (PyObject_HasAttrString (filter, "address"))
+ if (print_frame_info)
{
- PyObject *paddr = PyObject_CallMethod (filter, "address", NULL);
- if (paddr)
+ /* Elided frames are also printed with this function (recursively)
+ and are printed with indention. */
+ if (indent > 0)
+ ui_out_spaces (out, indent);
+
+ /* The address is required for frame annotations, and also for
+ address printing. */
+ if (PyObject_HasAttrString (filter, "address"))
{
- if (paddr != Py_None)
+ PyObject *paddr = PyObject_CallMethod (filter, "address", NULL);
+ if (paddr)
{
- address = PyLong_AsLong (paddr);
- has_addr = 1;
+ if (paddr != Py_None)
+ {
+ address = PyLong_AsLong (paddr);
+ has_addr = 1;
+ }
+ Py_DECREF (paddr);
}
- Py_DECREF (paddr);
+ else
+ goto error;
}
- else
- goto error;
- }
+ }
/* Print frame level. */
if (print_level)
{
@@ -446,107 +503,113 @@ py_print_frame (PyObject *filter,
}
}
- /* Print address to the address field. If an address is not provided,
- print nothing. */
- if (opts.addressprint && has_addr)
+ if (print_frame_info)
{
- annotate_frame_address ();
- ui_out_field_core_addr (out, "addr", gdbarch, address);
- annotate_frame_address_end ();
- }
-
- ui_out_text (out, " in ");
+ /* Print address to the address field. If an address is not provided,
+ print nothing. */
+ if (opts.addressprint && has_addr)
+ {
+ annotate_frame_address ();
+ ui_out_field_core_addr (out, "addr", gdbarch, address);
+ annotate_frame_address_end ();
+ }
- /* Print frame function. */
- if (PyObject_HasAttrString (filter, "function"))
- {
- PyObject *result = PyObject_CallMethod (filter, "function", NULL);
+ ui_out_text (out, " in ");
- if (result)
+ /* Print frame function. */
+ if (PyObject_HasAttrString (filter, "function"))
{
- if (result != Py_None)
- {
- char *func = NULL;
- char *dup = PyString_AsString (result);
+ PyObject *result = PyObject_CallMethod (filter, "function", NULL);
- if (! dup)
+ if (result)
+ {
+ if (result != Py_None)
{
- Py_DECREF (result);
- goto error;
- }
+ char *func = NULL;
+ char *dup = PyString_AsString (result);
- func = xstrdup (dup);
- annotate_frame_function_name ();
- ui_out_field_string (out, "func", func);
- xfree (func);
+ if (! dup)
+ {
+ Py_DECREF (result);
+ goto error;
+ }
+
+ func = xstrdup (dup);
+ annotate_frame_function_name ();
+ ui_out_field_string (out, "func", func);
+ xfree (func);
+ }
+ Py_DECREF (result);
}
- Py_DECREF (result);
+ else
+ goto error;
}
- else
- goto error;
}
+
/* Frame arguments. */
if (print_args)
{
- if (! py_print_args (filter, out, opts, print_args_type))
+ if (! py_print_args (filter, out, opts, mi_print_args_type, print_args_type))
goto error;
}
- annotate_frame_source_begin ();
-
- if (PyObject_HasAttrString (filter, "filename"))
+ if (print_frame_info)
{
- PyObject *result = PyObject_CallMethod (filter, "filename",
- NULL);
- if (result)
+ annotate_frame_source_begin ();
+
+ if (PyObject_HasAttrString (filter, "filename"))
{
- if (result != Py_None)
+ PyObject *result = PyObject_CallMethod (filter, "filename",
+ NULL);
+ if (result)
{
- char *filename = NULL;
- char *dup = PyString_AsString (result);
-
- if (! dup)
+ if (result != Py_None)
{
- Py_DECREF (result);
- goto error;
- }
+ char *filename = NULL;
+ char *dup = PyString_AsString (result);
+
+ if (! dup)
+ {
+ Py_DECREF (result);
+ goto error;
+ }
- filename = xstrdup (dup);
- 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 ();
- xfree (filename);
+ filename = xstrdup (dup);
+ 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 ();
+ xfree (filename);
+ }
+ Py_DECREF (result);
}
- Py_DECREF (result);
- }
- else
+ else
goto error;
- }
-
- if (PyObject_HasAttrString (filter, "line"))
- {
- PyObject *result = PyObject_CallMethod (filter, "line", NULL);
- int line;
+ }
- if (result)
+ if (PyObject_HasAttrString (filter, "line"))
{
- if (result != Py_None)
+ PyObject *result = PyObject_CallMethod (filter, "line", NULL);
+ int line;
+
+ if (result)
{
- line = PyLong_AsLong (result);
- ui_out_text (out, ":");
- annotate_frame_source_line ();
- ui_out_field_int (out, "line", line);
+ if (result != Py_None)
+ {
+ line = PyLong_AsLong (result);
+ ui_out_text (out, ":");
+ annotate_frame_source_line ();
+ ui_out_field_int (out, "line", line);
+ }
+ Py_DECREF (result);
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-08-01 16:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-01 16:58 [SCM] archer-pmuldoon-python-backtrace: Add -stack-list-arguments support. Add some tests for MI. Rewrite py_print_frame to cope with frame/args/local request differences between MI and CLI 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).