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

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