From patchwork Fri Dec 20 21:06:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 37045 Received: (qmail 2993 invoked by alias); 20 Dec 2019 21:06:16 -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 2984 invoked by uid 89); 20 Dec 2019 21:06:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=consisting, 1157, H*r:sk:VE1EUR0 X-HELO: EUR02-AM5-obe.outbound.protection.outlook.com Received: from mail-oln040092067017.outbound.protection.outlook.com (HELO EUR02-AM5-obe.outbound.protection.outlook.com) (40.92.67.17) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Dec 2019 21:06:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TLseoYL5Oby9bidXPnS7KDwSXGXBGTk4ZXMaDzvdo94YF4P/eqsVPsUXSLqpUISJU/k77MV34gDGNM+DDrrbdwylvcm6DEJsmR0Rl+GUVSxSaz+Ope9XL02t+HRooC3opzGF+a1WsWEmupBKAC5VC6OHgTm8uXpnjM0ug+UpE7XU94grYKBJV68w4bhZDLXaOYEmtINODSVMCJ5jSUSkqYdaxdNyfLce/TKrzznGoN9JvEsh5Ck8+B7ATuhtAgv8mHgGRXzB2rmoQZBCiNT3nHzztPNrNnMqRj+4je9Sy8+86b7n9QyeUFDdi0qnmsD848Om6QC/m7DWAJNU+1vw5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SfZXAzjlbRWJXYdpzzJrOYxchbhL4/4ILsPXgJzh5rY=; b=UgldBg5BOyKYEOGbpRjfP4pL7rIFjhRXnSmmTYepv3ZXcLxTrn92FUO6YvLJUCOkIEShsPtuKzgQ8azBhxhMbyHXCi9SuoOUM73l7rJAkH+ZbSXSKr2KqrfSTw4LkicQRZMYwZ77fDjZdBbYHP4pTXr4W1FfRDEq10x3d6dtddtsIcjabOwFcslIMv+fBW3OJvw2NxqktpCVTHaKkCb6fYLOx2J/IFnlcSse2WerMwD8CVq+UN7faDg1GYc462ROJsznuPVjITy3m7ORCBeyLm+7q7nA3UNDVjC/s1BLGgrRB8zttE6BUFOs9xF+FTDffL70fKkQxVxhG3zACV5zJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR02FT022.eop-EUR02.prod.protection.outlook.com (10.152.12.56) by VE1EUR02HT031.eop-EUR02.prod.protection.outlook.com (10.152.13.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.14; Fri, 20 Dec 2019 21:06:10 +0000 Received: from AM0PR08MB3714.eurprd08.prod.outlook.com (10.152.12.52) by VE1EUR02FT022.mail.protection.outlook.com (10.152.12.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.14 via Frontend Transport; Fri, 20 Dec 2019 21:06:10 +0000 Received: from AM0PR08MB3714.eurprd08.prod.outlook.com ([fe80::8dd1:fb18:6271:f769]) by AM0PR08MB3714.eurprd08.prod.outlook.com ([fe80::8dd1:fb18:6271:f769%7]) with mapi id 15.20.2559.015; Fri, 20 Dec 2019 21:06:10 +0000 From: Bernd Edlinger To: "gdb-patches@sourceware.org" , Simon Marchi Subject: [PATCH] Fix display of source code in TUI window Date: Fri, 20 Dec 2019 21:06:10 +0000 Message-ID: x-microsoft-original-message-id: <86c47a79-17e8-8f47-1c4e-bb7fbe8247be@hotmail.de> x-ms-exchange-transport-forked: True MIME-Version: 1.0 Hi, this fixes a bug in the TUI display which was pointed out by Simon. The problem is the source code window is showing the wrong or no source at all, when the same PC has different possible source code locations as it typically happens when stepping into nested inline functions. I have an idea for a test case but do not know yet how to make a working test case out of it. Attached also a test case consisting of step.c / step.h. When stepping into foo the TUI is unable to display foo, since it tries to open the wrong source file. gdb: 2019-12-20 Bernd Edlinger * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Use the correct symtab to display the source window. gdb/testsuite: 2019-12-20 Bernd Edlinger * gdb.tui/step.exp: New file. * gdb.tui/step.c: New file. * gdb.tui/step.h: New file. All existing TUI tests are unaffected by this patch, while the new test case is fixed. Thanks Bernd. From b777fc642a75115c562483b33d2eeb4b10282483 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Fri, 20 Dec 2019 21:58:47 +0100 Subject: [PATCH 2/2] Add a TUI test case for step into inline frames --- gdb/testsuite/gdb.tui/step.c | 36 ++++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.tui/step.exp | 39 +++++++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.tui/step.h | 22 ++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 gdb/testsuite/gdb.tui/step.c create mode 100644 gdb/testsuite/gdb.tui/step.exp create mode 100644 gdb/testsuite/gdb.tui/step.h diff --git a/gdb/testsuite/gdb.tui/step.c b/gdb/testsuite/gdb.tui/step.c new file mode 100644 index 0000000..cb9dc1a --- /dev/null +++ b/gdb/testsuite/gdb.tui/step.c @@ -0,0 +1,36 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2019 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 . */ + +#include + +__attribute__((noinline, noclone)) static void +bar () +{ +} + +#include "step.h" + +int +main () +{ + int x; + + x = 0; + foo (); + abort (); + return x; +} diff --git a/gdb/testsuite/gdb.tui/step.exp b/gdb/testsuite/gdb.tui/step.exp new file mode 100644 index 0000000..1d9dd9e --- /dev/null +++ b/gdb/testsuite/gdb.tui/step.exp @@ -0,0 +1,39 @@ +# Copyright 2019 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 . + +load_lib "tuiterm.exp" + +standard_testfile step.c + +if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { + return -1 +} + +Term::clean_restart 24 80 $testfile +if {![Term::enter_tui]} { + unsupported "TUI not supported" +} + +set text [Term::get_all_lines] +gdb_assert {![string match "No Source Available" $text]} \ + "initial source listing" + +Term::command "break main" +Term::command "run" +Term::check_contents "list main" "32 *x = 0;" +Term::command "step" +Term::check_contents "step main" "33 *foo \\(\\);" +Term::command "step" +Term::check_contents "step foo" "21 *bar \\(\\);" diff --git a/gdb/testsuite/gdb.tui/step.h b/gdb/testsuite/gdb.tui/step.h new file mode 100644 index 0000000..6945bee --- /dev/null +++ b/gdb/testsuite/gdb.tui/step.h @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2019 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 . */ + +__attribute__((__always_inline__)) static inline int +foo (void) +{ + bar (); +} -- 1.9.1