From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8591 invoked by alias); 6 Aug 2010 00:49:44 -0000 Received: (qmail 8578 invoked by uid 22791); 6 Aug 2010 00:49:43 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Aug 2010 00:49:36 +0000 Received: from hpaq14.eem.corp.google.com (hpaq14.eem.corp.google.com [172.25.149.14]) by smtp-out.google.com with ESMTP id o760nY8U023678 for ; Thu, 5 Aug 2010 17:49:34 -0700 Received: from vws2 (vws2.prod.google.com [10.241.21.130]) by hpaq14.eem.corp.google.com with ESMTP id o760nJu9003732 for ; Thu, 5 Aug 2010 17:49:32 -0700 Received: by vws2 with SMTP id 2so8102306vws.35 for ; Thu, 05 Aug 2010 17:49:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.88.138 with SMTP id a10mr7816764vcm.236.1281055772254; Thu, 05 Aug 2010 17:49:32 -0700 (PDT) Received: by 10.220.201.197 with HTTP; Thu, 5 Aug 2010 17:49:32 -0700 (PDT) In-Reply-To: <20100805212008.GA12652@host1.dyn.jankratochvil.net> References: <20100805212008.GA12652@host1.dyn.jankratochvil.net> Date: Fri, 06 Aug 2010 00:49:00 -0000 Message-ID: Subject: Re: [patch] Fix python gdb.execute to not paginate From: Doug Evans To: Jan Kratochvil Cc: gdb-patches@sourceware.org, David Malcolm Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-08/txt/msg00054.txt.bz2 On Thu, Aug 5, 2010 at 2:20 PM, Jan Kratochvil wrote: > Hi, > > downstream Bug: https://bugzilla.redhat.com/show_bug.cgi?id=3D620930 > (gdb) python for i in range(100): a =3D gdb.execute('info registers', to_= string=3DTrue) > ---Type to continue, or q 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. =A0I unde= rstand > it may not be universally right but so far I believe it is. =A0What do you > think? > > (--batch should be IMO somehow merged now with `set interactive-mode'. = =A0That > is not a part of this patch.) > > > Regards, > Jan > > > gdb/ > 2010-08-05 =A0Jan Kratochvil =A0 > > =A0 =A0 =A0 =A0* defs.h (make_cleanup_restore_uinteger) > =A0 =A0 =A0 =A0(make_cleanup_restore_page_info): New declarations. > =A0 =A0 =A0 =A0* python/python.c: Include main.h. > =A0 =A0 =A0 =A0(execute_gdb_command) : Temporarily set BATCH_F= LAG and call > =A0 =A0 =A0 =A0init_page_info. > =A0 =A0 =A0 =A0* utils.c (make_cleanup_restore_uinteger) > =A0 =A0 =A0 =A0(init_page_info) > =A0 =A0 =A0 =A0(do_restore_page_info_cleanup, make_cleanup_restore_page_i= nfo): New. > > gdb/testsuite/ > 2010-08-05 =A0Jan Kratochvil =A0 > > =A0 =A0 =A0 =A0* gdb.python/python.exp (show height, set height 10) > =A0 =A0 =A0 =A0(verify pagination beforehand, verify pagination beforehan= d: q) > =A0 =A0 =A0 =A0(gdb.execute does not page, verify pagination afterwards) > =A0 =A0 =A0 =A0(verify pagination afterwards: q): New. > > gdb/doc/ > 2010-08-05 =A0Jan Kratochvil =A0 > > =A0 =A0 =A0 =A0* gdb.texinfo (Mode Options) <-batch> > =A0 =A0 =A0 =A0(Basic Python) : Describe setting width and h= eight. 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 =3D 1; + init_page_info (); + str_file =3D 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?