From: Pedro Alves <palves@redhat.com>
To: Catalin Udma <catalin.udma@freescale.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] python: Use console format for output of gdb.execute command
Date: Tue, 29 Mar 2016 16:40:00 -0000 [thread overview]
Message-ID: <56FAAFD6.8030705@redhat.com> (raw)
In-Reply-To: <1456756452-15880-1-git-send-email-catalin.udma@freescale.com>
Hi Catalin,
On 02/29/2016 02:34 PM, Catalin Udma wrote:
> When gdb is started in MI mode, the output of gdb.execute
> command is in MI-format in case when it is executed from python stop
> handler while for all other cases the output is in console-format.
>
> To assure consistent output format, this is fixed by using the console
> format for all python gdb command executions.
This seems like the right thing to do. See comments below.
> diff --git a/gdb/python/python.c b/gdb/python/python.c
> index 7202105..8a987f9 100644
> --- a/gdb/python/python.c
> +++ b/gdb/python/python.c
> @@ -658,10 +658,18 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
> /* Copy the argument text in case the command modifies it. */
> char *copy = xstrdup (arg);
> struct cleanup *cleanup = make_cleanup (xfree, copy);
> + struct ui_out *saved_uiout;
> + struct interp *interp;
>
> make_cleanup_restore_integer (&interpreter_async);
> interpreter_async = 0;
>
> + /* Use the console interpreter uiout to have the same print format
> + for console or MI. */
> + interp = interp_lookup ("console");
> + saved_uiout = current_uiout;
> + current_uiout = interp_ui_out (interp);
> +
> prevent_dont_repeat ();
> if (to_string)
> result = execute_command_to_string (copy, from_tty);
> @@ -671,6 +679,9 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
> execute_command (copy, from_tty);
> }
>
> + /* Restore the saved uiout. */
> + current_uiout = saved_uiout;
This needs to be restored with a cleanup instead.
> +
> do_cleanups (cleanup);
> }
> CATCH (except, RETURN_MASK_ALL)
> diff --git a/gdb/testsuite/gdb.python/py-mi-events-gdb.py b/gdb/testsuite/gdb.python/py-mi-events-gdb.py
> new file mode 100644
> index 0000000..9d0c070
> --- /dev/null
> +++ b/gdb/testsuite/gdb.python/py-mi-events-gdb.py
> +# This file is part of the GDB testsuite. It tests python printing
> +# to string from event handlers.
Double-space after period.
> +
> +
> +import gdb
> +
> +
> +def signal_stop_handler (event):
> + """Stop event handler"""
> + if (isinstance (event, gdb.StopEvent)):
> +
OOC, why is this one an isinstance check, while below you
have an assert?
> +def continue_handler (event):
> + """Continue event handler"""
> + assert (isinstance (event, gdb.ContinueEvent))
> +int
> +main (void)
> +{
> + while (1);
Please avoid tests that run forever:
https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Don.27t_write_tests_that_run_forever
Thanks,
Pedro Alves
next prev parent reply other threads:[~2016-03-29 16:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-29 14:35 Catalin Udma
2016-03-02 22:20 ` Phil Muldoon
2016-03-03 10:25 ` Catalin-Dan Udma
2016-03-29 16:40 ` Pedro Alves [this message]
2016-03-31 10:43 ` Catalin-Dan Udma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56FAAFD6.8030705@redhat.com \
--to=palves@redhat.com \
--cc=catalin.udma@freescale.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox