This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] gdb.python/py-unwind: Disable stack protection
- From: Simon Marchi <simark at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 21 Jul 2017 22:03:16 -0000
- Subject: [binutils-gdb] gdb.python/py-unwind: Disable stack protection
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dcd27ddf875d6b913f1ddb0573c22b0931e36061
commit dcd27ddf875d6b913f1ddb0573c22b0931e36061
Author: Simon Marchi <simon.marchi@ericsson.com>
Date: Sat Jul 22 00:01:03 2017 +0200
gdb.python/py-unwind: Disable stack protection
[I made some typo fixes but forgot to amend my commit before sending the patch,
hence this v2.]
I see the following failure on Ubuntu 16.04's gcc 5.4.0:
Running /home/emaisin/src/binutils-gdb/gdb/testsuite/gdb.python/py-unwind.exp ...
FAIL: gdb.python/py-unwind.exp: continue to breakpoint: break backtrace-broken
FAIL: gdb.python/py-unwind.exp: Backtrace restored by unwinder (pattern 1)
The problem is that the test expects a very particular stack layout.
When stack protection is enabled, it adds a canary value which looks
like an additional local variable. This makes the test complain about
a bad stack layout and fail.
The simple solution is to disable stack protection for that test using
-fno-stack-protector. I checked older compilers (gcc 4.4, clang 3.5)
and they support that flag, so I don't think it's necessary to probe for
whether the compiler supports it.
Maybe a better solution would be to change the test to make it cope with
different stack layouts (perhaps it could save addresses of stuff in
some global variables which GDB/the unwinder would read). I'll go with
the simple solution for now though.
gdb/testsuite/ChangeLog:
* gdb.python/py-unwind.exp: Disable stack protection when
building test file.
Diff:
---
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.python/py-unwind.exp | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index eef141d..273d1f7 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-07-22 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.python/py-unwind.exp: Disable stack protection when
+ building test file.
+
2017-07-20 Pedro Alves <palves@redhat.com>
* gdb.base/default.exp (set language): Adjust expected output.
diff --git a/gdb/testsuite/gdb.python/py-unwind.exp b/gdb/testsuite/gdb.python/py-unwind.exp
index 625b04c..86e695c 100644
--- a/gdb/testsuite/gdb.python/py-unwind.exp
+++ b/gdb/testsuite/gdb.python/py-unwind.exp
@@ -20,7 +20,12 @@ load_lib gdb-python.exp
standard_testfile
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+# Stack protection can make the stack look a bit different, breaking the
+# assumptions this test has about its layout.
+
+set flags "additional_flags=-fno-stack-protector"
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} "debug $flags"] } {
return -1
}