From patchwork Sun Nov 24 11:22:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 36160 Received: (qmail 3248 invoked by alias); 24 Nov 2019 11:22:19 -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 3238 invoked by uid 89); 24 Nov 2019 11:22:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.7 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=sk:SYMBOL_, gdbopt, UD:gdb.opt, gdb.opt X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com Received: from mail-oln040092064066.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (40.92.64.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 24 Nov 2019 11:22:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fQoavy4MxwIXEiRehWycLF+L1ZY1+vISzWc7KkIvGH3YlwE08YmeCM5B8qrZrWdXyqiyo4yWp2mQx3ojAbUc6vJl8v3fpcgok7UdkoHApqqW7m0Hh59TMW6ED6Xbs5J8O4MAgqhmVNEsEEFKw+HCsk3vBAEK2/FD/cpkZwKNojVe9ikkPnsY9VaNf8kQxH2tGWVvOwC+HfuMm8QA0uR+gSPhUi8t2wB71ZgEI/Wl3dwazrUcjdljY9FVoE5vuJw59YVXGt6VL60foEuzWOpnQAeb+qvjTCi/bu4gs/ce65GjBmYWrKPd/9scIZkqxciuMuv20ey358X7F1wV8KxWwQ== 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=vuSTqMeoTHrC5l3t7VlRmfR8nGWq62PTVyLyFgC0Uwg=; b=F8yCsvkxv5XdCP3quFuM63DWSyV7qdlD9pnEcD8pq0xZ2Ef2U6EXPRJ+GkS6vd8I01NHmGkvCKH7VuflEGJ6LbJmwxYLLJrUNYZPxQB3FvMo2WnetE1yd155M9b6xcvCtzPB811JuZGt/kNLqsmbyG6ia6hFmYLu2qVVVK4DkXoGEnwe2qeMtu+yjF1BbVE9KtLnOz3ngj4PusHQDeqi9+3hmHh78YAo3rLvvE8yUe8JVIYvfF8pGzOcf6G/juSQZkS4mphZSo+v/NE+CAEVB1owSkqvWIwEfaZDSkBINIvQ2H7TnOOVgUPWrCGEtyX5wI4/+uMCMHk4bpSsSR7oKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DB5EUR01FT015.eop-EUR01.prod.protection.outlook.com (10.152.4.53) by DB5EUR01HT092.eop-EUR01.prod.protection.outlook.com (10.152.5.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.17; Sun, 24 Nov 2019 11:22:13 +0000 Received: from VI1PR03MB4528.eurprd03.prod.outlook.com (10.152.4.55) by DB5EUR01FT015.mail.protection.outlook.com (10.152.5.0) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.17 via Frontend Transport; Sun, 24 Nov 2019 11:22:13 +0000 Received: from VI1PR03MB4528.eurprd03.prod.outlook.com ([fe80::49b8:a7e6:9f6f:862d]) by VI1PR03MB4528.eurprd03.prod.outlook.com ([fe80::49b8:a7e6:9f6f:862d%3]) with mapi id 15.20.2474.023; Sun, 24 Nov 2019 11:22:12 +0000 From: Bernd Edlinger To: Pedro Alves , Simon Marchi , "gdb-patches@sourceware.org" Subject: [PATCHv4] Make "skip" work on inline frames Date: Sun, 24 Nov 2019 11:22:12 +0000 Message-ID: References: <8fc93db4-8906-4f4e-53f4-225ebfa0115d@simark.ca> <215bbf9c-4c3c-5cd2-c657-51aa7262f234@simark.ca> In-Reply-To: x-microsoft-original-message-id: <5767c6e6-f1d7-6a13-e48f-52fc3029d771@hotmail.de> x-ms-exchange-purlcount: 2 x-ms-exchange-transport-forked: True MIME-Version: 1.0 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. On 10/31/19 8:19 PM, Bernd Edlinger wrote: > On 10/31/19 7:00 PM, Pedro Alves wrote: >> On 10/31/19 4:53 PM, Simon Marchi wrote: >>> On 2019-10-31 12:42 p.m., Pedro Alves wrote: >>>> On 10/30/19 9:56 PM, Bernd Edlinger wrote: >>>>> +if { [prepare_for_testing "failed to prepare" "skip2" \ >>>>> + {skip2.c skip1.c } \ >>>>> + {debug nowarnings optimize=-O2}] } { >>>> >>>> Instead of -O2, could you make this use -O0 (the default), >>>> and then use attribute((always_inline)) to force inlining? >>>> We do that in some tests. E.g., gdb.opt/inline-locals.c. >>> >>> I think that's a good suggestion, but just be aware that there used to be >>> some problems with always_inline, e.g.: >> >> I don't think always_inline changes anything in the debug info special, >> it just tells the compiler to inline the function even at -O0, which is >> what we're after. >> >>> >>> https://sourceware.org/bugzilla/show_bug.cgi?id=13263 >> >> This one seems to be about attribute((artificial)), and the desire >> to not step into such functions automatically: >> >> "Given that I marked the function always_inline and artificial, I >> was expecting not to step into its body." >> >>> https://sourceware.org/bugzilla/show_bug.cgi?id=12429 >>> >> >> This one seems like a generic inlining issue. >> >>> I'm not sure if those are still valid. If they are, it might be more difficult >>> that expected to use always_inline. >> I don't think always_inline is anything special compared to inlining >> because of -O2. >> >> Thanks, >> Pedro Alves >> > > Ah, thanks for that hint! > > always_inline works quite well. > > The debug session started (using gcc 4.8.4) with -O2 -g on the line with "{" in main, > and with -O0 -g at the first real statement, so I had to remove one step. > I did not worry about it initially, but now I agree that would have caused trouble. > > > I attached both parts of the patch, the fist part unchanged from previous. > The test case now makes sure to not repeat the names. > > > Thanks > Bernd. > From 4b8c278b30898ab37db3dcfb73d2b8d1f1773569 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 --- gdb/testsuite/gdb.base/skip2.c | 64 ++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/skip2.exp | 80 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 gdb/testsuite/gdb.base/skip2.c create mode 100644 gdb/testsuite/gdb.base/skip2.exp diff --git a/gdb/testsuite/gdb.base/skip2.c b/gdb/testsuite/gdb.base/skip2.c new file mode 100644 index 0000000..d1abd45 --- /dev/null +++ b/gdb/testsuite/gdb.base/skip2.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 */ + x = 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/skip2.exp b/gdb/testsuite/gdb.base/skip2.exp new file mode 100644 index 0000000..a59dd0f --- /dev/null +++ b/gdb/testsuite/gdb.base/skip2.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" "skip2" \ + {skip2.c skip1.c } \ + {debug nowarnings}] } { + return -1 +} + +set srcfile skip2.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" +} -- 1.9.1