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