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

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