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

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