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

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