summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2014-03-28 21:58:28 +0000
committerJim Ingham <jingham@apple.com>2014-03-28 21:58:28 +0000
commit914f4e7092ff922901b2fb5d7a9b7103f8f616ea (patch)
tree0a6a4b902cad7bd42d8289358910c711725c3941
parentdca7c7c5f12b6319813cadd7b159d1f5fd8f4323 (diff)
downloadbcm5719-llvm-914f4e7092ff922901b2fb5d7a9b7103f8f616ea.tar.gz
bcm5719-llvm-914f4e7092ff922901b2fb5d7a9b7103f8f616ea.zip
Add the ability from the SB API's to set the "one thread" timeout
for expression evaluations that try one and then all threads. <rdar://problem/15598528> llvm-svn: 205060
-rw-r--r--lldb/include/lldb/API/SBExpressionOptions.h10
-rw-r--r--lldb/include/lldb/Target/Target.h19
-rw-r--r--lldb/scripts/Python/interface/SBExpressionOptions.i7
-rw-r--r--lldb/source/API/SBExpressionOptions.cpp12
-rw-r--r--lldb/source/Target/Process.cpp38
-rw-r--r--lldb/test/expression_command/timeout/TestCallWithTimeout.py10
6 files changed, 86 insertions, 10 deletions
diff --git a/lldb/include/lldb/API/SBExpressionOptions.h b/lldb/include/lldb/API/SBExpressionOptions.h
index ac5ce952a62..f0cf8c544af 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -56,9 +56,19 @@ public:
uint32_t
GetTimeoutInMicroSeconds () const;
+ // Set the timeout for the expression, 0 means wait forever.
void
SetTimeoutInMicroSeconds (uint32_t timeout = 0);
+ uint32_t
+ GetOneThreadTimeoutInMicroSeconds () const;
+
+ // Set the timeout for running on one thread, 0 means use the default behavior.
+ // If you set this higher than the overall timeout, you'll get an error when you
+ // try to run the expression.
+ void
+ SetOneThreadTimeoutInMicroSeconds (uint32_t timeout = 0);
+
bool
GetTryAllThreads () const;
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 85d283df391..efe9584eb22 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -203,8 +203,10 @@ public:
m_trap_exceptions(true),
m_generate_debug_info(false),
m_use_dynamic(lldb::eNoDynamicValues),
- m_timeout_usec(default_timeout)
- {}
+ m_timeout_usec(default_timeout),
+ m_one_thread_timeout_usec(0)
+ {
+ }
ExecutionPolicy
GetExecutionPolicy () const
@@ -302,6 +304,18 @@ public:
m_timeout_usec = timeout;
}
+ uint32_t
+ GetOneThreadTimeoutUsec () const
+ {
+ return m_one_thread_timeout_usec;
+ }
+
+ void
+ SetOneThreadTimeoutUsec (uint32_t timeout = 0)
+ {
+ m_one_thread_timeout_usec = timeout;
+ }
+
bool
GetTryAllThreads () const
{
@@ -378,6 +392,7 @@ private:
bool m_generate_debug_info;
lldb::DynamicValueType m_use_dynamic;
uint32_t m_timeout_usec;
+ uint32_t m_one_thread_timeout_usec;
};
//----------------------------------------------------------------------
diff --git a/lldb/scripts/Python/interface/SBExpressionOptions.i b/lldb/scripts/Python/interface/SBExpressionOptions.i
index 28541084197..46f464f2c58 100644
--- a/lldb/scripts/Python/interface/SBExpressionOptions.i
+++ b/lldb/scripts/Python/interface/SBExpressionOptions.i
@@ -64,6 +64,13 @@ public:
void
SetTimeoutInMicroSeconds (uint32_t timeout = 0);
+ uint32_t
+ GetOneThreadTimeoutInMicroSeconds () const;
+
+ %feature("docstring", "Sets the timeout in microseconds to run the expression on one thread before either timing out or trying all threads.") SetTimeoutInMicroSeconds;
+ void
+ SetOneThreadTimeoutInMicroSeconds (uint32_t timeout = 0);
+
bool
GetTryAllThreads () const;
diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp
index b426cd1845f..3ba9ab07e78 100644
--- a/lldb/source/API/SBExpressionOptions.cpp
+++ b/lldb/source/API/SBExpressionOptions.cpp
@@ -101,6 +101,18 @@ SBExpressionOptions::SetTimeoutInMicroSeconds (uint32_t timeout)
m_opaque_ap->SetTimeoutUsec (timeout);
}
+uint32_t
+SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds () const
+{
+ return m_opaque_ap->GetOneThreadTimeoutUsec ();
+}
+
+void
+SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds (uint32_t timeout)
+{
+ m_opaque_ap->SetOneThreadTimeoutUsec (timeout);
+}
+
bool
SBExpressionOptions::GetTryAllThreads () const
{
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 32dda344a0f..3231e1edc08 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5168,6 +5168,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
TimeValue final_timeout = one_thread_timeout;
uint32_t timeout_usec = options.GetTimeoutUsec();
+
if (!options.GetStopOthers())
{
before_first_timeout = false;
@@ -5175,16 +5176,37 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
}
else if (options.GetTryAllThreads())
{
- // If we are running all threads then we take half the time to run all threads, bounded by
- // .25 sec.
- if (options.GetTimeoutUsec() == 0)
- one_thread_timeout.OffsetWithMicroSeconds(default_one_thread_timeout_usec);
+ uint64_t option_one_thread_timeout = options.GetOneThreadTimeoutUsec();
+
+ // If the overall wait is forever, then we only need to set the one thread timeout:
+ if (timeout_usec == 0)
+ {
+ if (option_one_thread_timeout == 0)
+ one_thread_timeout.OffsetWithMicroSeconds(option_one_thread_timeout);
+ else
+ one_thread_timeout.OffsetWithMicroSeconds(default_one_thread_timeout_usec);
+ }
else
{
- uint64_t computed_timeout = timeout_usec / 2;
- if (computed_timeout > default_one_thread_timeout_usec)
- computed_timeout = default_one_thread_timeout_usec;
- one_thread_timeout.OffsetWithMicroSeconds(computed_timeout);
+ // Otherwise, if the one thread timeout is set, make sure it isn't longer than the overall timeout,
+ // and use it, otherwise use half the total timeout, bounded by the default_one_thread_timeout_usec.
+ uint64_t computed_one_thread_timeout;
+ if (option_one_thread_timeout != 0)
+ {
+ if (timeout_usec < option_one_thread_timeout)
+ {
+ errors.Printf("RunThreadPlan called without one thread timeout greater than total timeout");
+ return eExecutionSetupError;
+ }
+ computed_one_thread_timeout = option_one_thread_timeout;
+ }
+ else
+ {
+ computed_one_thread_timeout = timeout_usec / 2;
+ if (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);
}
final_timeout.OffsetWithMicroSeconds (timeout_usec);
}
diff --git a/lldb/test/expression_command/timeout/TestCallWithTimeout.py b/lldb/test/expression_command/timeout/TestCallWithTimeout.py
index 10d8702dc07..e6bf316c7d0 100644
--- a/lldb/test/expression_command/timeout/TestCallWithTimeout.py
+++ b/lldb/test/expression_command/timeout/TestCallWithTimeout.py
@@ -87,6 +87,16 @@ class ExprCommandWithTimeoutsTestCase(TestBase):
return_value = interp.HandleCommand ("expr -t 1000000 -u true -- wait_a_while(1000)", result)
self.assertTrue(return_value == lldb.eReturnStatusSuccessFinishResult)
+
+ # Finally set the one thread timeout and make sure that doesn't change things much:
+
+ options.SetTimeoutInMicroSeconds(1000000)
+ options.SetOneThreadTimeoutInMicroSeconds(500000)
+ value = frame.EvaluateExpression ("wait_a_while (1000)", options)
+ self.assertTrue(value.IsValid())
+ self.assertTrue (value.GetError().Success() == True)
+
+
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
OpenPOWER on IntegriCloud