Initial creation of sourceware repository

This commit is contained in:
Stan Shebs 1999-04-16 01:35:26 +00:00
parent cd946cff9e
commit c906108c21
2470 changed files with 976797 additions and 0 deletions

View file

@ -0,0 +1,31 @@
VPATH = @srcdir@
srcdir = @srcdir@
EXECUTABLES = pthreads
all:
@echo "Nothing to be done for all..."
info:
install-info:
dvi:
install:
uninstall: force
installcheck:
check:
clean mostlyclean:
-rm -f *~ *.o a.out xgdb *.x *.ci *.tmp core* $(EXECUTABLES)
distclean maintainer-clean realclean: clean
-rm -f Makefile config.status config.log config.h
Makefile : $(srcdir)/Makefile.in $(srcdir)/configure.in
$(SHELL) ./config.status --recheck
config.h: stamp-h ; @true
stamp-h: config.in config.status
CONFIG_HEADERS=config.h:config.in $(SHELL) config.status
config.status: configure
$(SHELL) config.status --recheck

View file

@ -0,0 +1,4 @@
/* config.in. Generated automatically from configure.in by autoheader. */
/* Define if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H

1098
gdb/testsuite/gdb.threads/configure vendored Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,18 @@
dnl Process this file file with autoconf to produce a configure script.
dnl This file is a shell script fragment that supplies the information
dnl necessary to tailor a template configure script into the configure
dnl script appropriate for this directory. For more information, check
dnl any existing configure script.
AC_PREREQ(2.5)
AC_INIT(pthreads.exp)
AC_CONFIG_HEADER(config.h:config.in)
CC=${CC-cc}
AC_SUBST(CC)
AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../../..)
AC_CANONICAL_SYSTEM
AC_CHECK_HEADERS(pthread.h)
AC_OUTPUT(Makefile)

View file

@ -0,0 +1,168 @@
#include <stdio.h>
#include "config.h"
#ifndef HAVE_PTHREAD_H
/* Don't even try to compile. In fact, cause a syntax error that we can
look for as a compiler error message and know that we have no pthread
support. In that case we can just suppress the test completely. */
#error "no posix threads support"
#else
/* OK. We have the right header. If we try to compile this and fail, then
there is something wrong and the user should know about it so the testsuite
should issue an ERROR result.. */
#ifdef __linux__
#define _MIT_POSIX_THREADS 1 /* Linux (or at least RedHat 4.0) needs this */
#endif
#include <pthread.h>
/* Under OSF 2.0 & 3.0 and HPUX 10, the second arg of pthread_create
is prototyped to be just a "pthread_attr_t", while under Solaris it
is a "pthread_attr_t *". Arg! */
#if defined (__osf__) || defined (__hpux__)
#define PTHREAD_CREATE_ARG2(arg) arg
#define PTHREAD_CREATE_NULL_ARG2 null_attr
static pthread_attr_t null_attr;
#else
#define PTHREAD_CREATE_ARG2(arg) &arg
#define PTHREAD_CREATE_NULL_ARG2 NULL
#endif
static int verbose = 0;
static void
common_routine (arg)
int arg;
{
static int from_thread1;
static int from_thread2;
static int from_main;
static int hits;
static int full_coverage;
if (verbose) printf("common_routine (%d)\n", arg);
hits++;
switch (arg)
{
case 0:
from_main++;
break;
case 1:
from_thread1++;
break;
case 2:
from_thread2++;
break;
}
if (from_main && from_thread1 && from_thread2)
full_coverage = 1;
}
static void *
thread1 (void *arg)
{
int i;
int z = 0;
if (verbose) printf ("thread1 (%0x) ; pid = %d\n", arg, getpid ());
for (i=1; i <= 10000000; i++)
{
if (verbose) printf("thread1 %d\n", pthread_self ());
z += i;
common_routine (1);
sleep(1);
}
}
static void *
thread2 (void * arg)
{
int i;
int k = 0;
if (verbose) printf ("thread2 (%0x) ; pid = %d\n", arg, getpid ());
for (i=1; i <= 10000000; i++)
{
if (verbose) printf("thread2 %d\n", pthread_self ());
k += i;
common_routine (2);
sleep(1);
}
sleep(100);
}
int
foo (a, b, c)
int a, b, c;
{
int d, e, f;
if (verbose) printf("a=%d\n", a);
}
main(argc, argv)
int argc;
char **argv;
{
pthread_t tid1, tid2;
int j;
int t = 0;
void (*xxx) ();
pthread_attr_t attr;
if (verbose) printf ("pid = %d\n", getpid());
foo (1, 2, 3);
#ifndef __osf__
if (pthread_attr_init (&attr))
{
perror ("pthread_attr_init 1");
exit (1);
}
#endif
#ifdef PTHREAD_SCOPE_SYSTEM
if (pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM))
{
perror ("pthread_attr_setscope 1");
exit (1);
}
#endif
if (pthread_create (&tid1, PTHREAD_CREATE_ARG2(attr), thread1, (void *) 0xfeedface))
{
perror ("pthread_create 1");
exit (1);
}
if (verbose) printf ("Made thread %d\n", tid1);
sleep (1);
if (pthread_create (&tid2, PTHREAD_CREATE_NULL_ARG2, thread2, (void *) 0xdeadbeef))
{
perror ("pthread_create 2");
exit (1);
}
if (verbose) printf("Made thread %d\n", tid2);
sleep (1);
for (j = 1; j <= 10000000; j++)
{
if (verbose) printf("top %d\n", pthread_self ());
common_routine (0);
sleep(1);
t += j;
}
exit(0);
}
#endif /* ifndef HAVE_PTHREAD_H */

