diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2010-08-07 15:00:39 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2010-08-07 15:00:39 +0000 |
commit | 5da1313be24d27eef6103a478f75345723e65614 (patch) | |
tree | 0c318f59ab4f7315ffe7d6ce240f1edef083217d /gdb/utils.c | |
parent | 8574ee7158424df46e8e7f9b4937f24345ee343a (diff) | |
download | gdb-5da1313be24d27eef6103a478f75345723e65614.zip gdb-5da1313be24d27eef6103a478f75345723e65614.tar.gz gdb-5da1313be24d27eef6103a478f75345723e65614.tar.bz2 |
gdb/
* 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.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index 0c51dbc..6b1f4ba 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -339,6 +339,7 @@ restore_integer (void *p) /* Remember the current value of *VARIABLE and make it restored when the cleanup is run. */ + struct cleanup * make_cleanup_restore_integer (int *variable) { @@ -352,6 +353,15 @@ make_cleanup_restore_integer (int *variable) xfree); } +/* Remember the current value of *VARIABLE and make it restored when the cleanup + is run. */ + +struct cleanup * +make_cleanup_restore_uinteger (unsigned int *variable) +{ + return make_cleanup_restore_integer ((int *) variable); +} + /* Helper for make_cleanup_unpush_target. */ static void @@ -370,6 +380,34 @@ make_cleanup_unpush_target (struct target_ops *ops) return make_my_cleanup (&cleanup_chain, do_unpush_target, ops); } +struct restore_ui_file_closure +{ + struct ui_file **variable; + struct ui_file *value; +}; + +static void +do_restore_ui_file (void *p) +{ + struct restore_ui_file_closure *closure = p; + + *(closure->variable) = closure->value; +} + +/* Remember the current value of *VARIABLE and make it restored when + the cleanup is run. */ + +struct cleanup * +make_cleanup_restore_ui_file (struct ui_file **variable) +{ + struct restore_ui_file_closure *c = XNEW (struct restore_ui_file_closure); + + c->variable = variable; + c->value = *variable; + + return make_cleanup_dtor (do_restore_ui_file, (void *) c, xfree); +} + struct cleanup * make_my_cleanup2 (struct cleanup **pmy_chain, make_cleanup_ftype *function, void *arg, void (*free_arg) (void *)) @@ -2052,6 +2090,12 @@ static int wrap_column; void init_page_info (void) { + if (batch_flag) + { + lines_per_page = UINT_MAX; + chars_per_line = UINT_MAX; + } + else #if defined(TUI) if (!tui_get_command_dimension (&chars_per_line, &lines_per_page)) #endif @@ -2096,6 +2140,44 @@ init_page_info (void) set_width (); } +/* Helper for make_cleanup_restore_page_info. */ + +static void +do_restore_page_info_cleanup (void *arg) +{ + set_screen_size (); + set_width (); +} + +/* Provide cleanup for restoring the terminal size. */ + +struct cleanup * +make_cleanup_restore_page_info (void) +{ + struct cleanup *back_to; + + back_to = make_cleanup (do_restore_page_info_cleanup, NULL); + make_cleanup_restore_uinteger (&lines_per_page); + make_cleanup_restore_uinteger (&chars_per_line); + + return back_to; +} + +/* Temporarily set BATCH_FLAG and the associated unlimited terminal size. + Provide cleanup for restoring the original state. */ + +struct cleanup * +set_batch_flag_and_make_cleanup_restore_page_info (void) +{ + struct cleanup *back_to = make_cleanup_restore_page_info (); + + make_cleanup_restore_integer (&batch_flag); + batch_flag = 1; + init_page_info (); + + return back_to; +} + /* Set the screen size based on LINES_PER_PAGE and CHARS_PER_LINE. */ static void |