Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Alan Hayward <Alan.Hayward@arm.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: nd <nd@arm.com>
Subject: Re: [PATCH v2] Testsuite: Ensure stack protection is off for GCC
Date: Fri, 18 Jan 2019 19:44:00 -0000	[thread overview]
Message-ID: <3f86dec6-ae47-36ca-a033-8c861f39cbaa@redhat.com> (raw)
In-Reply-To: <20190118172550.65430-1-alan.hayward@arm.com>

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  <alan.hayward@arm.com>
> 
> 	* 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 <http://www.gnu.org/licenses/>.  */
> +
> +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


  reply	other threads:[~2019-01-18 19:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-18 17:26 Alan Hayward
2019-01-18 19:44 ` Pedro Alves [this message]
2019-02-19 18:11 ` Sergio Durigan Junior
2019-02-20 11:52   ` Alan Hayward

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f86dec6-ae47-36ca-a033-8c861f39cbaa@redhat.com \
    --to=palves@redhat.com \
    --cc=Alan.Hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox