aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.threads
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>1995-07-26 00:35:07 +0000
committerJeff Law <law@redhat.com>1995-07-26 00:35:07 +0000
commitf27ffb51f544e79fe110af75c84879bae35c5096 (patch)
treeceacc3966c4f276a120c6cc43b06ebfe65aaa834 /gdb/testsuite/gdb.threads
parent80ac01168f15cb5b0e29f892b749bcd357ac9143 (diff)
downloadgdb-f27ffb51f544e79fe110af75c84879bae35c5096.zip
gdb-f27ffb51f544e79fe110af75c84879bae35c5096.tar.gz
gdb-f27ffb51f544e79fe110af75c84879bae35c5096.tar.bz2
* gdb.threads: New directory with some crude multi-threaded
gdb tests (step.exp and step2.exp). * config/mt-lynx (STEP_EXECUTABLE): Define. (THREADFLAGS): Define. Hiro's test for 6100 and a crude test of my own. They both need some major cleanup for non-lynx hosts; both are also a little too loose in their checks. But I'm too burnt out on lynx to address either concern.
Diffstat (limited to 'gdb/testsuite/gdb.threads')
-rw-r--r--gdb/testsuite/gdb.threads/configure.in32
-rw-r--r--gdb/testsuite/gdb.threads/step.c221
2 files changed, 253 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.threads/configure.in b/gdb/testsuite/gdb.threads/configure.in
new file mode 100644
index 0000000..07619ad
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/configure.in
@@ -0,0 +1,32 @@
+# This file is a shell script fragment that supplies the information
+# necessary to tailor a template configure script into the configure
+# script appropriate for this directory. For more information, check
+# any existing configure script.
+
+srctrigger="Makefile.in"
+srcname="gdb.threads"
+
+# per-host:
+
+# per-target:
+
+ # everything defaults to unix for a target
+target_abbrev=unix
+target_makefile_frag=../config/mt-unix
+
+ # this section is for all targets
+case "${target}" in
+ hppa*-*-hpux*) target_makefile_frag=../config/mt-hpux ;;
+ i[345]86-*-aout) target_makefile_frag=../config/mt-i386-aout ;;
+ *-*-lynx*) target_makefile_frag=../config/mt-lynx ;;
+ *-*-netware*) target_makefile_frag=../config/mt-netware ;;
+ *-*-vxworks*) target_makefile_frag=../config/mt-vxworks ;;
+ m68k-*-*) target_makefile_frag=../config/mt-m68k ;;
+ i960-*-nindy) target_makefile_frag=../config/mt-i960-nindy ;;
+ a29k-*-udi) target_makefile_frag=../config/mt-a29k-udi ;;
+ sparclite-*-*) target_makefile_frag=../config/mt-slite ;;
+ sparc-*-aout) target_makefile_frag=../config/mt-sparc-aout ;;
+ mips-*-ecoff) target_makefile_frag=../config/mt-mips-ecoff ;;
+esac
+
+# post-target:
diff --git a/gdb/testsuite/gdb.threads/step.c b/gdb/testsuite/gdb.threads/step.c
new file mode 100644
index 0000000..1b18a4b
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/step.c
@@ -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);
+}