From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1387 invoked by alias); 7 Jun 2018 11:33:57 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 1155 invoked by uid 89); 7 Jun 2018 11:33:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=not, or, if, If X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Jun 2018 11:33:43 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 41A1A401EF06; Thu, 7 Jun 2018 11:33:42 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7B356B5BD; Thu, 7 Jun 2018 11:33:38 +0000 (UTC) Subject: Re: variable displayed twice when using GDB/MI To: Xavier Roirand , gdb@sourceware.org References: <20180601140130.GA296965@host1.jankratochvil.net> <4370e1fc-ec28-0889-85fa-28706ce38630@adacore.com> From: Pedro Alves Message-ID: Date: Thu, 07 Jun 2018 11:33:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <4370e1fc-ec28-0889-85fa-28706ce38630@adacore.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2018-06/txt/msg00006.txt.bz2 On 06/05/2018 10:49 AM, Xavier Roirand wrote: > Hello, > > I'm using a simple C program: > > void main() { >         int i=0; > } > > When debugging with MI interpreter, I want to display variable i: > > (gdb) > -break-insert main > ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000000000040049b",func="main",file="foo.c",fullname="/tmp/foo.c",line="2",thread-groups=["i1"],times="0",original-location="main"} > (gdb) > -exec-run > [...] > display i > &"display i\n" > ~"1: i = 0" > ~"\n" > ^done > (gdb) > > If I do a 'next': > > (gdb) > n > &"n\n" > ^running > *running,thread-id="all" > (gdb) > ~"1: i = 0" > ~"\n" > ~"3\t}\n" > ~"1: i = 0" > ~"\n" > [...] > (gdb) > > The variable i is displayed twice, is it expected ? Using CLI interpreter it's displayed only once so I'm wondering if this is expected or not ? This is GDB printing the stop event on both the CLI uiout and on the MI uiout, from mi_on_normal_stop_1: print_stop_event (mi_uiout); console_interp = interp_lookup (current_ui, INTERP_CONSOLE); if (should_print_stop_to_console (console_interp, tp)) print_stop_event (mi->cli_uiout); See intro comment on should_print_stop_to_console, please. print_stop_event is what currently calls "do_displays", so we print the displays twice. Fixing this probably needs to take in consideration whether we print the displays on the CLI uiout even if the stop isn't printed there according to should_print_stop_to_console. I.e., what makes more sense for a user that enabled some display, but then stepped with the frontend's "step" buttons instead of typing "next" or "step". Probably we shouldn't print the displays in that case, just to keep things simple, respecting should_print_stop_to_console, but not 100% sure. Thanks, Pedro Alves