diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2010-09-11 16:00:27 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2010-09-11 16:00:27 +0000 |
commit | 8d4d924b76392dfd191e5bc0e54381befb9af0af (patch) | |
tree | 145c81b97f6ffe3485a2641514e10ec4eab38b68 | |
parent | 84f49b315b57025e0400e2b5d66b49bef3e16e23 (diff) | |
download | gdb-8d4d924b76392dfd191e5bc0e54381befb9af0af.zip gdb-8d4d924b76392dfd191e5bc0e54381befb9af0af.tar.gz gdb-8d4d924b76392dfd191e5bc0e54381befb9af0af.tar.bz2 |
gdb/
Redirect also uiout and stdtarg{,err} in execute_command_to_string.
* cli-logging.c (struct saved_output_files) <targerr>: New.
(set_logging_redirect, pop_output_files, handle_redirections):
Redirect also gdb_stdtargerr.
* defs.h (struct ui_out, make_cleanup_ui_out_redirect_pop): New
declarations.
* event-top.c (gdb_setup_readline, gdb_disable_readline): Redirect
also gdb_stdtargerr.
* top.c (execute_command_to_string): Move make_cleanup_ui_file_delete
to the top. Redirect also gdb_stdlog, gdb_stdtarg and gdb_stdtargerr.
Use ui_out_redirect, register make_cleanup_ui_out_redirect_pop.
* tui/tui-io.c (tui_setup_io): Redirect also gdb_stdtargerr.
* utils.c (do_ui_out_redirect_pop, make_cleanup_ui_out_redirect_pop):
New functions.
gdb/testsuite/
* gdb.python/python.exp (set height 0, collect help from uiout)
(verify help to uiout): New tests.
-rw-r--r-- | gdb/ChangeLog | 18 | ||||
-rw-r--r-- | gdb/cli/cli-logging.c | 6 | ||||
-rw-r--r-- | gdb/defs.h | 4 | ||||
-rw-r--r-- | gdb/event-top.c | 2 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/python.exp | 6 | ||||
-rw-r--r-- | gdb/top.c | 13 | ||||
-rw-r--r-- | gdb/tui/tui-io.c | 2 | ||||
-rw-r--r-- | gdb/utils.c | 20 |
9 files changed, 75 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 70706c5..27a5d5f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,21 @@ +2010-09-11 Jan Kratochvil <jan.kratochvil@redhat.com> + Paul Bolle <pebolle@tiscali.nl> + + Redirect also uiout and stdtarg{,err} in execute_command_to_string. + * cli-logging.c (struct saved_output_files) <targerr>: New. + (set_logging_redirect, pop_output_files, handle_redirections): + Redirect also gdb_stdtargerr. + * defs.h (struct ui_out, make_cleanup_ui_out_redirect_pop): New + declarations. + * event-top.c (gdb_setup_readline, gdb_disable_readline): Redirect + also gdb_stdtargerr. + * top.c (execute_command_to_string): Move make_cleanup_ui_file_delete + to the top. Redirect also gdb_stdlog, gdb_stdtarg and gdb_stdtargerr. + Use ui_out_redirect, register make_cleanup_ui_out_redirect_pop. + * tui/tui-io.c (tui_setup_io): Redirect also gdb_stdtargerr. + * utils.c (do_ui_out_redirect_pop, make_cleanup_ui_out_redirect_pop): + New functions. + 2010-09-10 Pierre Muller <muller@ics.u-strasbg.fr> * hppa-tdep.c (unwind_command): Use host_address_to_string function diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c index fc486d3..2640c28 100644 --- a/gdb/cli/cli-logging.c +++ b/gdb/cli/cli-logging.c @@ -33,6 +33,7 @@ struct saved_output_files struct ui_file *err; struct ui_file *log; struct ui_file *targ; + struct ui_file *targerr; }; static struct saved_output_files saved_output; static char *saved_filename; @@ -116,6 +117,7 @@ set_logging_redirect (char *args, int from_tty, struct cmd_list_element *c) gdb_stderr = output; gdb_stdlog = output; gdb_stdtarg = output; + gdb_stdtargerr = output; logging_no_redirect_file = new_logging_no_redirect_file; /* There is a former output pushed on the ui_out_redirect stack. We want to @@ -154,10 +156,12 @@ pop_output_files (void) gdb_stderr = saved_output.err; gdb_stdlog = saved_output.log; gdb_stdtarg = saved_output.targ; + gdb_stdtargerr = saved_output.targ; saved_output.out = NULL; saved_output.err = NULL; saved_output.log = NULL; saved_output.targ = NULL; + saved_output.targerr = NULL; ui_out_redirect (uiout, NULL); } @@ -211,11 +215,13 @@ handle_redirections (int from_tty) saved_output.err = gdb_stderr; saved_output.log = gdb_stdlog; saved_output.targ = gdb_stdtarg; + saved_output.targerr = gdb_stdtargerr; gdb_stdout = output; gdb_stderr = output; gdb_stdlog = output; gdb_stdtarg = output; + gdb_stdtargerr = output; if (ui_out_redirect (uiout, output) < 0) warning (_("Current output protocol does not support redirection")); @@ -337,6 +337,10 @@ extern struct cleanup *make_cleanup_freeargv (char **); struct ui_file; extern struct cleanup *make_cleanup_ui_file_delete (struct ui_file *); +struct ui_out; +extern struct cleanup * + make_cleanup_ui_out_redirect_pop (struct ui_out *uiout); + struct section_addr_info; extern struct cleanup *(make_cleanup_free_section_addr_info (struct section_addr_info *)); diff --git a/gdb/event-top.c b/gdb/event-top.c index 0fc7f89..a49bddb 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -1048,6 +1048,7 @@ gdb_setup_readline (void) gdb_stderr = stdio_fileopen (stderr); gdb_stdlog = gdb_stderr; /* for moment */ gdb_stdtarg = gdb_stderr; /* for moment */ + gdb_stdtargerr = gdb_stderr; /* for moment */ /* If the input stream is connected to a terminal, turn on editing. */ @@ -1106,6 +1107,7 @@ gdb_disable_readline (void) ui_file_delete (gdb_stderr); gdb_stdlog = NULL; gdb_stdtarg = NULL; + gdb_stdtargerr = NULL; #endif rl_callback_handler_remove (); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 7c1a7da..82e9f9e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-09-11 Jan Kratochvil <jan.kratochvil@redhat.com> + + * gdb.python/python.exp (set height 0, collect help from uiout) + (verify help to uiout): New tests. + 2010-09-10 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> * gdb.base/break-interp.exp (test_ld) <istarget powerpc64-*>: Add diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 8c36d7f..2f6a9fe 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -149,6 +149,12 @@ gdb_test_multiple "python print \"\\n\" * $lines" $test { } gdb_test "q" "Quit" "verify pagination afterwards: q" +gdb_test_no_output "set height 0" + +gdb_test_no_output "python a = gdb.execute('help', to_string=True)" "collect help from uiout" + +gdb_test "python print a" ".*aliases -- Aliases of other commands.*" "verify help to uiout" + # Start with a fresh gdb. clean_restart ${testfile} @@ -475,12 +475,23 @@ execute_command_to_string (char *p, int from_tty) str_file = mem_fileopen (); + make_cleanup_ui_file_delete (str_file); make_cleanup_restore_ui_file (&gdb_stdout); make_cleanup_restore_ui_file (&gdb_stderr); - make_cleanup_ui_file_delete (str_file); + make_cleanup_restore_ui_file (&gdb_stdlog); + make_cleanup_restore_ui_file (&gdb_stdtarg); + make_cleanup_restore_ui_file (&gdb_stdtargerr); + + if (ui_out_redirect (uiout, str_file) < 0) + warning (_("Current output protocol does not support redirection")); + else + make_cleanup_ui_out_redirect_pop (uiout); gdb_stdout = str_file; gdb_stderr = str_file; + gdb_stdlog = str_file; + gdb_stdtarg = str_file; + gdb_stdtargerr = str_file; execute_command (p, from_tty); diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 92da76e..9dcb228 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -545,6 +545,7 @@ tui_setup_io (int mode) gdb_stderr = tui_stderr; gdb_stdlog = gdb_stdout; /* for moment */ gdb_stdtarg = gdb_stderr; /* for moment */ + gdb_stdtargerr = gdb_stderr; /* for moment */ uiout = tui_out; /* Save tty for SIGCONT. */ @@ -557,6 +558,7 @@ tui_setup_io (int mode) gdb_stderr = tui_old_stderr; gdb_stdlog = gdb_stdout; /* for moment */ gdb_stdtarg = gdb_stderr; /* for moment */ + gdb_stdtargerr = gdb_stderr; /* for moment */ uiout = tui_old_uiout; /* Restore readline. */ diff --git a/gdb/utils.c b/gdb/utils.c index 6b1f4ba..98b8ae3 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -311,6 +311,26 @@ make_cleanup_ui_file_delete (struct ui_file *arg) return make_my_cleanup (&cleanup_chain, do_ui_file_delete, arg); } +/* Helper function for make_cleanup_ui_out_redirect_pop. */ + +static void +do_ui_out_redirect_pop (void *arg) +{ + struct ui_out *uiout = arg; + + if (ui_out_redirect (uiout, NULL) < 0) + warning (_("Cannot restore redirection of the current output protocol")); +} + +/* Return a new cleanup that pops the last redirection by ui_out_redirect + with NULL parameter. */ + +struct cleanup * +make_cleanup_ui_out_redirect_pop (struct ui_out *uiout) +{ + return make_my_cleanup (&cleanup_chain, do_ui_out_redirect_pop, uiout); +} + static void do_free_section_addr_info (void *arg) { |