From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24708 invoked by alias); 6 Aug 2010 01:22:53 -0000 Received: (qmail 24695 invoked by uid 22791); 6 Aug 2010 01:22:52 -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) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Aug 2010 01:22:45 +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 o761Mgf3023177 for ; Thu, 5 Aug 2010 18:22:42 -0700 Received: from vws18 (vws18.prod.google.com [10.241.21.146]) by hpaq14.eem.corp.google.com with ESMTP id o761Mf7u032096 for ; Thu, 5 Aug 2010 18:22:41 -0700 Received: by vws18 with SMTP id 18so2098801vws.1 for ; Thu, 05 Aug 2010 18:22:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.62.136 with SMTP id x8mr7820511vch.177.1281057761120; Thu, 05 Aug 2010 18:22:41 -0700 (PDT) Received: by 10.220.201.197 with HTTP; Thu, 5 Aug 2010 18:22:41 -0700 (PDT) In-Reply-To: References: <20100805212008.GA12652@host1.dyn.jankratochvil.net> Date: Fri, 06 Aug 2010 01:22: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/msg00055.txt.bz2 On Thu, Aug 5, 2010 at 5:49 PM, Doug Evans wrote: > 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 outpu= t IMO >> should not depend on the momentarily terminal - wrapping and indenting t= he >> output on its width. >> >> The patch makes python gdb.execute running in the --batch mode. =A0I und= erstand >> it may not be universally right but so far I believe it is. =A0What do y= ou >> 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_= FLAG 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_= info): 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 beforeha= nd: 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 = height. > > Yikes, nasty problem. > > @@ -380,6 +381,13 @@ execute_gdb_command (PyObject *self, PyObject > *args, PyObject *kw) > > =A0 =A0 =A0if (to_string) > =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 /* GDB_STDOUT should be better already restored during = these > + =A0 =A0 =A0 =A0 =A0 =A0restoration callbacks. =A0*/ > + =A0 =A0 =A0 =A0 make_cleanup_restore_page_info (); > + =A0 =A0 =A0 =A0 make_cleanup_restore_integer (&batch_flag); > + =A0 =A0 =A0 =A0 batch_flag =3D 1; > + =A0 =A0 =A0 =A0 init_page_info (); > + > =A0 =A0 =A0 =A0 str_file =3D mem_fileopen (); > > =A0 =A0 =A0 =A0 make_cleanup_restore_ui_file (&gdb_stdout); > > IWBN to bury the implementation details. =A0I.e. move the setting of > batch_flag into utils.c. =A0Plus calling init_page_info here feels > wrong. =A0New function in utils.c that performs all the needed changes, > and have just one make_cleanup_restore_foo routine to switch back? Actually, I wonder if it makes sense to bury more implementation details. Make an API of it, running a gdb command and collecting the result as a string.