View file

@ -0,0 +1,328 @@
# Copyright (C) 1996, 1997 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@prep.ai.mit.edu
# This file was written by Fred Fish. (fnf@cygnus.com)
if $tracelevel then {
strace $tracelevel
}
set prms_id 0
set bug_id 0
# This only works with native configurations
if ![isnative] then {
return
}
set testfile "pthreads"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
# regexp for "horizontal" text (i.e. doesn't include newline or
# carriage return)
set horiz "\[^\n\r\]*"
set built_binfile 0
if [istarget "*-*-linux"] then {
set target_cflags "-D_MIT_POSIX_THREADS"
} else {
set target_cflags ""
}
set why_msg "unrecognized error"
foreach lib {-lpthreads -lpthread} {
set options "debug"
lappend options "incdir=${objdir}/${subdir}"
lappend options "libs=$lib"
set ccout [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $options]
switch -regexp -- $ccout {
".*no posix threads support.*" {
set why_msg "missing threads include file"
break
}
".*cannot open -lpthread.*" {
set why_msg "missing runtime threads library"
}
".*Can't find library for -lpthread.*" {
set why_msg "missing runtime threads library"
}
{^$} {
pass "successfully compiled posix threads test case"
set built_binfile 1
break
}
}
}
if {$built_binfile == "0"} {
unsupported "Couldn't compile ${srcfile}, ${why_msg}"
return -1
}
# Now we can proceed with the real testing.
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_test "set print sevenbit-strings" ""
#gdb_test "set print address off" ""
gdb_test "set width 0" ""
# We'll need this when we send_gdb a ^C to GDB. Need to do it before we
# run the program and gdb starts saving and restoring tty states.
# On Ultrix, we don't need it and it is really slow (because shell_escape
# doesn't use vfork).
if ![istarget "*-*-ultrix*"] then {
gdb_test "shell stty intr '^C'" ""
}
proc all_threads_running {} {
global gdb_prompt
global srcfile
# Reset all the counters to zero.
gdb_test "set var common_routine::hits=0" ""
gdb_test "set var common_routine::from_thread1=0" ""
gdb_test "set var common_routine::from_thread2=0" ""
gdb_test "set var common_routine::from_main=0" ""
gdb_test "set var common_routine::full_coverage=0" ""
# Disable all breakpoints.
gdb_test "disable" ""
# Set up a breakpoint that will cause us to stop when we have
# been called 15 times. This should be plenty of time to allow
# every thread to run at least once, since each thread sleeps for
# one second between calls to common_routine.
gdb_test "tbreak common_routine if hits == 15" ""
# Start all the threads running again and wait for the inferior
# to stop. Since no other breakpoints are set at this time
# we should stop only when we have been previously called 15 times.
send_gdb "continue\n"
gdb_expect {
-re "Continuing.*common_routine.*at.*$srcfile.*$gdb_prompt $" {}
default {
fail "continue until common routine run 15 times"
return 0
}
timeout {
fail "continue until common routine run 15 times (timeout)"
return 0
}
}
# Check that we stopped when we actually expected to stop, by
# verifying that there have been 15 previous hits.
send_gdb "p common_routine::hits\n"
gdb_expect {
-re ".*= 15\r\n$gdb_prompt $" {}
default {
fail "stopped before calling common_routine 15 times"
return 0
}
-re ".*$gdb_prompt $" {
fail "stopped before calling common_routine 15 times"
return 0
}
timeout {
fail "stopped before calling common_routine 15 times (timeout)"
return 0
}
}
# Also check that all of the threads have run, which will only be true
# if the full_coverage variable is set.
send_gdb "p common_routine::full_coverage\n"
gdb_expect {
-re ".*= 1\r\n$gdb_prompt $" {}
default {
fail "some threads didn't run"
return 0
}
timeout {
fail "some threads didn't run (timeout)"
return 0
}
}
# Looks fine, return success.
return 1
}
proc test_startup {} {
global srcdir srcfile gdb_prompt expect_out
global horiz
global main_id thread1_id thread2_id
# We should be able to do an info threads before starting any others.
send_gdb "info threads\n"
gdb_expect {
-re ".*Thread.*LWP.*main.*$gdb_prompt $" {
pass "info threads"
}
-re "\r\n$gdb_prompt $" {
pass "info threads"
setup_xfail "*-*-*"
fail "gdb does not support pthreads for this machine"
return 0
}
}
# Extract the thread id number of main thread from "info threads" output.
send_gdb "info threads\n"
gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}main.*)($gdb_prompt $)"
set main_id $expect_out(1,string)
# Check that we can continue and create the first thread.
gdb_test "break thread1" "Breakpoint .* file .*$srcdir.*"
gdb_test "continue" \
"Continuing.*Breakpoint .*, thread1 \\(arg=0xfeedface\\).*at.*$srcfile.*" \
"Continue to creation of first thread"
gdb_test "disable" ""
# Extract the thread id number of thread 1 from "info threads" output.
send_gdb "info threads\n"
gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}thread1.*)($gdb_prompt $)"
set thread1_id $expect_out(1,string)
# Check that we can continue and create the second thread,
# ignoring the first thread for the moment.
gdb_test "break thread2" "Breakpoint .* file .*$srcdir.*"
gdb_test "continue" \
"Continuing.*Breakpoint .*, thread2 \\(arg=0xdeadbeef\\).*at.*$srcfile.*" \
"Continue to creation of second thread"
# Extract the thread id number of thread 2 from "info threads" output.
send_gdb "info threads\n"
gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}thread2.*)($gdb_prompt $)"
set thread2_id $expect_out(1,string)
return 1
}
proc check_control_c {} {
global gdb_prompt
# Verify that all threads are running.
if [all_threads_running] then {
pass "All threads running after startup"
}
# Send a continue followed by ^C to the process to stop it.
send_gdb "continue\n"
set description "Stopped with a ^C"
after 1000 [send_gdb "\003"]
gdb_expect {
-re "Program received signal SIGINT.*$gdb_prompt $" {
pass $description
}
-re "Quit.*$gdb_prompt $" {
pass $description
}
timeout {
fail "$description (timeout)"
}
}
gdb_test "bt" ""
# Verify that all threads can be run again after a ^C stop.
if [all_threads_running] then {
pass "All threads running after continuing from ^C stop"
}
}
proc check_backtraces {} {
global gdb_prompt main_id thread1_id thread2_id
# Check that the "thread apply N backtrace" command works
gdb_test "thread apply $main_id backtrace" \
".* in main \\(argc=.*, argv=.*\\).*" \
"check backtrace from main thread"
gdb_test "thread apply $thread1_id backtrace" \
".* in thread1 \\(arg=0xfeedface\\).*" \
"check backtrace from thread 1"
gdb_test "thread apply $thread2_id backtrace" \
".* in thread2 \\(arg=0xdeadbeef\\).*" \
"check backtrace from thread 2"
# Check that we can apply the backtrace command to all
# three threads with a single gdb command
gdb_test "thread apply $main_id $thread1_id $thread2_id bt" \
".* in main .* in thread1 .* in thread2.*" \
"apply backtrace command to all three threads"
# Check that we can do thread specific backtraces
# This also tests that we can do thread specific breakpoints.
gdb_test "break common_routine thread $thread2_id" \
"Breakpoint .* at 0x.* file .* line .*" \
"set break at common_routine in thread 2"
send_gdb "continue\n"
gdb_expect {
-re "Breakpoint .* common_routine \\(arg=2\\).*" {
send_gdb "backtrace\n"
gdb_expect {
-re "#0.*common_routine \\(arg=2\\).*#1.*thread2.*" {
pass "backtrace from thread 2 bkpt in common_routine"
}
default {
fail "backtrace from thread 2 bkpt in common_routine"
}
timeout {
fail "backtrace from thread 2 bkpt in common_routine (timeout)"
}
}
}
-re "Breakpoint .* common_routine \\(arg=0\\).*" {
fail "stopped in main thread at breakpoint for thread 2"
}
-re "Breakpoint .* common_routine \\(arg=1\\).*" {
fail "stopped in main thread at breakpoint for thread 1"
}
-re ".*$gdb_prompt" {
fail "continue to bkpt at common_routine in thread 2"
}
default {
fail "continue to bkpt at common_routine in thread 2"
}
timeout {
fail "continue to bkpt at common_routine in thread 2 (timeout)"
}
}
}
setup_xfail "alpha-*-osf*"
if [runto_main] then {
clear_xfail "alpha-*-osf*"
if [test_startup] then {
check_control_c
check_backtraces
}
}
clear_xfail "alpha-*-osf*"

