From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1AF2D385802F for ; Wed, 6 Mar 2024 13:42:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1AF2D385802F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1AF2D385802F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709732569; cv=none; b=PpxpWHvX47fPUmuq7OTEU3A7HXfLuoErbsMo7HuK0U8wOKQRHOZ8o1k0PMnAoUuNUTezfuq39C7NsfyBh9W46yTHSlJ6rduJnYzim5IBxiZX6n2hFlvgxNOEGpEpRXkf+N5pDTSFio95Pc5Nxp3gZH/1Xp+LCiItXxoSz1doorQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709732569; c=relaxed/simple; bh=ROpXRO+SpbYugT8ApmkVQX9/CrFytW+4t8LUWGEhXjM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EeFr39b5XZNB6iwyFF3xlJvSmjf+FXeWZidOuN/vB7W1+9BrfXKO038iSuzeZXW/eu9lgOxj3hvp2hR5BJJTLtMwmRqYJoCfVC4IcvxVWt1p5QeAeyRO0WTTMHvrpCE6Xi0mqolByWs7gArcuutftQz3sBxAAC6hD8Ym6zAzKjE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709732565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=oPIOHmQNCuk7RfRsGjw4wRZkAcaIOHv3BH5X09QQmGE=; b=X7q3ipU76/6lxaV+kik9IOjr6wzPd0BnYu6uymHNQE+34ln0iNo65feMqOu95fJRoJ9TWu ZnhB+HHkDaSpX2Than2XtN1ci69vmWhXTrXct0ZAc068umN/2WVpO6HIF3ceyrd1aSUdQO 2A1QlEEinDpTTYznz5gjhmL39Dc4+Go= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-101-m3mpvH4tP766lOTaukKGAw-1; Wed, 06 Mar 2024 08:42:44 -0500 X-MC-Unique: m3mpvH4tP766lOTaukKGAw-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-55d71ec6ef3so6408804a12.0 for ; Wed, 06 Mar 2024 05:42:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709732562; x=1710337362; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oPIOHmQNCuk7RfRsGjw4wRZkAcaIOHv3BH5X09QQmGE=; b=OdKhjj+RRNsAfpB0jmPZXuoqfmj71ZEMmRh1DTG3F1FezkrwGPqB5bd6eZgBT/f21z oeElWzGjdnr0k+4XYblvXpXHyaZQEIWL2Zm5lRT2qJpUiADyiLWRhi5qlpxdytPOO3sG zbnHwxtyfra2UO/iiY65Ba1S0e0Pnd0WiMHkN+pU+Pquj6nAgI4m9SAOFmbzEwFlQdvP GAT+ZtavrfcYOblbsgYBGMsDv74iwWr49zib6+Pi85hIYAF2YXx8wIbBpIR7OuyC2O5L 8L/IX4lH04tKlVzpqc13Q9zUfQhreO5esusac+1tQ0ZvngrLThfcMcoXuGyyHf0h7Cb8 Q8KQ== X-Forwarded-Encrypted: i=1; AJvYcCWAcU2cB3Tj2djH48DPJeNKTVwGf131/5iRy6/cNGNoONjZzRvyED0Z/1w4Y4GCypSiUKz0l8Gi/8Oi7ZN1q6vLTfGiwpZfmwRcFQ== X-Gm-Message-State: AOJu0YxKrEMRXOr+c5hoPrG5Zo+56fBCrO18bGUG8RxL/84MYXKZLNI+ +SzId/IU++KjQfVIA4W6YK3BDUOgXUK8Q8bkxYyuMC0n2MgNOFou4z0Yy9gpBy6XwuAjZMVYh7J fQFyZb1tBdPqqsbIgOS++/QkLyuAGvfLosa3aR1vAfP9QpRS1pgzMypD0cgoGdOg9zvI= X-Received: by 2002:a50:cc8e:0:b0:566:1794:7b2 with SMTP id q14-20020a50cc8e000000b00566179407b2mr12438117edi.13.1709732562176; Wed, 06 Mar 2024 05:42:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeU8uBFye+ARmaE6bQ+fbKGh4cUck52c59y6wb9lsQIL+GnDFsxZR6yxxFDqIybdI/DTtX8Q== X-Received: by 2002:a50:cc8e:0:b0:566:1794:7b2 with SMTP id q14-20020a50cc8e000000b00566179407b2mr12438096edi.13.1709732561532; Wed, 06 Mar 2024 05:42:41 -0800 (PST) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id cy24-20020a0564021c9800b00566850548fcsm6946772edb.20.2024.03.06.05.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 05:42:41 -0800 (PST) From: Andrew Burgess To: Tom Tromey , gdb-patches@sourceware.org Cc: Tom Tromey Subject: Re: [PATCH v2] Remove tui-out.[ch] In-Reply-To: <20240305213839.3093613-1-tom@tromey.com> References: <20240305213839.3093613-1-tom@tromey.com> Date: Wed, 06 Mar 2024 13:42:40 +0000 Message-ID: <87ttlja33j.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tom Tromey writes: > The other day on irc, we were discussing the "m_line" hack in > tui-out.c, and I mentioned that it would be nice to replace this with > a new ui_out_flag. > > Later, I looked at ui_out_flag and found: > > ui_source_list = (1 << 0), > > ... and sure enough, this is tested already. > > This patch removes tui-out.[ch] and changes the TUI to use an ordinary > cli-out object without this flag set. > > As far as I can tell, this doesn't affect behavior at all -- the TUI > tests all pass, and interactively I tried switching stack frames, > "list", etc, and it all seems to work. > > New in v2: fixed the problem pointed out by Keith, and added a test > case for that scenario. This LGTM. Keith might also want to look at this so I'll just add: Reviewed-By: Andrew Burgess Thanks, Andrew > --- > gdb/Makefile.in | 2 - > gdb/source.c | 27 ++---- > gdb/testsuite/gdb.tui/tui-missing-src.exp | 2 + > gdb/tui/tui-io.c | 3 +- > gdb/tui/tui-out.c | 111 ---------------------- > gdb/tui/tui-out.h | 64 ------------- > 6 files changed, 12 insertions(+), 197 deletions(-) > delete mode 100644 gdb/tui/tui-out.c > delete mode 100644 gdb/tui/tui-out.h > > diff --git a/gdb/Makefile.in b/gdb/Makefile.in > index 0e0f19c40c9..340ff266a6e 100644 > --- a/gdb/Makefile.in > +++ b/gdb/Makefile.in > @@ -318,7 +318,6 @@ SUBDIR_TUI_SRCS = \ > tui/tui-io.c \ > tui/tui-layout.c \ > tui/tui-location.c \ > - tui/tui-out.c \ > tui/tui-regs.c \ > tui/tui-source.c \ > tui/tui-status.c \ > @@ -1605,7 +1604,6 @@ HFILES_NO_SRCDIR = \ > tui/tui-io.h \ > tui/tui-layout.h \ > tui/tui-location.h \ > - tui/tui-out.h \ > tui/tui-regs.h \ > tui/tui-source.h \ > tui/tui-status.h \ > diff --git a/gdb/source.c b/gdb/source.c > index 2c465a1251f..bbeb4154258 100644 > --- a/gdb/source.c > +++ b/gdb/source.c > @@ -1341,30 +1341,21 @@ print_source_lines_base (struct symtab *s, int line, int stopline, > styled_string (file_name_style.style (), filename), > safe_strerror (errcode)); > } > - else > + else if (uiout->is_mi_like_p () || uiout->test_flags (ui_source_list)) > { > + /* CLI expects only the "file" field. MI expects both > + fields. ui_source_list is set only for CLI, not for > + TUI. */ > + > uiout->field_signed ("line", line); > uiout->text ("\tin "); > > - /* CLI expects only the "file" field. TUI expects only the > - "fullname" field (and TUI does break if "file" is printed). > - MI expects both fields. ui_source_list is set only for CLI, > - not for TUI. */ > - if (uiout->is_mi_like_p () || uiout->test_flags (ui_source_list)) > - uiout->field_string ("file", symtab_to_filename_for_display (s), > - file_name_style.style ()); > - if (uiout->is_mi_like_p () || !uiout->test_flags (ui_source_list)) > + uiout->field_string ("file", symtab_to_filename_for_display (s), > + file_name_style.style ()); > + if (uiout->is_mi_like_p ()) > { > const char *s_fullname = symtab_to_fullname (s); > - char *local_fullname; > - > - /* ui_out_field_string may free S_FULLNAME by calling > - open_source_file for it again. See e.g., > - tui_field_string->tui_show_source. */ > - local_fullname = (char *) alloca (strlen (s_fullname) + 1); > - strcpy (local_fullname, s_fullname); > - > - uiout->field_string ("fullname", local_fullname); > + uiout->field_string ("fullname", s_fullname); > } > > uiout->text ("\n"); > diff --git a/gdb/testsuite/gdb.tui/tui-missing-src.exp b/gdb/testsuite/gdb.tui/tui-missing-src.exp > index 19da9389a46..1929a1e3568 100644 > --- a/gdb/testsuite/gdb.tui/tui-missing-src.exp > +++ b/gdb/testsuite/gdb.tui/tui-missing-src.exp > @@ -89,6 +89,8 @@ Term::check_box_contents "check source box is empty" \ > Term::command "set pagination off" > Term::command "start" > Term::command "next" > +Term::check_contents "next does not show source line" \ > + "\\(gdb\\) next *\n\\(gdb\\)" > Term::command "step" > Term::check_contents "checking if inside f2 ()" "f2 \\(x=4\\)" > Term::check_box_contents "f2.c must be displayed in source window" \ > diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c > index 94554fd447d..ba07e3d573b 100644 > --- a/gdb/tui/tui-io.c > +++ b/gdb/tui/tui-io.c > @@ -33,7 +33,6 @@ > #include "tui/tui-win.h" > #include "tui/tui-wingeneral.h" > #include "tui/tui-file.h" > -#include "tui/tui-out.h" > #include "ui-out.h" > #include "cli-out.h" > #include > @@ -917,7 +916,7 @@ tui_initialize_io (void) > tui_stdout = new pager_file (new tui_file (stdout, true)); > tui_stderr = new tui_file (stderr, false); > tui_stdlog = new timestamped_file (tui_stderr); > - tui_out = new tui_ui_out (tui_stdout); > + tui_out = new cli_ui_out (tui_stdout, 0); > > /* Create the default UI. */ > tui_old_uiout = new cli_ui_out (gdb_stdout); > diff --git a/gdb/tui/tui-out.c b/gdb/tui/tui-out.c > deleted file mode 100644 > index 2ce7309b902..00000000000 > --- a/gdb/tui/tui-out.c > +++ /dev/null > @@ -1,111 +0,0 @@ > -/* Output generating routines for GDB CLI. > - > - Copyright (C) 1999-2024 Free Software Foundation, Inc. > - > - Contributed by Cygnus Solutions. > - Written by Fernando Nasser for Cygnus. > - > - This file is part of GDB. > - > - This program is free software; you can redistribute it and/or modify > - it under the terms of the GNU General Public License as published by > - the Free Software Foundation; either version 3 of the License, or > - (at your option) any later version. > - > - This program is distributed in the hope that it will be useful, > - but WITHOUT ANY WARRANTY; without even the implied warranty of > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > - GNU General Public License for more details. > - > - You should have received a copy of the GNU General Public License > - along with this program. If not, see . */ > - > -#include "defs.h" > -#include "ui-out.h" > -#include "tui-out.h" > -#include "tui.h" > - > -/* Output an int field. */ > - > -void > -tui_ui_out::do_field_signed (int fldno, int width, ui_align alignment, > - const char *fldname, LONGEST value) > -{ > - if (suppress_output ()) > - return; > - > - /* Don't print line number, keep it for later. */ > - if (m_start_of_line == 0 && strcmp (fldname, "line") == 0) > - { > - m_start_of_line++; > - m_line = value; > - return; > - } > - m_start_of_line++; > - > - cli_ui_out::do_field_signed (fldno, width, alignment, fldname, value); > -} > - > -/* Other cli_field_* end up here so alignment and field separators are > - both handled by tui_field_string. */ > - > -void > -tui_ui_out::do_field_string (int fldno, int width, ui_align align, > - const char *fldname, const char *string, > - const ui_file_style &style) > -{ > - if (suppress_output ()) > - return; > - > - m_start_of_line++; > - > - if (fldname && m_line > 0 && strcmp (fldname, "fullname") == 0) > - return; > - > - cli_ui_out::do_field_string (fldno, width, align, fldname, string, style); > -} > - > -void > -tui_ui_out::do_field_fmt (int fldno, int width, ui_align align, > - const char *fldname, const ui_file_style &style, > - const char *format, va_list args) > -{ > - if (suppress_output ()) > - return; > - > - m_start_of_line++; > - > - cli_ui_out::do_field_fmt (fldno, width, align, fldname, style, format, args); > -} > - > -void > -tui_ui_out::do_text (const char *string) > -{ > - if (suppress_output ()) > - return; > - > - m_start_of_line++; > - if (m_line > 0) > - { > - /* Printing a source line, so suppress regular output -- the > - line was shown on the TUI's source window by tui_show_source > - above instead. */ > - if (strchr (string, '\n') != 0) > - { > - /* We've reached the end of the line, so go back to letting > - text output go to the console. */ > - m_line = 0; > - m_start_of_line = 0; > - } > - return; > - } > - if (strchr (string, '\n')) > - m_start_of_line = 0; > - > - cli_ui_out::do_text (string); > -} > - > -tui_ui_out::tui_ui_out (ui_file *stream) > - : cli_ui_out (stream, 0) > -{ > -} > diff --git a/gdb/tui/tui-out.h b/gdb/tui/tui-out.h > deleted file mode 100644 > index e4ebb1e7408..00000000000 > --- a/gdb/tui/tui-out.h > +++ /dev/null > @@ -1,64 +0,0 @@ > -/* Copyright (C) 2016-2024 Free Software Foundation, Inc. > - > - This file is part of GDB. > - > - This program is free software; you can redistribute it and/or modify > - it under the terms of the GNU General Public License as published by > - the Free Software Foundation; either version 3 of the License, or > - (at your option) any later version. > - > - This program is distributed in the hope that it will be useful, > - but WITHOUT ANY WARRANTY; without even the implied warranty of > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > - GNU General Public License for more details. > - > - You should have received a copy of the GNU General Public License > - along with this program. If not, see . */ > - > -#ifndef TUI_TUI_OUT_H > -#define TUI_TUI_OUT_H > - > -#include "cli-out.h" > - > -/* A ui_out class for the TUI. This is just like the CLI's ui_out, > - except that it overrides output methods to detect when a source > - line is being printed and show the source in the TUI's source > - window instead of printing the line in the console window. */ > -class tui_ui_out : public cli_ui_out > -{ > -public: > - > - explicit tui_ui_out (ui_file *stream); > - > -protected: > - > - void do_field_signed (int fldno, int width, ui_align align, const char *fldname, > - LONGEST value) override; > - void do_field_string (int fldno, int width, ui_align align, const char *fldname, > - const char *string, const ui_file_style &style) override; > - void do_field_fmt (int fldno, int width, ui_align align, const char *fldname, > - const ui_file_style &style, > - const char *format, va_list args) override > - ATTRIBUTE_PRINTF (7, 0); > - void do_text (const char *string) override; > - > -private: > - > - /* These fields are used to make print_source_lines show the source > - in the TUI's source window instead of in the console. > - M_START_OF_LINE is incremented whenever something is output to > - the ui_out. If an integer field named "line" is printed on the > - ui_out, and nothing else has been printed yet (both > - M_START_OF_LINE and M_LINE are still 0), we assume > - print_source_lines is starting to print a source line, and thus > - record the line number in M_LINE. Afterwards, when we see a > - string field named "fullname" being output, we take the fullname > - and the recorded line and show the source line in the TUI's > - source window. tui_ui_out::do_text() suppresses text output > - until it sees an endline being printed, at which point these > - variables are reset back to 0. */ > - int m_line = 0; > - int m_start_of_line = 0; > -}; > - > -#endif /* TUI_TUI_OUT_H */ > -- > 2.43.0