| Index: gdb/contrib/expect-read1.c
|
| diff --git a/gdb/testsuite/gdb.threads/corethreads.c b/gdb/contrib/expect-read1.c
|
| similarity index 59%
|
| copy from gdb/testsuite/gdb.threads/corethreads.c
|
| copy to gdb/contrib/expect-read1.c
|
| index e3c7c8c3bf70bbea79e099274254a40b542c6976..963c1ffab9358e898898c19aa55404ceef5143b5 100644
|
| --- a/gdb/testsuite/gdb.threads/corethreads.c
|
| +++ b/gdb/contrib/expect-read1.c
|
| @@ -1,4 +1,4 @@
|
| -/* Copyright 2011-2012 Free Software Foundation, Inc.
|
| +/* Copyright (C) 2013 Free Software Foundation, Inc.
|
|
|
| This file is part of GDB.
|
|
|
| @@ -15,33 +15,26 @@
|
| You should have received a copy of the GNU General Public License
|
| along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
| -#include <pthread.h>
|
| +/* RTLD_NEXT requires _GNU_SOURCE. */
|
| +#define _GNU_SOURCE 1
|
| +#include <dlfcn.h>
|
| +#include <unistd.h>
|
| +#include <fcntl.h>
|
| #include <stdlib.h>
|
| -#include <assert.h>
|
|
|
| -pthread_t thread0;
|
| -pthread_t thread1;
|
| -
|
| -static void *
|
| -start (void *arg)
|
| -{
|
| - assert (pthread_self () == thread1);
|
| -
|
| - abort ();
|
| -}
|
| -
|
| -int
|
| -main (void)
|
| +ssize_t
|
| +read (int fd, void *buf, size_t count)
|
| {
|
| - int i;
|
| -
|
| - thread0 = pthread_self ();
|
| + static ssize_t (*read2) (int fd, void *buf, size_t count) = NULL;
|
|
|
| - i = pthread_create (&thread1, NULL, start, NULL);
|
| - assert (i == 0);
|
| + if (read2 == NULL)
|
| + {
|
| + unsetenv ("LD_PRELOAD");
|
| + read2 = dlsym (RTLD_NEXT, "read");
|
| + }
|
|
|
| - i = pthread_join (thread1, NULL);
|
| - assert (i == 0);
|
| + if (count > 1 && isatty (fd) == 1)
|
| + count = 1;
|
|
|
| - return 0;
|
| + return read2 (fd, buf, count);
|
| }
|
|
|