View file

@ -0,0 +1,221 @@
/* step.c for step.exp */
#include <ipc.h>
#include <pthread.h>
#include <st.h>
#include <signal.h>
#include <stdio.h>
void alarm_handler ();
void alarm_handler1 ();
void alarm_handler2 ();
void thread1 ();
void thread2 ();
#define TIME_LIMIT 30
int count1 = 0;
int count2 = 0;
pthread_t tid1, tid2;
pthread_attr_t attr1, attr2;
pthread_mutex_t mut;
pthread_mutexattr_t mut_attr;
pthread_condattr_t cv_attr_a, cv_attr_b;
pthread_cond_t cv_a, cv_b;
struct cv_struct
{
char a;
char b;
}
test_struct;
main ()
{
/*init la struct */
test_struct.a = 0;
test_struct.b = 1;
/* create le mutex */
if (pthread_mutexattr_create (&mut_attr) == -1)
{
perror ("mutexattr_create");
exit (1);
}
if (pthread_mutex_init (&mut, mut_attr) == -1)
{
perror ("mutex_init");
exit (1);
}
/* create 2 cv */
if (pthread_condattr_create (&cv_attr_a) == -1)
{
perror ("condattr_create(1)");
exit (1);
}
if (pthread_cond_init (&cv_a, cv_attr_a) == -1)
{
perror ("cond_init(1)");
exit (1);
}
if (pthread_condattr_create (&cv_attr_b) == -1)
{
perror ("condattr_create(2)");
exit (1);
}
if (pthread_cond_init (&cv_b, cv_attr_b) == -1)
{
perror ("cond_init(2)");
exit (1);
}
/* create 2 threads of execution */
if (pthread_attr_create (&attr1) == -1)
{
perror ("attr_create(1)");
exit (1);
}
if (pthread_create (&tid1, attr1, thread1, &count1) == -1)
{
perror ("pthread_create(1)");
exit (1);
}
if (pthread_attr_create (&attr2) == -1)
{
perror ("attr_create(2)");
exit (1);
}
if (pthread_create (&tid2, attr2, thread2, &count2) == -1)
{
perror ("pthread_create(2)");
exit (1);
}
/* set alarm to print out data and exit */
signal (SIGALRM, alarm_handler);
alarm (TIME_LIMIT);
for (;;)
pause ();
}
void
thread1 (count)
int *count;
{
tid_t tid;
tid = getstid ();
printf ("Thread1 tid 0x%x (%d) \n", tid, tid);
printf ("Thread1 @tid=0x%x \n", &tid);
signal (SIGALRM, alarm_handler1);
for (;;)
{
if (pthread_mutex_lock (&mut) == -1)
{
perror ("pthread_mutex_lock(1)");
pthread_exit ((void *) 0);
}
while (test_struct.a == 0)
{
if (pthread_cond_wait (&cv_a, &mut) == -1)
{
perror ("pthread_cond_wait(1)");
pthread_exit ((void *) -1);
}
}
(*count)++;
printf ("*******thread1 count %d\n", *count);
test_struct.a = 0;
test_struct.b = 1;
pthread_cond_signal (&cv_b);
if (pthread_mutex_unlock (&mut) == -1)
{
perror ("pthread_mutex_unlock(1)");
pthread_exit ((void *) -1);
}
}
}
void
thread2 (count)
int *count;
{
tid_t tid;
tid = getstid ();
printf ("Thread2 tid 0x%x (%d) \n", tid, tid);
printf ("Thread1 @tid=0x%x \n", &tid);
signal (SIGALRM, alarm_handler2);
for (;;)
{
if (pthread_mutex_lock (&mut) == -1)
{
perror ("pthread_mutex_lock(2)");
pthread_exit ((void *) 0);
}
while (test_struct.b == 0)
{
if (pthread_cond_wait (&cv_b, &mut) == -1)
{
perror ("pthread_cond_wait(2)");
pthread_exit ((void *) -1);
}
}
(*count)++;
printf ("*******thread2 count %d\n", *count);
test_struct.b = 0;
test_struct.a = 1;
pthread_cond_signal (&cv_a);
if (pthread_mutex_unlock (&mut) == -1)
{
perror ("pthread_mutex_unlock(2)");
pthread_exit ((void *) -1);
}
}
}
void
alarm_handler ()
{
printf ("\tcount1 (%d) \n\tcount2 (%d)\n", count1, count2);
exit (0);
}
void
alarm_handler1 ()
{
printf ("ALARM thread 1\n");
}
void
alarm_handler2 ()
{
printf ("ALARM thread 2\n");
pthread_exit ((void *) 0);
}

