* defs.h (make_cleanup_restore_uinteger, make_cleanup_restore_ui_file)
	(make_cleanup_restore_page_info)
	(set_batch_flag_and_make_cleanup_restore_page_info): New declarations.
	* gdbcmd.h (execute_command_to_string): New declaration.
	* python/python.c (struct restore_ui_file_closure, restore_ui_file)
	(make_cleanup_restore_ui_file): Move to utils.c
	(execute_gdb_command) <to_string>: Move ...
	* top.c (execute_command_to_string): ... here.  Call
	set_batch_flag_and_make_cleanup_restore_page_info.
	* utils.c (make_cleanup_restore_integer): New source file blank line.
	(make_cleanup_restore_uinteger): New.
	(struct restore_ui_file_closure, do_restore_ui_file)
	(make_cleanup_restore_ui_file): Move here from python/python.c.
	(init_page_info) <batch_flag>
	(do_restore_page_info_cleanup, make_cleanup_restore_page_info)
	(set_batch_flag_and_make_cleanup_restore_page_info): New.

gdb/testsuite/
	* 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/
	* gdb.texinfo (Mode Options) <-batch>
	(Basic Python) <gdb.execute>: Describe setting width and height.
This commit is contained in:
Jan Kratochvil 2010-08-07 15:00:39 +00:00
parent 8574ee7158
commit 5da1313be2
10 changed files with 190 additions and 48 deletions

View file

@ -87,3 +87,26 @@ gdb_test "python import itertools; print 'IMPOR'+'TED'" "IMPORTED" "pythonX.Y/li
gdb_test_no_output \
"python x = gdb.execute('printf \"%d\", 23', to_string = True)"
gdb_test "python print x" "23"
# Test (no) pagination of the executed command.
gdb_test "show height" {Number of lines gdb thinks are in a page is unlimited\.}
set lines 10
gdb_test_no_output "set height $lines"
set test "verify pagination beforehand"
gdb_test_multiple "python print \"\\n\" * $lines" $test {
-re "---Type <return> to continue, or q <return> to quit---$" {
pass $test
}
}
gdb_test "q" "Quit" "verify pagination beforehand: q"
gdb_test "python if gdb.execute('python print \"\\\\n\" * $lines', to_string=True) == \"\\n\" * [expr $lines + 1]: print \"yes\"" "yes" "gdb.execute does not page"
set test "verify pagination afterwards"
gdb_test_multiple "python print \"\\n\" * $lines" $test {
-re "---Type <return> to continue, or q <return> to quit---$" {
pass $test
}
}
gdb_test "q" "Quit" "verify pagination afterwards: q"