2003-10-23 04:43:54 +00:00
|
|
|
/* Pthreads test program.
|
2014-01-01 03:54:24 +00:00
|
|
|
Copyright 1996-2014 Free Software Foundation, Inc.
|
2003-10-23 04:43:54 +00:00
|
|
|
|
|
|
|
Written by Fred Fish of Cygnus Support
|
|
|
|
Contributed by Cygnus Support
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
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
|
2007-08-23 18:08:50 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2003-10-23 04:43:54 +00:00
|
|
|
(at your option) any later version.
|
2007-08-23 18:08:50 +00:00
|
|
|
|
2003-10-23 04:43:54 +00:00
|
|
|
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.
|
2007-08-23 18:08:50 +00:00
|
|
|
|
2003-10-23 04:43:54 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 18:08:50 +00:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2003-10-23 04:43:54 +00:00
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
#include <stdio.h>
|
2004-09-14 20:28:25 +00:00
|
|
|
#include <stdlib.h>
|
1999-04-16 01:35:26 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
|
Delete Tru64 support
This commit does most of the mechanical removal. IOW, the easy part.
procfs.c isn't touched beyond removing a couple obvious bits that are
guarded by a couple macros defined in config/alpha/nm-osf3.h. Going
beyond that for procfs.c & co would be a harder excision that
potentially affects Solaris.
Some comments in the generic alpha code ABIs that may still be
relevant and I wouldn't know what to do with them. That can always be
done on a separate pass, preferably by someone who can test on alpha.
A couple other spots have references to OSF/Tru64 and related files
being removed, but it felt like removing them would make things worse,
not better. We can revisit those when we next need to touch that
code.
I didn't remove a reference to osf in testsuite/lib/future.exp, as I
believe that code is imported from DejaGNU.
Built and tested on x86_64 Fedora 20, with --enable-targets=all.
Tested that building for --target=alpha-osf3 on x86_64 Fedora 20
fails with:
checking for default auto-load directory... $debugdir:$datadir/auto-load
checking for default auto-load safe-path... $debugdir:$datadir/auto-load
*** Configuration alpha-unknown-osf3 is obsolete.
*** Support has been REMOVED.
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory `build-osf'
make: *** [all] Error 2
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
* Makefile.in (ALL_64_TARGET_OBS): Remove alpha-osf1-tdep.o.
(HFILES_NO_SRCDIR): Remove config/alpha/nm-osf3.h.
(ALLDEPFILES): Remove alpha-nat.c, alpha-osf1-tdep.c and
solib-osf.c.
* NEWS: Mention that support for alpha*-*-osf* has been removed.
* ada-lang.h [__alpha__ && __osf__]
(ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS): Delete.
* alpha-nat.c, alpha-osf1-tdep.c: Delete files.
* alpha-tdep.c (alpha_gdbarch_init): Remove reference to
GDB_OSABI_OSF1.
* config/alpha/alpha-osf3.mh, config/alpha/nm-osf3.h: Delete
files.
* config/djgpp/fnchange.lst (config/alpha/alpha-osf1.mh)
(config/alpha/alpha-osf2.mh, config/alpha/alpha-osf3.mh): Delete.
* configure: Regenerate.
* configure.ac: Remove references to osf.
* configure.host: Handle alpha*-*-osf* in the obsolete hosts
section. Remove all other references to osf.
* configure.tgt: Add alpha*-*-osf* to the obsolete targets section.
Remove all other references to osf.
* dec-thread.c: Delete file.
* defs.h (GDB_OSABI_OSF1): Delete.
* inferior.h (START_INFERIOR_TRAPS_EXPECTED): New unconditionally
defined.
* osabi.c (gdb_osabi_names): Delete "OSF/1".
* procfs.c (procfs_debug_inferior) [PROCFS_DONT_TRACE_FAULTS]:
Delete code.
(unconditionally_kill_inferior)
[PROCFS_NEED_CLEAR_CURSIG_FOR_KILL]: Delete code.
* solib-osf.c: Delete file.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
* gdb.base/callfuncs.exp: emove references to osf.
* gdb.base/sigall.exp: Likewise.
* gdb.gdb/selftest.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.mi/non-stop.c: Likewise.
* gdb.mi/pthreads.c: Likewise.
* gdb.reverse/sigall-precsave.exp: Likewise.
* gdb.reverse/sigall-reverse.exp: Likewise.
* gdb.threads/pthreads.c: Likewise.
* gdb.threads/pthreads.exp: Likewise.
gdb/doc/
2014-10-17 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Ada Tasks and Core Files): Delete mention of Tru64.
(SVR4 Process Information): Delete mention of OSF/1.
2014-10-17 10:18:59 +00:00
|
|
|
/* Under HPUX 10, the second arg of pthread_create
|
1999-04-16 01:35:26 +00:00
|
|
|
is prototyped to be just a "pthread_attr_t", while under Solaris it
|
|
|
|
is a "pthread_attr_t *". Arg! */
|
|
|
|
|
Delete Tru64 support
This commit does most of the mechanical removal. IOW, the easy part.
procfs.c isn't touched beyond removing a couple obvious bits that are
guarded by a couple macros defined in config/alpha/nm-osf3.h. Going
beyond that for procfs.c & co would be a harder excision that
potentially affects Solaris.
Some comments in the generic alpha code ABIs that may still be
relevant and I wouldn't know what to do with them. That can always be
done on a separate pass, preferably by someone who can test on alpha.
A couple other spots have references to OSF/Tru64 and related files
being removed, but it felt like removing them would make things worse,
not better. We can revisit those when we next need to touch that
code.
I didn't remove a reference to osf in testsuite/lib/future.exp, as I
believe that code is imported from DejaGNU.
Built and tested on x86_64 Fedora 20, with --enable-targets=all.
Tested that building for --target=alpha-osf3 on x86_64 Fedora 20
fails with:
checking for default auto-load directory... $debugdir:$datadir/auto-load
checking for default auto-load safe-path... $debugdir:$datadir/auto-load
*** Configuration alpha-unknown-osf3 is obsolete.
*** Support has been REMOVED.
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory `build-osf'
make: *** [all] Error 2
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
* Makefile.in (ALL_64_TARGET_OBS): Remove alpha-osf1-tdep.o.
(HFILES_NO_SRCDIR): Remove config/alpha/nm-osf3.h.
(ALLDEPFILES): Remove alpha-nat.c, alpha-osf1-tdep.c and
solib-osf.c.
* NEWS: Mention that support for alpha*-*-osf* has been removed.
* ada-lang.h [__alpha__ && __osf__]
(ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS): Delete.
* alpha-nat.c, alpha-osf1-tdep.c: Delete files.
* alpha-tdep.c (alpha_gdbarch_init): Remove reference to
GDB_OSABI_OSF1.
* config/alpha/alpha-osf3.mh, config/alpha/nm-osf3.h: Delete
files.
* config/djgpp/fnchange.lst (config/alpha/alpha-osf1.mh)
(config/alpha/alpha-osf2.mh, config/alpha/alpha-osf3.mh): Delete.
* configure: Regenerate.
* configure.ac: Remove references to osf.
* configure.host: Handle alpha*-*-osf* in the obsolete hosts
section. Remove all other references to osf.
* configure.tgt: Add alpha*-*-osf* to the obsolete targets section.
Remove all other references to osf.
* dec-thread.c: Delete file.
* defs.h (GDB_OSABI_OSF1): Delete.
* inferior.h (START_INFERIOR_TRAPS_EXPECTED): New unconditionally
defined.
* osabi.c (gdb_osabi_names): Delete "OSF/1".
* procfs.c (procfs_debug_inferior) [PROCFS_DONT_TRACE_FAULTS]:
Delete code.
(unconditionally_kill_inferior)
[PROCFS_NEED_CLEAR_CURSIG_FOR_KILL]: Delete code.
* solib-osf.c: Delete file.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
* gdb.base/callfuncs.exp: emove references to osf.
* gdb.base/sigall.exp: Likewise.
* gdb.gdb/selftest.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.mi/non-stop.c: Likewise.
* gdb.mi/pthreads.c: Likewise.
* gdb.reverse/sigall-precsave.exp: Likewise.
* gdb.reverse/sigall-reverse.exp: Likewise.
* gdb.threads/pthreads.c: Likewise.
* gdb.threads/pthreads.exp: Likewise.
gdb/doc/
2014-10-17 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Ada Tasks and Core Files): Delete mention of Tru64.
(SVR4 Process Information): Delete mention of OSF/1.
2014-10-17 10:18:59 +00:00
|
|
|
#if defined (__hpux__)
|
1999-04-16 01:35:26 +00:00
|
|
|
#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;
|
|
|
|
|
2010-03-23 23:50:22 +00:00
|
|
|
if (verbose) printf ("thread1 (%0lx) ; pid = %d\n", (long) arg, getpid ());
|
1999-04-16 01:35:26 +00:00
|
|
|
for (i=1; i <= 10000000; i++)
|
|
|
|
{
|
2010-03-23 23:50:22 +00:00
|
|
|
if (verbose) printf("thread1 %ld\n", (long) pthread_self ());
|
1999-04-16 01:35:26 +00:00
|
|
|
z += i;
|
|
|
|
common_routine (1);
|
|
|
|
sleep(1);
|
|
|
|
}
|
2002-02-24 20:37:56 +00:00
|
|
|
return (void *) 0;
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
thread2 (void * arg)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int k = 0;
|
|
|
|
|
2010-03-23 23:50:22 +00:00
|
|
|
if (verbose) printf ("thread2 (%0lx) ; pid = %d\n", (long) arg, getpid ());
|
1999-04-16 01:35:26 +00:00
|
|
|
for (i=1; i <= 10000000; i++)
|
|
|
|
{
|
2010-03-23 23:50:22 +00:00
|
|
|
if (verbose) printf("thread2 %ld\n", (long) pthread_self ());
|
1999-04-16 01:35:26 +00:00
|
|
|
k += i;
|
|
|
|
common_routine (2);
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
sleep(100);
|
2002-02-24 20:37:56 +00:00
|
|
|
return (void *) 0;
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2002-02-24 20:37:56 +00:00
|
|
|
void
|
1999-04-16 01:35:26 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
if (pthread_attr_init (&attr))
|
|
|
|
{
|
|
|
|
perror ("pthread_attr_init 1");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#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);
|
|
|
|
}
|
2010-03-23 23:50:22 +00:00
|
|
|
if (verbose) printf ("Made thread %ld\n", (long) tid1);
|
1999-04-16 01:35:26 +00:00
|
|
|
sleep (1);
|
|
|
|
|
|
|
|
if (pthread_create (&tid2, PTHREAD_CREATE_NULL_ARG2, thread2, (void *) 0xdeadbeef))
|
|
|
|
{
|
|
|
|
perror ("pthread_create 2");
|
|
|
|
exit (1);
|
|
|
|
}
|
2010-03-23 23:50:22 +00:00
|
|
|
if (verbose) printf("Made thread %ld\n", (long) tid2);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
sleep (1);
|
|
|
|
|
|
|
|
for (j = 1; j <= 10000000; j++)
|
|
|
|
{
|
2010-03-23 23:50:22 +00:00
|
|
|
if (verbose) printf("top %ld\n", (long) pthread_self ());
|
1999-04-16 01:35:26 +00:00
|
|
|
common_routine (0);
|
|
|
|
sleep(1);
|
|
|
|
t += j;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|