View file

@ -0,0 +1,200 @@
# step.exp -- Expect script to test gdb with step.c
# Copyright (C) 1992, 1997 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@prep.ai.mit.edu
# This file was written by Hiro Sugawara. (hiro@lynx.com)
#
# This test really needs some major surgery to be acceptable, but
# I'm just about burnt out on lynx work, so I'm not doing it now.
#
# * The test has an indeterminate number of pass/fails
# for each run (it runs a small group of tests until
# it's timer kicks off). This is very bad for nightly
# automated regression testing.
#
# * It tries to "step" from withint he prologue of a
# function. This isn't support in gdb (it's going
# to act like a continue).
#
# * This test rarely check that it stopped in sensible
# places. (see previous bullet -- this test doesn't
# catch the fact it continued rather than stepped)
if $tracelevel then {
strace $tracelevel
}
set program_exited 0
proc set_bp { where } {
global gdb_prompt
send_gdb "break $where\n"
# The first regexp is what we get with -g, the second without -g.
gdb_expect {
-re "Break.* at .*: file .*, line \[0-9\]*.*$gdb_prompt $" {}
-re "Breakpoint \[0-9\]* at 0x\[0-9a-f\]*.*$gdb_prompt $" {}
-re "$gdb_prompt $" { fail "setting breakpoint at $where" ; return 0 }
timeout { fail "setting breakpoint at $where (timeout)" ; return 0 }
}
pass "set_bp"
}
proc step_it { cmd } {
global gdb_prompt
global program_exited
send_gdb "$cmd\n"
gdb_expect {
-re "0x\[0-9A-Fa-f\]* *in.*\r\n$gdb_prompt $" { pass "step_it"; return 0 }
-re "0x\[0-9A-Fa-f\]* *\[0-9\]*.*\r\n$gdb_prompt $" { pass "step_it"; return 1 }
-re "Program exited .*\n$gdb_prompt $" {
set program_exited 1
return -1
}
-re "$gdb_prompt $" { fail "single-stepping ($cmd).\n" ; return -1 }
timeout { fail "single-stepping ($cmd) timout.\n" ; return -1 }
}
}
proc step_inst {} {
step_it "stepi"
}
proc step_source {} {
step_it "step"
}
proc continue_all {} {
global gdb_prompt
send_gdb "continue\n"
gdb_expect {
-re "Breakpoint \[0-9\]*, thread\[0-9\]* .*$gdb_prompt $" {
pass "continue_all"
return 0
}
-re "Program exited .*\n$gdb_prompt $" {
set program_exited 1
return 1;
}
-re "$gdb_prompt $" { fail "continue" ; return -1 }
timeout { fail "continue (timeout)" ; return -1 }
}
}
proc check_threads { num_threads } {
global gdb_prompt
set curr_thread 0
send_gdb "info threads\n"
while { $num_threads > 0 } {
gdb_expect {
-re "\\* *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" {
incr curr_thread
set num_threads [expr $num_threads - 1]
}
-re " *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" {
set num_threads [expr $num_threads - 1]
}
-re "$gdb_prompt $" {
if { $num_threads < 0 } {
fail "check_threads (too many)" ; return -1
}
break
}
timeout { fail "check_threads (timeout)" ; return -1 }
}
}
if { $curr_thread == 0 } {
fail "check_threads (no current thread)\n"
return -1
}
if { $curr_thread > 1 } {
fail "check_threads (more than one current thread)\n"
return -1
}
return 0
}
proc test_cond_wait {} {
global program_exited
set_bp 135
runto 179
while { 1 } {
set stepi_counter 0
while { [step_inst] } {
if { $program_exited } { break }
incr stepi_counter
if { $stepi_counter > 30 } {
fail "too many stepi's per line\n"
return -1
}
}
if { $program_exited } { break }
step_source
if { $program_exited } { break }
continue_all
if { $program_exited } { break }
check_threads 3
}
}
proc do_tests {} {
global prms_id
global bug_id
global subdir
global objdir
global srcdir
global binfile
global gdb_prompt
set prms_id 0
set bug_id 0
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $objdir/$subdir/$binfile
send_gdb "set width 0\n"
gdb_expect -re "$gdb_prompt $"
test_cond_wait
}
# Check to see if we have an executable to test. If not, then either we
# haven't tried to compile one, or the compilation failed for some reason.
# In either case, just notify the user and skip the tests in this file.
set binfile "step"
set srcfile "step.c"
if ![file exists $objdir/$subdir/$binfile] then {
if $all_flag then {
warning "$binfile does not exist; tests suppressed."
}
} else {
do_tests
}

