From patchwork Fri Nov 14 10:40:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Perry X-Patchwork-Id: 3734 Received: (qmail 7455 invoked by alias); 14 Nov 2014 10:41:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 7439 invoked by uid 89); 14 Nov 2014 10:41:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f174.google.com Received: from mail-wi0-f174.google.com (HELO mail-wi0-f174.google.com) (209.85.212.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 14 Nov 2014 10:41:01 +0000 Received: by mail-wi0-f174.google.com with SMTP id h11so2246248wiw.7 for ; Fri, 14 Nov 2014 02:40:58 -0800 (PST) X-Received: by 10.180.101.200 with SMTP id fi8mr6190667wib.77.1415961658291; Fri, 14 Nov 2014 02:40:58 -0800 (PST) Received: from [192.168.123.77] (82-69-37-147.dsl.in-addr.zen.co.uk. [82.69.37.147]) by mx.google.com with ESMTPSA id td9sm2893425wic.15.2014.11.14.02.40.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Nov 2014 02:40:57 -0800 (PST) Message-ID: <5465DC37.5040808@gmail.com> Date: Fri, 14 Nov 2014 10:40:55 +0000 From: Thomas Perry User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH] Fix behaviour of 'show' commands in hook functions in MI mode X-IsSubscribed: yes Hi, This is my first patch, so apologies in advance for anything that I haven't done quite right. In console mode, if I add a 'hook-run' which executes (for example) 'show inferior-tty', the result is printed before the run, and if I add a 'hookpost-run' with the same command, the result is printed after the run. This behaviour matches the documentation (and my expectations). In MI mode, 'show' commands in post-execution hooks seem to be ignored, and the result of a 'show' in a pre-execution hook is printed AFTER the hooked command has terminated, for example in an exec-async-output record as follows: *stopped,value="",reason="exited-normally" The following patch modifies the behaviour of a 'show' command executed in a hook function in MI mode, so that it will print the result using the console-mode behaviour, wrapped up as an MI console-stream-output record. I hope this is reasonable -- please get in touch if it warrants discussion. To reproduce: echo "int main() { }" | gcc -x c - echo -e "set inferior-tty /dev/null\ndefine hook-run\nshow \ inferior-tty\nend\nrun\nquit" > x gdb -i=mi -x x ./a.out Patch: * cli/cli-setshow.c: Print the results of 'show' commands in hook functions in MI mode using the console-mode behaviour. { diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index a7d0728..1659fca 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -21,6 +21,7 @@ #include #include "arch-utils.h" #include "observer.h" +#include "top.h" #include "ui-out.h" @@ -649,7 +650,7 @@ do_show_command (const char *arg, int from_tty, struct cmd_list_element *c) code to print the value out. For the latter there should be MI and CLI specific versions. */ - if (ui_out_is_mi_like_p (uiout)) + if (ui_out_is_mi_like_p (uiout) && !in_user_command) ui_out_field_stream (uiout, "value", stb); else