From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id APD1D4UBmmcrLh4AWB0awg (envelope-from ) for ; Wed, 29 Jan 2025 05:23:01 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=EqAgT/UW; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=hFTHUJ3x; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=EqAgT/UW; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=hFTHUJ3x; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3BEFF1E105; Wed, 29 Jan 2025 05:23:01 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id CE8791E08E for ; Wed, 29 Jan 2025 05:22:59 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 790E73857BA3 for ; Wed, 29 Jan 2025 10:22:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 790E73857BA3 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=EqAgT/UW; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=hFTHUJ3x; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=EqAgT/UW; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=hFTHUJ3x Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id B36023858D20 for ; Wed, 29 Jan 2025 10:20:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B36023858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B36023858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738146030; cv=none; b=KE8Fkjx4pAozJlxXJD4/+zD8T0q0cONc0UFhR+opLhhBxuhWgoztDbJaFfhrJ5zvGCSJc9ZS42v73dweMq4VSTi8d3D4uyw94ZExhCnS+1LZkSW6h/dVLgOzckVi2oqEA4Hn4pztBDZbCGx81+4asd2eiPuvfOQ/Vw/xyeb6a5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738146030; c=relaxed/simple; bh=3tJT49fUiQ9BRe9nYog6TUKeeANDNmXDr108CUdGr2w=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=eqTSqUPYb0ODNrzc11a4xDdIf0B2RijQKzCDejZUtdLvlPFS3x+6Jy7ezbxXwHfxHWrPLFpx5lNymOISGvmybyxmpJckH2ixeLt1fa6eHq2iYLeNhu6In+t7NKpw1sQfI8cfvnfOo1LhIdu2LtB/TzsMX/0nWf/KTBC8qm1eYsw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B36023858D20 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 980DC21102 for ; Wed, 29 Jan 2025 10:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738146024; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PemV3N2fIux1WZFUkfSjxhjtggO87o9RY3EsurLBopY=; b=EqAgT/UWwVIxQ36KhrTnTfYzDJR43FvkVpq4kaaqV0so4rCwJ3ik8pj+OJXRMBATPyH4Cm LgogF7dlgNJbQix1n28nP8t2XXvF2Hz9ypnKEolv6xzEsf+IPGieRquCFN2rwo0Q/Ui/a8 FHgKswvSibSGXwF6mOCsfZ0A3syeQD4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738146024; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PemV3N2fIux1WZFUkfSjxhjtggO87o9RY3EsurLBopY=; b=hFTHUJ3xjbrhhSlw6mX7lZshxpwJgqN9m+WWhtdf0nEEneXLTf4AGkslzEBMVzqvcvqU6q q/IjiVw0+Vj+FMCA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="EqAgT/UW"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=hFTHUJ3x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738146024; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PemV3N2fIux1WZFUkfSjxhjtggO87o9RY3EsurLBopY=; b=EqAgT/UWwVIxQ36KhrTnTfYzDJR43FvkVpq4kaaqV0so4rCwJ3ik8pj+OJXRMBATPyH4Cm LgogF7dlgNJbQix1n28nP8t2XXvF2Hz9ypnKEolv6xzEsf+IPGieRquCFN2rwo0Q/Ui/a8 FHgKswvSibSGXwF6mOCsfZ0A3syeQD4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738146024; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PemV3N2fIux1WZFUkfSjxhjtggO87o9RY3EsurLBopY=; b=hFTHUJ3xjbrhhSlw6mX7lZshxpwJgqN9m+WWhtdf0nEEneXLTf4AGkslzEBMVzqvcvqU6q q/IjiVw0+Vj+FMCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 82217137D2 for ; Wed, 29 Jan 2025 10:20:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id zRJoHugAmmc/JgAAD6G6ig (envelope-from ) for ; Wed, 29 Jan 2025 10:20:24 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/tui] Don't show incorrect source file in source window Date: Wed, 29 Jan 2025 11:21:02 +0100 Message-ID: <20250129102102.28617-1-tdevries@suse.de> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 980DC21102 X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,gnu.org:url]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Consider the test-case sources main.c and foo.c: ... $ cat main.c extern int foo (void); int main (void) { return foo (); } $ cat foo.c extern int foo (void); int foo (void) { return 0; } ... and main.c compiled with debug info, and foo.c without: ... $ gcc -g main.c -c $ gcc foo.c -c $ gcc -g main.o foo.o ... In TUI mode, if we run to foo: ... $ gdb -q a.out -tui -ex "b foo" -ex run ... it gets us "[ No Source Available ]": ... ┌─main.c─────────────────────────────────────────┐ │ │ │ │ │ │ │ [ No Source Available ] │ │ │ │ │ └────────────────────────────────────────────────┘ (src) In: foo L?? PC: 0x400566 db.so.1". Breakpoint 1, 0x0000000000400566 in foo () (gdb) ... But after resizing (pressing ctrl- in the gnome-terminal), we get instead the source for main.c: ... ┌─main.c───────────────────────────────────────────────────┐ │ 3 int │ │ 4 main (void) │ │ 5 { │ │ 6 return foo (); │ │ 7 } │ │ │ │ │ └──────────────────────────────────────────────────────────┘ (src) In: foo L?? PC: 0x400566 db.so.1". Breakpoint 1, 0x0000000000400566 in foo () (gdb) ... which is inappropriate because we're stopped in function foo, which is not in main.c. Fix this in tui_source_window_base::rerender. Tested on x86_64-linux. Reported-By: Andrew Burgess PR tui/32614 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32614 --- gdb/testsuite/gdb.tui/resize-3-foo.c | 24 ++++++++++ gdb/testsuite/gdb.tui/resize-3-main.c | 24 ++++++++++ gdb/testsuite/gdb.tui/resize-3.exp | 63 +++++++++++++++++++++++++++ gdb/tui/tui-winsource.c | 6 +++ 4 files changed, 117 insertions(+) create mode 100644 gdb/testsuite/gdb.tui/resize-3-foo.c create mode 100644 gdb/testsuite/gdb.tui/resize-3-main.c create mode 100644 gdb/testsuite/gdb.tui/resize-3.exp diff --git a/gdb/testsuite/gdb.tui/resize-3-foo.c b/gdb/testsuite/gdb.tui/resize-3-foo.c new file mode 100644 index 00000000000..653b24ba92b --- /dev/null +++ b/gdb/testsuite/gdb.tui/resize-3-foo.c @@ -0,0 +1,24 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2025 Free Software Foundation, Inc. + + 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 . */ + +extern int foo (void); + +int +foo (void) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.tui/resize-3-main.c b/gdb/testsuite/gdb.tui/resize-3-main.c new file mode 100644 index 00000000000..95fdd3b6ba0 --- /dev/null +++ b/gdb/testsuite/gdb.tui/resize-3-main.c @@ -0,0 +1,24 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2025 Free Software Foundation, Inc. + + 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 . */ + +extern int foo (void); + +int +main (void) +{ + return foo (); +} diff --git a/gdb/testsuite/gdb.tui/resize-3.exp b/gdb/testsuite/gdb.tui/resize-3.exp new file mode 100644 index 00000000000..ec022b4a177 --- /dev/null +++ b/gdb/testsuite/gdb.tui/resize-3.exp @@ -0,0 +1,63 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# 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 . + +# Test TUI resizing while showing "No Source Available". + +require allow_tui_tests + +standard_testfile -main.c -foo.c + +if { [build_executable_from_specs "failed to prepare" \ + $testfile {debug} \ + $srcfile {debug} \ + $srcfile2 {nodebug}] == -1 } { + return -1 +} + +tuiterm_env + +Term::clean_restart 24 80 $testfile + +# It would be simpler to run directly to foo and then enter TUI, but that +# fails to trigger PR32614. So instead, we first run to main, enter TUI and +# then run to foo. +if {![runto_main]} { + perror "test suppressed" + return +} + +# Set a breakpoint on foo, easier to do before entering TUI. +gdb_breakpoint foo + +if {![Term::enter_tui]} { + unsupported "TUI not supported" + return +} + +# Continue to foo. +Term::command continue + +with_test_prefix "before resize" { + Term::check_contents "Source window empty" \ + "No Source Available" +} + +Term::resize 40 90 + +with_test_prefix "after resize" { + # Regression test for PR32614. + Term::check_contents "Source window empty" \ + "No Source Available" +} diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index a5d0c594545..bf4052755df 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -460,6 +460,12 @@ tui_source_window_base::rerender () struct gdbarch *gdbarch = get_frame_arch (frame); struct symtab *s = find_pc_line_symtab (get_frame_pc (frame)); + if (s == nullptr) + { + erase_source_content (); + return; + } + if (this != tui_src_win ()) find_line_pc (s, cursal.line, &cursal.pc); base-commit: d1b55b91df48f26a8541646bb88231ad5b9a0832 -- 2.43.0