X-Git-Url: http://git.jankratochvil.net/?p=debugger.git;a=blobdiff_plain;f=testsuite.c;fp=testsuite.c;h=cb11a535fcd447a143587cf13bc87524e97f7bfc;hp=9fa2a6421b3cff797c0a16e35a7a70f1801949c1;hb=e22c060c8eea5a383c3d934aacb183202d568f63;hpb=9c53604dfe1f2625c81c34fe0270bd3ef9083262 diff --git a/testsuite.c b/testsuite.c index 9fa2a64..cb11a53 100644 --- a/testsuite.c +++ b/testsuite.c @@ -28,6 +28,24 @@ #define tkill(tid, sig) syscall (SYS_tkill, (tid), (sig)) +static void detach_checked (struct attach_state_struct *attach_state) +{ + pid_t pid = attach_state_pid_get (attach_state); + + if (attach_state_stopped_get (attach_state) != 0) + { + STATE (pid, 1 << STATE_STOPPED); + detach (attach_state); + STATE (pid, 1 << STATE_STOPPED); + } + else + { + STATE (pid, (1 << STATE_PTRACED)); + detach (attach_state); + STATE (pid, ((1 << STATE_SLEEPING) | (1 << STATE_RUNNING))); + } +} + static volatile int spawned_threads_count; /* Set for the specific spawner. */ static struct attach_state_struct *attach_checked (pid_t pid, int redelivered_expect) @@ -50,38 +68,23 @@ static struct attach_state_struct *attach_checked (pid_t pid, int redelivered_ex if (attach_state_threads_count_get (attach_state) == spawned_threads_count) break; + fprintf (stderr, "FIXME: Untested threads initialization - REMOVE.\n"); /* During the inferior's initialization we may catch less threads. */ assert (attach_state_threads_count_get (attach_state) < spawned_threads_count); /* WARNING: Currently we never use REDELIVERED_EXPECT but we would have to probably reset it back to 0 otherwise. */ assert (redelivered_expect == 0); + detach_checked (attach_state); } while (loops++ < LOOPS_MIN || time (NULL) < timeout); + assert (attach_state_threads_count_get (attach_state) == spawned_threads_count); /* FIXME: Why also STATE_STOPPED? */ STATE (pid, (1 << STATE_PTRACED) | (1 << STATE_STOPPED)); return attach_state; } -static void detach_checked (struct attach_state_struct *attach_state) -{ - pid_t pid = attach_state_pid_get (attach_state); - - if (attach_state_stopped_get (attach_state) != 0) - { - STATE (pid, 1 << STATE_STOPPED); - detach (attach_state); - STATE (pid, 1 << STATE_STOPPED); - } - else - { - STATE (pid, (1 << STATE_PTRACED)); - detach (attach_state); - STATE (pid, ((1 << STATE_SLEEPING) | (1 << STATE_RUNNING))); - } -} - struct registry { struct registry *next;