Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions lldb/test/API/api/multiple-debuggers/multi-process-driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ void *do_one_debugger (void *in)
return (void*) 1;
}

int count_completed_threads(int num_threads) {
int num_completed_threads = 0;
for (int i = 0; i < num_threads; i++)
if (completed_threads_array[i] == true)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (completed_threads_array[i] == true)
if (completed_threads_array[i])

num_completed_threads++;
return num_completed_threads;
}

int count_successful_threads(int num_threads) {
int num_successful_threads = 0;
for (int i = 0; i < num_threads; i++)
if (successful_threads_array[i] == true)
num_successful_threads++;
return num_successful_threads;
}

int main (int argc, char **argv)
{
#if !defined(_MSC_VER)
Expand All @@ -241,26 +257,13 @@ int main (int argc, char **argv)
}


int max_time_to_wait = 20; // 20 iterations, or 60 seconds
int iter = 0;
while (1)
{
int max_time_to_wait = 40; // 40 iterations, or 120 seconds

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually multiply all timeouts by a factor 10 when running under ASAN. A reasonably proxy for that would be if getenv("ASAN_OPTIONS") returns a nonempty string, because lit sets that environment variable.

for (int iter = 0; iter < max_time_to_wait; iter++) {
std::this_thread::sleep_for(std::chrono::seconds(3));
bool all_done = true;
int successful_threads = 0;
int total_completed_threads = 0;
for (uint64_t i = 0; i < NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS; i++)
{
if (successful_threads_array[i] == true)
successful_threads++;
if (completed_threads_array[i] == true)
total_completed_threads++;
if (completed_threads_array[i] == false)
{
all_done = false;
}
}
if (all_done)
int successful_threads = count_successful_threads(NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
int total_completed_threads = count_completed_threads(NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);

if (total_completed_threads == NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS)
{
#if DEBUG == 1
printf ("All threads completed.\n");
Expand All @@ -275,14 +278,14 @@ int main (int argc, char **argv)
printf ("%d threads completed so far (%d successfully), out of %d\n", total_completed_threads, successful_threads, NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
#endif
}
if (iter++ == max_time_to_wait)
{
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);
break;
}
if (iter == max_time_to_wait)
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);
}


SBDebugger::Terminate();
exit (1);
}