Skip to content

Commit 40ee301

Browse files
author
git apple-llvm automerger
committed
Merge commit '8ccf402c149d' from swift/release/6.0 into stable/20230725
2 parents 3f46759 + 8ccf402 commit 40ee301

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

lldb/test/API/api/multiple-debuggers/multi-process-driver.cpp

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,22 @@ void *do_one_debugger (void *in)
216216
return (void*) 1;
217217
}
218218

219+
int count_completed_threads(int num_threads) {
220+
int num_completed_threads = 0;
221+
for (int i = 0; i < num_threads; i++)
222+
if (completed_threads_array[i])
223+
num_completed_threads++;
224+
return num_completed_threads;
225+
}
226+
227+
int count_successful_threads(int num_threads) {
228+
int num_successful_threads = 0;
229+
for (int i = 0; i < num_threads; i++)
230+
if (successful_threads_array[i])
231+
num_successful_threads++;
232+
return num_successful_threads;
233+
}
234+
219235
int main (int argc, char **argv)
220236
{
221237
#if !defined(_MSC_VER)
@@ -241,26 +257,15 @@ int main (int argc, char **argv)
241257
}
242258

243259

244-
int max_time_to_wait = 20; // 20 iterations, or 60 seconds
245-
int iter = 0;
246-
while (1)
247-
{
260+
int max_time_to_wait = 40; // 40 iterations, or 120 seconds
261+
if (getenv("ASAN_OPTIONS"))
262+
max_time_to_wait *= 4;
263+
for (int iter = 0; iter < max_time_to_wait; iter++) {
248264
std::this_thread::sleep_for(std::chrono::seconds(3));
249-
bool all_done = true;
250-
int successful_threads = 0;
251-
int total_completed_threads = 0;
252-
for (uint64_t i = 0; i < NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS; i++)
253-
{
254-
if (successful_threads_array[i] == true)
255-
successful_threads++;
256-
if (completed_threads_array[i] == true)
257-
total_completed_threads++;
258-
if (completed_threads_array[i] == false)
259-
{
260-
all_done = false;
261-
}
262-
}
263-
if (all_done)
265+
int successful_threads = count_successful_threads(NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
266+
int total_completed_threads = count_completed_threads(NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
267+
268+
if (total_completed_threads == NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS)
264269
{
265270
#if DEBUG == 1
266271
printf ("All threads completed.\n");
@@ -275,14 +280,14 @@ int main (int argc, char **argv)
275280
printf ("%d threads completed so far (%d successfully), out of %d\n", total_completed_threads, successful_threads, NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
276281
#endif
277282
}
278-
if (iter++ == max_time_to_wait)
279-
{
280-
printf ("reached maximum timeout but only %d threads have completed so far (%d successfully), out of %d. Exiting.\n", total_completed_threads, successful_threads, NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
281-
break;
282-
}
283+
if (iter == max_time_to_wait)
284+
printf("reached maximum timeout but only %d threads have completed "
285+
"so far "
286+
"(%d successfully), out of %d. Exiting.\n",
287+
total_completed_threads, successful_threads,
288+
NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
283289
}
284290

285-
286291
SBDebugger::Terminate();
287292
exit (1);
288293
}

0 commit comments

Comments
 (0)