From patchwork Mon Dec 2 16:47:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 36437 Received: (qmail 31677 invoked by alias); 2 Dec 2019 16:47:34 -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 31662 invoked by uid 89); 2 Dec 2019 16:47:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=played, HX-MS-Has-Attach:yes, superfluous, 0200 X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-oln040092066071.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (40.92.66.71) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Dec 2019 16:47:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MqSnWcXRp0WO7cZW6wJ3O0hXA3bCdecEyTkE/8qf99b0Py5FxqAW9LMwCrjGiEWHGoCIGdeCmDymXtwFdbRByaoczEEmDliD4PKZEI4ActVB3t6u0yhqH4NTe8xKaWbe7J3Q4rrJtCcJO2q7be+racL2jySroWj4XkmjSSuYNtRn1RMHqI+sPEA/IChMsHVBbRkStaXvbd7vkiG43gvLe7eMlhROMXjfVvyn+hVsMSLMROGXM5MIB2RvZYMxazbn/zm++uDQMklmR+03EjfYKAgxRnOafYfFzsx69ivjgTa/kiglDdeOmSOXevnr7An69M9lTnFBPq/HPlh13pHYjg== 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=15d9/OKDGM/q2N95zJL792PY/T03AcV3v0Mf1wEbiGg=; b=LaJe70V5/k4ZYnxCPor2P1WIgpxlPDNEeydc3iR+jDKFL9GM/lH98XbvXApr/mZidpVVzI7J+McYsh18MBKRSN6szW3nhhjGf3RaIYePiOcjXMGniEfVYJOB55tzOu8shY8FmSrK+s+MLz87AV8Lm+dmKuCe+XK5VdBpip4VADlch5lGCKIYRAEWOUOXSCFRtx7Jta0CdEW0uNrNj/Df0EUX0dqEy9kOkpRl1Vab2UOIZKEhAPQBlt2IThsI1B8QVMNZIQx29i2gk7wcG6DonVHlzFbb14ZODOa/tUMggJMhCZY0MTwkRwzUySHrfDCHPCaDUsLwsbWVch0cNj7ebw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from HE1EUR01FT004.eop-EUR01.prod.protection.outlook.com (10.152.0.58) by HE1EUR01HT173.eop-EUR01.prod.protection.outlook.com (10.152.1.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2495.18; Mon, 2 Dec 2019 16:47:26 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (10.152.0.54) by HE1EUR01FT004.mail.protection.outlook.com (10.152.1.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2495.18 via Frontend Transport; Mon, 2 Dec 2019 16:47:26 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::5861:779d:3997:2e70]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::5861:779d:3997:2e70%7]) with mapi id 15.20.2495.014; Mon, 2 Dec 2019 16:47:26 +0000 From: Bernd Edlinger To: Simon Marchi , Pedro Alves , "gdb-patches@sourceware.org" Subject: [PATCHv5] Make "skip" work on inline frames Date: Mon, 2 Dec 2019 16:47:26 +0000 Message-ID: References: <8fc93db4-8906-4f4e-53f4-225ebfa0115d@simark.ca> <215bbf9c-4c3c-5cd2-c657-51aa7262f234@simark.ca> <8d5b880e-12f2-11ac-1bfe-82941f64369b@simark.ca> In-Reply-To: <8d5b880e-12f2-11ac-1bfe-82941f64369b@simark.ca> x-microsoft-original-message-id: <70971d76-5139-2150-401b-6bf2e1cfc6cb@hotmail.de> x-ms-exchange-transport-forked: True MIME-Version: 1.0 On 12/2/19 3:34 AM, Simon Marchi wrote: > On 2019-11-24 6:22 a.m., Bernd Edlinger wrote: >> This is just a minor update on the patch >> since the function SYMBOL_PRINT_NAME was removed with >> commit 987012b89bce7f6385ed88585547f852a8005a3f >> I replaced it with sym->print_name (), otherwise the >> patch is unchanged. > > Hi Bernd, > > Sorry, I had lost this in the mailing list noise. > > I played a bit with the patch and different cases of figure. I am not able to understand > the purpose of each of your changes (due to the complexity of that particular code), but > I didn't find anything that stood out as wrong to me. Pedro might be able to do a more > in-depth review of the event handling code. > > If the test tests specifically skipping of inline functions, I'd name it something more > descriptive than "skip2.exp", maybe "skip-inline.exp"? > > Unfortunately, your test doesn't pass on my computer (gcc 9.2.0), but neither does the > gdb.base/skip.exp. I am attaching the gdb.log when running your test, if it can help. > > Simon > Hi Simon, I only tested that with gcc-4.8, and both test cases worked with that gcc version. I tried now with gcc-trunk version from a few days ago, and I think I see what you mean. skip2.c (now skip-inline.c) can be fixed by removing the assignment to x in the first line, which is superfluous (and copied from skip.c). But skip.c cannot be fixed this way. I only see a chance to allow the stepping back to main and then to foo happen. Does this modified test case work for you? Thanks Bernd. From 32627e64b9b7b437c5f6d46d1138ecba09816273 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Wed, 30 Oct 2019 21:35:22 +0100 Subject: [PATCH 2/2] Add a test case for skip with inlined functions Fixed an issue in skip.exp that made it fail with recent gcc versions, while already at it. --- gdb/testsuite/gdb.base/skip-inline.c | 64 +++++++++++++++++++++++++++ gdb/testsuite/gdb.base/skip-inline.exp | 80 ++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/skip.exp | 12 +++-- 3 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 gdb/testsuite/gdb.base/skip-inline.c create mode 100644 gdb/testsuite/gdb.base/skip-inline.exp diff --git a/gdb/testsuite/gdb.base/skip-inline.c b/gdb/testsuite/gdb.base/skip-inline.c new file mode 100644 index 0000000..e562149 --- /dev/null +++ b/gdb/testsuite/gdb.base/skip-inline.c @@ -0,0 +1,64 @@ +/* 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 + +int bar (void); +int baz (int); +void skip1_test_skip_file_and_function (void); +void test_skip_file_and_function (void); + +__attribute__((__always_inline__)) static inline int +foo (void) +{ + return bar (); +} + +int +main () +{ + volatile int x; + + /* step immediately into the inlined code */ + baz (foo ()); + + /* step first over non-inline code, this involves a different code path */ + x = 0; x = baz (foo ()); + + test_skip_file_and_function (); + + return 0; +} + +static void +test_skip (void) +{ +} + +static void +end_test_skip_file_and_function (void) +{ + abort (); +} + +void +test_skip_file_and_function (void) +{ + test_skip (); + skip1_test_skip_file_and_function (); + end_test_skip_file_and_function (); +} diff --git a/gdb/testsuite/gdb.base/skip-inline.exp b/gdb/testsuite/gdb.base/skip-inline.exp new file mode 100644 index 0000000..9d490bd --- /dev/null +++ b/gdb/testsuite/gdb.base/skip-inline.exp @@ -0,0 +1,80 @@ +# 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 completion-support.exp + +standard_testfile + +if { [prepare_for_testing "failed to prepare" "skip-inline" \ + {skip-inline.c skip1.c } \ + {debug nowarnings}] } { + return -1 +} + +set srcfile skip-inline.c +set srcfile1 skip1.c + +if ![runto_main] { + fail "can't run to main" + return +} + +# Create a skiplist entry for a specified file and function. + +gdb_test "skip function foo" "Function foo will be skipped when stepping\." + +gdb_test "bt" "\\s*\\#0\\s+main.*" "in the main" +gdb_test "step" ".*" "step into baz, since foo will be skipped" +gdb_test "bt" "\\s*\\#0\\s+baz.*" "in the baz, since foo was skipped" +gdb_test "step" ".*" "step in the baz" +gdb_test "bt" "\\s*\\#0\\s+baz.*" "still in the baz" +gdb_test "step" ".*" "step back to main" +gdb_test "bt" "\\s*\\#0\\s+main.*" "again in the main" +gdb_test "step" ".*" "step again into baz, since foo will be skipped" +gdb_test "bt" "\\s*\\#0\\s+baz.*" "again in the baz" +gdb_test "step" ".*" "step in the baz, again" +gdb_test "bt" "\\s*\\#0\\s+baz.*" "still in the baz, again" +gdb_test "step" ".*" "step back to main, again" +gdb_test "bt" "\\s*\\#0\\s+main.*" "again back to main" + +if ![runto_main] { + fail "can't run to main" + return +} + +with_test_prefix "double step" { + gdb_test "bt" "\\s*\\#0\\s+main.*" "in the main" + gdb_test "step 2" ".*" "step into baz, since foo will be skipped" + gdb_test "bt" "\\s*\\#0\\s+baz.*" "still in the baz" + gdb_test "step" ".*" "step back to main" + gdb_test "bt" "\\s*\\#0\\s+main.*" "again in the main" + gdb_test "step 2" ".*" "step again into baz, since foo will be skipped" + gdb_test "bt" "\\s*\\#0\\s+baz.*" "again in the baz" + gdb_test "step" ".*" "step back to main, again" + gdb_test "bt" "\\s*\\#0\\s+main.*" "again back to main" +} + +if ![runto_main] { + fail "can't run to main" + return +} + +with_test_prefix "triple step" { + gdb_test "bt" "\\s*\\#0\\s+main.*" "in the main" + gdb_test "step 3" ".*" "step over baz" + gdb_test "bt" "\\s*\\#0\\s+main.*" "again in the main" + gdb_test "step 3" ".*" "step over baz, again" + gdb_test "bt" "\\s*\\#0\\s+main.*" "again back to main" +} diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp index d763194..0fd44e0 100644 --- a/gdb/testsuite/gdb.base/skip.exp +++ b/gdb/testsuite/gdb.base/skip.exp @@ -142,7 +142,9 @@ with_test_prefix "step after disabling 3" { gdb_test "step" "bar \\(\\) at.*" "step 1" gdb_test "step" ".*" "step 2"; # Return from foo() - gdb_test "step" "foo \\(\\) at.*" "step 3" + # with recent gcc we jump once back to main before entering foo here + # if that happens try to step a second time + gdb_test "step" "foo \\(\\) at.*" "step 3" "main \\(\\) at .*" "step" gdb_test "step" ".*" "step 4"; # Return from bar() gdb_test "step" "main \\(\\) at.*" "step 5" } @@ -261,7 +263,9 @@ with_test_prefix "step using -fu for baz" { gdb_test_no_output "skip enable 7" gdb_test "step" "bar \\(\\) at.*" "step 1" gdb_test "step" ".*" "step 2"; # Return from bar() - gdb_test "step" "foo \\(\\) at.*" "step 3" + # with recent gcc we jump once back to main before entering foo here + # if that happens try to step a second time + gdb_test "step" "foo \\(\\) at.*" "step 3" "main \\(\\) at.*" "step" gdb_test "step" ".*" "step 4"; # Return from foo() gdb_test "step" "main \\(\\) at.*" "step 5" } @@ -276,7 +280,9 @@ with_test_prefix "step using -rfu for baz" { gdb_test_no_output "skip enable 8" gdb_test "step" "bar \\(\\) at.*" "step 1" gdb_test "step" ".*" "step 2"; # Return from bar() - gdb_test "step" "foo \\(\\) at.*" "step 3" + # with recent gcc we jump once back to main before entering foo here + # if that happens try to step a second time + gdb_test "step" "foo \\(\\) at.*" "step 3" "main \\(\\) at.*" "step" gdb_test "step" ".*" "step 4"; # Return from foo() gdb_test "step" "main \\(\\) at.*" "step 5" } -- 1.9.1