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