View file

@ -0,0 +1,150 @@
# step2.exp -- Expect script to test gdb step.c
# Copyright (C) 1992, 1997 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@prep.ai.mit.edu
# This file was written by Jeff Law. (law@cygnus.com)
#
if $tracelevel then {
strace $tracelevel
}
set program_exited 0
# A simple and crude test to see that we can step two threads independently
proc test_multi_threaded_stepping {} {
global gdb_prompt
global hex
global srcfile
global decimal
# Set breakpoints in code that we know is executed in only
# thread of control.
gdb_test "break thread1" \
"Break.* at $hex: file .*$srcfile, line $decimal\\."
gdb_test "break thread2" \
"Break.* at $hex: file .*$srcfile, line $decimal\\."
# the order in which things happen is indeterminate. So we basically
# look for a set of events and note that each one happens and that
# all of the required events have happened when we're done.
#
# Right now we only verify that both threads start and that they
# both call pthread_cond_wait twice.
set thread1started 0
set thread1condwait 0
set thread2started 0
set thread2condwait 0
send_gdb "run\n"
gdb_expect {
-re "The program .* has been started already.*y or n. $" {
send_gdb "y\n"
exp_continue
}
-re ".*Breakpoint \[0-9\]+,.*thread1.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" {
if { $thread1started != 0 } then {
fail "thread1 started"
return
} else {
set thread1started 1
pass "thread1 started"
}
send_gdb "step\n"
exp_continue
}
-re ".*Breakpoint \[0-9\]+,.*thread2.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" {
if { $thread2started != 0 } then {
fail "thread2 started"
return
} else {
set thread2started 1
pass "thread2 started"
}
send_gdb "step\n"
exp_continue
}
-re ".*pthread_cond_wait.*cv_a.*$gdb_prompt" {
if { $thread1started == 0 } then {
fail "thread1 condwait"
return
}
if { $thread1condwait < 2 } then {
pass "thread1 condwait"
incr thread1condwait
}
if { $thread2condwait == 2 } then {
pass "multi threaded stepping"
return
}
send_gdb "step\n"
exp_continue
}
-re ".*pthread_cond_wait.*cv_b.*$gdb_prompt" {
if { $thread2started == 0 } then {
fail "thread2 condwait"
return
}
if { $thread2condwait < 2 } then {
pass "thread2 condwait"
incr thread2condwait
}
if { $thread1condwait == 2 } then {
pass "multi threaded stepping"
return
}
send_gdb "step\n"
exp_continue
}
-re "$gdb_prompt" {
send_gdb "step\n"
exp_continue
}
default { fail "multi threaded stepping" }
}
}
# Check to see if we have an executable to test. If not, then either we
# haven't tried to compile one, or the compilation failed for some reason.
# In either case, just notify the user and skip the tests in this file.
set binfile "step"
set srcfile "step.c"
if ![file exists $objdir/$subdir/$binfile] then {
if $all_flag then {
warning "$binfile does not exist; tests suppressed."
}
return
}
set prms_id 0
set bug_id 0
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $objdir/$subdir/$binfile
test_multi_threaded_stepping