This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[RFA]: Test for threads attach/detach


Better get aproval for this stuff first :-).

This is supposed to test attaching to a multi-threaded program.  Only
executed on Linux for now.

OK, to check this in?

Mark


Index: testsuite/ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* gdb.threads/attach.exp: New file.

--- /dev/null	Thu Feb 19 16:30:24 1998
+++ testsuite/gdb.threads/attach.exp	Sun May  6 14:30:39 2001
@@ -0,0 +1,119 @@
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@gnu.org
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+# This probably only works with Linux configurations.
+if ![istarget *-*-linux-gnu] then {
+    return
+}
+
+set testfile "linux-dp"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug libs=-lpthread}] != "" } {
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+# Create and source the file that provides information about the compiler
+# used to compile the test case.
+
+if [get_compiler_info ${binfile}] {
+    return -1;
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Start the program running and then wait for a bit, to be sure that
+# it can be attached to.
+
+set testpid [eval exec $binfile > /dev/null &]
+exec sleep 2
+
+send_gdb "attach $testpid\n"
+gdb_expect {
+    -re "Attaching to program.*$binfile.*\\\[New .*\\\].*$gdb_prompt $" {
+	pass "attach1"
+    }
+    -re ".*$gdb_prompt $" {
+	fail "attach1"
+    }
+    timeout {
+	fail "attach1 (timeout)"
+    }
+}
+
+send_gdb "detach\n"
+gdb_expect {
+    -re "Detaching from program: .*$binfile.*$gdb_prompt $" {
+	pass "detach attach1"
+    }
+    -re ".*$gdb_prompt $" {
+	fail "detach attach1"
+    }
+    timeout {
+	fail "detach attach1 (timeout)"
+    }
+}
+
+send_gdb "attach $testpid\n"
+gdb_expect {
+    -re "Attaching to program.*$binfile.*\\\[New .*\\\].*$gdb_prompt $" {
+	pass "attach2"
+    }
+    -re ".*$gdb_prompt $" {
+	fail "attach2"
+    }
+    timeout {
+	fail "attach2 (timeout)"
+    }
+}
+
+send_gdb "kill\n"
+gdb_expect {
+    -re ".*Kill the program being debugged.*y or n. $" {
+	send_gdb "y\n"
+	gdb_expect {
+	    -re "$gdb_prompt $" {
+		pass "after attach2, exit"
+	    }
+	    timeout {
+		fail "after attach2, exit (timeout)"
+	    }
+	}
+    }
+    -re "$gdb_prompt $" {
+	fail "after attach2, exit"
+    }
+    timeout {
+	fail "after attach2, exit (timeout)"
+    }
+}
+
+return


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]