From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5045 invoked by alias); 3 Sep 2010 18:06:44 -0000 Received: (qmail 4856 invoked by uid 22791); 3 Sep 2010 18:06:41 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_TD,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Sep 2010 18:06:25 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o83I6MsR027449 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 3 Sep 2010 14:06:23 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o83I6KcC022421 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 3 Sep 2010 14:06:22 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o83I6KG1017962; Fri, 3 Sep 2010 20:06:20 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o83I6J1t017961; Fri, 3 Sep 2010 20:06:19 +0200 Date: Fri, 03 Sep 2010 20:03:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: pebolle@tiscali.nl Subject: [patch] Fix uiout for execute_command_to_string Message-ID: <20100903180619.GA15409@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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-09/txt/msg00134.txt.bz2 Hi, uiout is currently not redirected in execute_command_to_string. This function is currently testable only using python. (gdb) python gdb.execute("help",to_string=True) Aliases of other commandsMaking program stop at certain pointsExamining dataSpecifying and examining filesMaintenance commandsObscure featuresRunning the programExamining the stackStatus inquiriesSupport facilitiesTracing of program execution without stopping the programUser-defined commands(gdb) Bugreport (with patches posting) by Paul Bolle: https://bugzilla.redhat.com/show_bug.cgi?id=627506 Redirected there also gdb_stdlog as it seems appropriate to me. That is remain unredirected gdb_stdin, gdb_stdtargin, gdb_stdtarg and gdb_stdtargerr, I do not much understand gdb_stdtarg* but it seems to +/- match other redirections in GDB. No regressions on {x86_64,x86_64-m32,i686}-fedora14snapshot-linux-gnu. Thanks, Jan gdb/ 2010-09-03 Jan Kratochvil Redirect also uiout in execute_command_to_string. * defs.h (struct ui_out, make_cleanup_ui_out_redirect_pop): New declarations. * top.c (execute_command_to_string): Move make_cleanup_ui_file_delete to the top. Redirect also gdb_stdlog. Use ui_out_redirect, register make_cleanup_ui_out_redirect_pop. * utils.c (do_ui_out_redirect_pop, make_cleanup_ui_out_redirect_pop): New functions. gdb/testsuite/ 2010-09-03 Jan Kratochvil * gdb.python/python.exp (set height 0, collect help from uiout) (verify help to uiout): New tests. --- a/gdb/defs.h +++ b/gdb/defs.h @@ -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 *)); --- 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} --- a/gdb/top.c +++ b/gdb/top.c @@ -475,12 +475,19 @@ 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); + + 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; execute_command (p, from_tty); --- a/gdb/utils.c +++ b/gdb/utils.c @@ -312,6 +312,21 @@ make_cleanup_ui_file_delete (struct ui_file *arg) } 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")); +} + +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) { free_section_addr_info (arg);