Blame SOURCES/gdb-6.3-attach-see-vdso-test.patch

ed07ac
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
ed07ac
From: Fedora GDB patches <invalid@email.com>
ed07ac
Date: Fri, 27 Oct 2017 21:07:50 +0200
ed07ac
Subject: gdb-6.3-attach-see-vdso-test.patch
ed07ac
ed07ac
;; Test kernel VDSO decoding while attaching to an i386 process.
ed07ac
;;=fedoratest
ed07ac
ed07ac
diff --git a/gdb/testsuite/gdb.base/attach-see-vdso.c b/gdb/testsuite/gdb.base/attach-see-vdso.c
ed07ac
new file mode 100644
ed07ac
--- /dev/null
ed07ac
+++ b/gdb/testsuite/gdb.base/attach-see-vdso.c
ed07ac
@@ -0,0 +1,25 @@
ed07ac
+/* This testcase is part of GDB, the GNU debugger.
ed07ac
+
ed07ac
+   Copyright 2007 Free Software Foundation, Inc.
ed07ac
+
ed07ac
+   This program is free software; you can redistribute it and/or modify
ed07ac
+   it under the terms of the GNU General Public License as published by
ed07ac
+   the Free Software Foundation; either version 2 of the License, or
ed07ac
+   (at your option) any later version.
ed07ac
+
ed07ac
+   This program is distributed in the hope that it will be useful,
ed07ac
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ed07ac
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ed07ac
+   GNU General Public License for more details.
ed07ac
+
ed07ac
+   You should have received a copy of the GNU General Public License
ed07ac
+   along with this program; if not, write to the Free Software
ed07ac
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
ed07ac
+
ed07ac
+#include <unistd.h>
ed07ac
+
ed07ac
+int main ()
ed07ac
+{
ed07ac
+  pause ();
ed07ac
+  return 1;
ed07ac
+}
ed07ac
diff --git a/gdb/testsuite/gdb.base/attach-see-vdso.exp b/gdb/testsuite/gdb.base/attach-see-vdso.exp
ed07ac
new file mode 100644
ed07ac
--- /dev/null
ed07ac
+++ b/gdb/testsuite/gdb.base/attach-see-vdso.exp
ed07ac
@@ -0,0 +1,77 @@
ed07ac
+# Copyright 2007
ed07ac
+
ed07ac
+# This program is free software; you can redistribute it and/or modify
ed07ac
+# it under the terms of the GNU General Public License as published by
ed07ac
+# the Free Software Foundation; either version 2 of the License, or
ed07ac
+# (at your option) any later version.
ed07ac
+#
ed07ac
+# This program is distributed in the hope that it will be useful,
ed07ac
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
ed07ac
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ed07ac
+# GNU General Public License for more details.
ed07ac
+#
ed07ac
+# You should have received a copy of the GNU General Public License
ed07ac
+# along with this program; if not, write to the Free Software
ed07ac
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
ed07ac
+
ed07ac
+# This file was created by Jan Kratochvil <jan.kratochvil@redhat.com>.
ed07ac
+
ed07ac
+# This test only works on Linux
ed07ac
+if { ![istarget "*-*-linux-gnu*"] } {
ed07ac
+    return 0
ed07ac
+}
ed07ac
+
ed07ac
+if {[use_gdb_stub]} {
ed07ac
+    untested "skipping test because of use_gdb_stub"
ed07ac
+    return -1
ed07ac
+}
ed07ac
+
ed07ac
+set testfile "attach-see-vdso"
ed07ac
+set srcfile  ${testfile}.c
ed07ac
+set binfile  [standard_output_file ${testfile}]
ed07ac
+set escapedbinfile  [string_to_regexp [standard_output_file ${testfile}]]
ed07ac
+
ed07ac
+# The kernel VDSO is used for the syscalls returns only on i386 (not x86_64).
ed07ac
+#
ed07ac
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-m32}] != "" } {
ed07ac
+    gdb_suppress_entire_file "Testcase nonthraded compile failed, so all tests in this file will automatically fail."
ed07ac
+}
ed07ac
+
ed07ac
+if [get_compiler_info ${binfile}] {
ed07ac
+    return -1
ed07ac
+}
ed07ac
+
ed07ac
+# Start the program running and then wait for a bit, to be sure
ed07ac
+# that it can be attached to.
ed07ac
+
ed07ac
+set testpid [eval exec $binfile &]
ed07ac
+
ed07ac
+# Avoid some race:
ed07ac
+sleep 2
ed07ac
+
ed07ac
+# Start with clean gdb
ed07ac
+gdb_exit
ed07ac
+gdb_start
ed07ac
+gdb_reinitialize_dir $srcdir/$subdir
ed07ac
+# Never call: gdb_load ${binfile}
ed07ac
+# as the former problem would not reproduce otherwise.
ed07ac
+
ed07ac
+set test "attach"
ed07ac
+gdb_test_multiple "attach $testpid" "$test" {
ed07ac
+    -re "Attaching to process $testpid\r?\n.*$gdb_prompt $" {
ed07ac
+	pass "$test"
ed07ac
+    }
ed07ac
+}
ed07ac
+
ed07ac
+gdb_test "bt" "#0 *0x\[0-9a-f\]* in \[^?\].*" "backtrace decodes VDSO"
ed07ac
+
ed07ac
+# Exit and detach the process.
ed07ac
+
ed07ac
+gdb_exit
ed07ac
+
ed07ac
+# Make sure we don't leave a process around to confuse
ed07ac
+# the next test run (and prevent the compile by keeping
ed07ac
+# the text file busy), in case the "set should_exit" didn't
ed07ac
+# work.
ed07ac
+
ed07ac
+remote_exec build "kill -9 ${testpid}"