Index: gdb/testsuite/gdb.threads/clone-new-thread-event.c |
diff --git a/gdb/testsuite/gdb.threads/current-lwp-dead.c b/gdb/testsuite/gdb.threads/clone-new-thread-event.c |
similarity index 63% |
copy from gdb/testsuite/gdb.threads/current-lwp-dead.c |
copy to gdb/testsuite/gdb.threads/clone-new-thread-event.c |
index 138c350f1fec87fcfe1de79f2926b246d10bbbe0..5855ad961b29659f1a563ed9637a795a0ac0a308 100644 |
--- a/gdb/testsuite/gdb.threads/current-lwp-dead.c |
+++ b/gdb/testsuite/gdb.threads/clone-new-thread-event.c |
@@ -15,20 +15,17 @@ |
You should have received a copy of the GNU General Public License |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
- Do not use threads as we need to exploit a bug in LWP code masked by the |
- threads code otherwise. |
- |
- INFERIOR_PTID must point to exited LWP. Here we use the initial LWP as it |
- is automatically INFERIOR_PTID for GDB. |
- |
- Finally we need to call target_resume (RESUME_ALL, ...) which we invoke by |
- NEW_THREAD_EVENT (called from the new LWP as initial LWP is exited now). */ |
+ Test that GDB doesn't lose an event for a thread it didn't know |
+ about, until an event is reported for it. */ |
#define _GNU_SOURCE |
#include <sched.h> |
#include <assert.h> |
-#include <unistd.h> |
#include <stdlib.h> |
+#include <signal.h> |
+#include <sys/types.h> |
+#include <unistd.h> |
+#include <sys/syscall.h> |
#include <features.h> |
#ifdef __UCLIBC__ |
@@ -40,31 +37,21 @@ |
#define STACK_SIZE 0x1000 |
static int |
-fn_return (void *unused) |
+tkill (int lwpid, int signo) |
+{ |
+ return syscall (__NR_tkill, lwpid, signo); |
+} |
+ |
+static pid_t |
+gettid (void) |
{ |
- return 0; /* at-fn_return */ |
+ return syscall (__NR_gettid); |
} |
static int |
fn (void *unused) |
{ |
- int i; |
- unsigned char *stack; |
- int new_pid; |
- |
- i = sleep (1); |
- assert (i == 0); |
- |
- stack = malloc (STACK_SIZE); |
- assert (stack != NULL); |
- |
- new_pid = clone (fn_return, stack + STACK_SIZE, CLONE_FILES |
-#if defined(__UCLIBC__) && defined(HAS_NOMMU) |
- | CLONE_VM |
-#endif /* defined(__UCLIBC__) && defined(HAS_NOMMU) */ |
- , NULL, NULL, NULL, NULL); |
- assert (new_pid > 0); |
- |
+ tkill (gettid (), SIGUSR1); |
return 0; |
} |