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

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