This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix python gdb.execute to not paginate


On Thu, Aug 5, 2010 at 5:49 PM, Doug Evans <dje@google.com> wrote:
> 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?

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]