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

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