Make RunThreadPlan start the timeout clock for each part of the expression evaluation AFTER the

successful resume for that part.  This will make the timeouts more stable when lldb is running
in a busy program.

llvm-svn: 206835
This commit is contained in:
Jim Ingham 2014-04-22 01:41:52 +00:00
parent d4f44690ef
commit fd95f8961e
1 changed files with 31 additions and 17 deletions

View File

@ -5198,10 +5198,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
// This is just for accounting: // This is just for accounting:
uint32_t num_resumes = 0; uint32_t num_resumes = 0;
TimeValue one_thread_timeout = TimeValue::Now();
TimeValue final_timeout = one_thread_timeout;
uint32_t timeout_usec = options.GetTimeoutUsec(); uint32_t timeout_usec = options.GetTimeoutUsec();
uint32_t one_thread_timeout_usec;
uint32_t all_threads_timeout_usec = 0;
// If we are going to run all threads the whole time, or if we are only going to run one thread, // If we are going to run all threads the whole time, or if we are only going to run one thread,
// then we don't need the first timeout. So we set the final timeout, and pretend we are after the // then we don't need the first timeout. So we set the final timeout, and pretend we are after the
@ -5210,19 +5209,20 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (!options.GetStopOthers() || !options.GetTryAllThreads()) if (!options.GetStopOthers() || !options.GetTryAllThreads())
{ {
before_first_timeout = false; before_first_timeout = false;
final_timeout.OffsetWithMicroSeconds(timeout_usec); one_thread_timeout_usec = 0;
all_threads_timeout_usec = timeout_usec;
} }
else else
{ {
uint64_t option_one_thread_timeout = options.GetOneThreadTimeoutUsec(); uint32_t option_one_thread_timeout = options.GetOneThreadTimeoutUsec();
// If the overall wait is forever, then we only need to set the one thread timeout: // If the overall wait is forever, then we only need to set the one thread timeout:
if (timeout_usec == 0) if (timeout_usec == 0)
{ {
if (option_one_thread_timeout != 0) if (option_one_thread_timeout != 0)
one_thread_timeout.OffsetWithMicroSeconds(option_one_thread_timeout); one_thread_timeout_usec = option_one_thread_timeout;
else else
one_thread_timeout.OffsetWithMicroSeconds(default_one_thread_timeout_usec); one_thread_timeout_usec = default_one_thread_timeout_usec;
} }
else else
{ {
@ -5244,19 +5244,19 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (computed_one_thread_timeout > default_one_thread_timeout_usec) if (computed_one_thread_timeout > default_one_thread_timeout_usec)
computed_one_thread_timeout = default_one_thread_timeout_usec; computed_one_thread_timeout = default_one_thread_timeout_usec;
} }
one_thread_timeout.OffsetWithMicroSeconds(computed_one_thread_timeout); one_thread_timeout_usec = computed_one_thread_timeout;
all_threads_timeout_usec = timeout_usec - one_thread_timeout_usec;
} }
final_timeout.OffsetWithMicroSeconds (timeout_usec);
} }
if (log) if (log)
log->Printf ("Stop others: %u, try all: %u, one thread: %" PRIu64 " - all threads: %" PRIu64 ".\n", log->Printf ("Stop others: %u, try all: %u, before_first: %u, one thread: %" PRIu32 " - all threads: %" PRIu32 ".\n",
options.GetStopOthers(), options.GetStopOthers(),
options.GetTryAllThreads(), options.GetTryAllThreads(),
one_thread_timeout.GetAsMicroSecondsSinceJan1_1970(), before_first_timeout,
final_timeout.GetAsMicroSecondsSinceJan1_1970()); one_thread_timeout_usec,
all_threads_timeout_usec);
// This isn't going to work if there are unfetched events on the queue. // This isn't going to work if there are unfetched events on the queue.
// Are there cases where we might want to run the remaining events here, and then try to // Are there cases where we might want to run the remaining events here, and then try to
@ -5286,6 +5286,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
// The expression evaluation should still succeed. // The expression evaluation should still succeed.
bool miss_first_event = true; bool miss_first_event = true;
#endif #endif
TimeValue one_thread_timeout;
TimeValue final_timeout;
while (1) while (1)
{ {
@ -5380,13 +5383,21 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (before_first_timeout) if (before_first_timeout)
{ {
if (options.GetTryAllThreads()) if (options.GetTryAllThreads())
{
one_thread_timeout = TimeValue::Now();
one_thread_timeout.OffsetWithMicroSeconds(one_thread_timeout_usec);
timeout_ptr = &one_thread_timeout; timeout_ptr = &one_thread_timeout;
}
else else
{ {
if (timeout_usec == 0) if (timeout_usec == 0)
timeout_ptr = NULL; timeout_ptr = NULL;
else else
{
final_timeout = TimeValue::Now();
final_timeout.OffsetWithMicroSeconds (timeout_usec);
timeout_ptr = &final_timeout; timeout_ptr = &final_timeout;
}
} }
} }
else else
@ -5394,7 +5405,11 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (timeout_usec == 0) if (timeout_usec == 0)
timeout_ptr = NULL; timeout_ptr = NULL;
else else
{
final_timeout = TimeValue::Now();
final_timeout.OffsetWithMicroSeconds (all_threads_timeout_usec);
timeout_ptr = &final_timeout; timeout_ptr = &final_timeout;
}
} }
do_resume = true; do_resume = true;
@ -5569,10 +5584,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{ {
if (timeout_usec != 0) if (timeout_usec != 0)
{ {
uint64_t remaining_time = final_timeout - TimeValue::Now();
log->Printf ("Process::RunThreadPlan(): Running function with one thread timeout timed out, " log->Printf ("Process::RunThreadPlan(): Running function with one thread timeout timed out, "
"running for %" PRIu64 " usec with all threads enabled.", "running for %" PRIu32 " usec with all threads enabled.",
remaining_time); all_threads_timeout_usec);
} }
else else
{ {