From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9934 invoked by alias); 18 Jan 2019 19:44:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 9911 invoked by uid 89); 18 Jan 2019 19:44:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Jan 2019 19:44:18 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB84476540; Fri, 18 Jan 2019 19:44:16 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8BE05D979; Fri, 18 Jan 2019 19:44:15 +0000 (UTC) Subject: Re: [PATCH v2] Testsuite: Ensure stack protection is off for GCC To: Alan Hayward , "gdb-patches@sourceware.org" References: <20190118172550.65430-1-alan.hayward@arm.com> Cc: nd From: Pedro Alves Message-ID: <3f86dec6-ae47-36ca-a033-8c861f39cbaa@redhat.com> Date: Fri, 18 Jan 2019 19:44:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190118172550.65430-1-alan.hayward@arm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-01/txt/msg00426.txt.bz2 On 01/18/2019 05:25 PM, Alan Hayward wrote: > Using -fstack-protector-strong will cause GDB to break on the wrong line > when placing a breakpoint on a function. This is due to inadequate dwarf > line numbering, and is being tracked by the GCC bug > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88432 > > GCC (and Clang) provided by Debian/Ubuntu default to stack protector > being enabled. > > Ensure that when running the GDB testsuite, stack protector is always > turned off for GCC 4.1.0 (when stack protector was added) and above. > > Ensure that this does not cause infinite recursion due to > test_compiler_info having to compile a file itself. > > Add a test to explicitly test breakpoints with various levels of stack > protection on both GCC and Clang, with xfail for the known errors. > > Restore change in ovldbreak.exp which worked around the issue. Thanks! This is OK, with the nits below fixed. > > gdb/testsuite/ChangeLog: > > 2019-01-18 Alan Hayward > > * gdb.base/stack-protector.c: New test. > * gdb.base/stack-protector.exp: New file. > * gdb.cp/ovldbreak.exp: Only allow a single break line. > * lib/gdb.exp (get_compiler_info): Use getting_compiler_info option. > (gdb_compile): Remove stack protector for GCC and prevent recursion. Tabs vs spaces above. > > diff --git a/gdb/testsuite/gdb.base/stack-protector.c b/gdb/testsuite/gdb.base/stack-protector.c > new file mode 100644 > index 0000000000..5e048859a7 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/stack-protector.c > @@ -0,0 +1,27 @@ > +/* This test program 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 . */ > + > +int foo (int a) Linux break before "foo". > +{ > + return a + 7; /* break here. */ > +} > + > +int > +main () > +{ > + return foo (5); > +} > @@ -3549,11 +3550,26 @@ proc gdb_compile {source dest type options} { > } > } elseif { $opt == "shlib_load" && $type == "executable" } { > set shlib_load 1 > + } elseif { $opt == "getting_compiler_info" } { > + # If this is set, calling test_compiler_info will cause recursion. > + set getting_compiler_info 1 > } else { > lappend new_options $opt > } > } > > + # Ensure stack protector is disabled for GCC, as this will causes problems s/as this will causes/as this causes/ > + # with DWARF line numbering. > + # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88432 > + # This option defaults to on for Debian/Ubuntu. > + if { $getting_compiler_info == 0 > + && [test_compiler_info {gcc-*-*}] > + && !([test_compiler_info {gcc-[0-3]-*}] > + || [test_compiler_info {gcc-4-0-*}]) } { > + # Put it at the front to not override any user-provided value Missing period. > + lappend new_options "early_flags=-fno-stack-protector" > + } > + > # Because we link with libraries using their basename, we may need > # (depending on the platform) to set a special rpath value, to allow > # the executable to find the libraries it depends on. > Thanks, Pedro Alves