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

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