public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org, David Malcolm <dmalcolm@redhat.com>
Subject: Re: [patch] Fix python gdb.execute to not paginate
Date: Fri, 06 Aug 2010 00:49:00 -0000	[thread overview]
Message-ID: <AANLkTi=hwoZz8ND87HPgM7R0a69oM-DvTT7gNYLvW7Ls@mail.gmail.com> (raw)
In-Reply-To: <20100805212008.GA12652@host1.dyn.jankratochvil.net>

On Thu, Aug 5, 2010 at 2:20 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> Hi,
>
> downstream Bug: https://bugzilla.redhat.com/show_bug.cgi?id=620930
> (gdb) python for i in range(100): a = gdb.execute('info registers', to_string=True)
> ---Type <return> to continue, or q <return> to quit---
>
> When at it I have merged it with making --batch more batch, as the output IMO
> should not depend on the momentarily terminal - wrapping and indenting the
> output on its width.
>
> The patch makes python gdb.execute running in the --batch mode.  I understand
> it may not be universally right but so far I believe it is.  What do you
> think?
>
> (--batch should be IMO somehow merged now with `set interactive-mode'.  That
> is not a part of this patch.)
>
>
> Regards,
> Jan
>
>
> gdb/
> 2010-08-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>        * defs.h (make_cleanup_restore_uinteger)
>        (make_cleanup_restore_page_info): New declarations.
>        * python/python.c: Include main.h.
>        (execute_gdb_command) <to_string>: Temporarily set BATCH_FLAG and call
>        init_page_info.
>        * utils.c (make_cleanup_restore_uinteger)
>        (init_page_info) <batch_flag>
>        (do_restore_page_info_cleanup, make_cleanup_restore_page_info): New.
>
> gdb/testsuite/
> 2010-08-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>        * gdb.python/python.exp (show height, set height 10)
>        (verify pagination beforehand, verify pagination beforehand: q)
>        (gdb.execute does not page, verify pagination afterwards)
>        (verify pagination afterwards: q): New.
>
> gdb/doc/
> 2010-08-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>        * gdb.texinfo (Mode Options) <-batch>
>        (Basic Python) <gdb.execute>: Describe setting width and height.

Yikes, nasty problem.

@@ -380,6 +381,13 @@ execute_gdb_command (PyObject *self, PyObject
*args, PyObject *kw)

      if (to_string)
       {
+         /* GDB_STDOUT should be better already restored during these
+            restoration callbacks.  */
+         make_cleanup_restore_page_info ();
+         make_cleanup_restore_integer (&batch_flag);
+         batch_flag = 1;
+         init_page_info ();
+
         str_file = mem_fileopen ();

         make_cleanup_restore_ui_file (&gdb_stdout);

IWBN to bury the implementation details.  I.e. move the setting of
batch_flag into utils.c.  Plus calling init_page_info here feels
wrong.  New function in utils.c that performs all the needed changes,
and have just one make_cleanup_restore_foo routine to switch back?

  reply	other threads:[~2010-08-06  0:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-05 21:20 Jan Kratochvil
2010-08-06  0:49 ` Doug Evans [this message]
2010-08-06  1:22   ` Doug Evans
2010-08-06 17:15     ` Tom Tromey
2010-08-06 17:27       ` Doug Evans
2010-08-06 10:29   ` Jan Kratochvil
2010-08-06 21:37     ` Doug Evans
2010-08-07 15:02       ` Jan Kratochvil
2010-08-09 17:30         ` Tom Tromey
2010-08-09 19:24           ` Jan Kratochvil
2010-08-06  8:35 ` Eli Zaretskii

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='AANLkTi=hwoZz8ND87HPgM7R0a69oM-DvTT7gNYLvW7Ls@mail.gmail.com' \
    --to=dje@google.com \
    --cc=dmalcolm@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).