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

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