Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@wins.uva.nl>
To: gdb-patches@sources.redhat.com
Cc: fnasser@cygnus.com
Subject: [RFA]: Test for threads attach/detach
Date: Sun, 06 May 2001 10:11:00 -0000	[thread overview]
Message-ID: <200105061711.f46HBRn00371@delius.kettenis.local> (raw)

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


             reply	other threads:[~2001-05-06 10:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-06 10:11 Mark Kettenis [this message]
     [not found] ` <3B5F4EC3.33CC33D3@cygnus.com>
2001-07-26  2:40   ` Mark Kettenis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200105061711.f46HBRn00371@delius.kettenis.local \
    --to=kettenis@wins.uva.nl \
    --cc=fnasser@cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox