[Lldb-commits] [lldb] r288797 - Use Timeout<> in EvaluateExpressionOptions class

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 6 03:24:52 PST 2016


Author: labath
Date: Tue Dec  6 05:24:51 2016
New Revision: 288797

URL: http://llvm.org/viewvc/llvm-project?rev=288797&view=rev
Log:
Use Timeout<> in EvaluateExpressionOptions class

Modified:
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/source/API/SBExpressionOptions.cpp
    lldb/trunk/source/Commands/CommandObjectExpression.cpp
    lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
    lldb/trunk/source/Expression/REPL.cpp
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
    lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
    lldb/trunk/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
    lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
    lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Tue Dec  6 05:24:51 2016
@@ -33,6 +33,7 @@
 #include "lldb/Target/PathMappingList.h"
 #include "lldb/Target/ProcessLaunchInfo.h"
 #include "lldb/Target/SectionLoadHistory.h"
+#include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-public.h"
 
 namespace lldb_private {
@@ -224,23 +225,11 @@ private:
 
 class EvaluateExpressionOptions {
 public:
-  static const uint32_t default_timeout = 500000;
-  static const ExecutionPolicy default_execution_policy =
+  static constexpr std::chrono::milliseconds default_timeout{500};
+  static constexpr ExecutionPolicy default_execution_policy =
       eExecutionPolicyOnlyWhenNeeded;
 
-  EvaluateExpressionOptions()
-      : m_execution_policy(default_execution_policy),
-        m_language(lldb::eLanguageTypeUnknown),
-        m_prefix(), // A prefix specific to this expression that is added after
-                    // the prefix from the settings (if any)
-        m_coerce_to_id(false), m_unwind_on_error(true),
-        m_ignore_breakpoints(false), m_keep_in_memory(false),
-        m_try_others(true), m_stop_others(true), m_debug(false),
-        m_trap_exceptions(true), m_generate_debug_info(false),
-        m_result_is_internal(false), m_auto_apply_fixits(true),
-        m_use_dynamic(lldb::eNoDynamicValues), m_timeout_usec(default_timeout),
-        m_one_thread_timeout_usec(0), m_cancel_callback(nullptr),
-        m_cancel_callback_baton(nullptr) {}
+  EvaluateExpressionOptions() = default;
 
   ExecutionPolicy GetExecutionPolicy() const { return m_execution_policy; }
 
@@ -288,14 +277,16 @@ public:
     m_use_dynamic = dynamic;
   }
 
-  uint32_t GetTimeoutUsec() const { return m_timeout_usec; }
+  const Timeout<std::micro> &GetTimeout() const { return m_timeout; }
 
-  void SetTimeoutUsec(uint32_t timeout = 0) { m_timeout_usec = timeout; }
+  void SetTimeout(const Timeout<std::micro> &timeout) { m_timeout = timeout; }
 
-  uint32_t GetOneThreadTimeoutUsec() const { return m_one_thread_timeout_usec; }
+  const Timeout<std::micro> &GetOneThreadTimeout() const {
+    return m_one_thread_timeout;
+  }
 
-  void SetOneThreadTimeoutUsec(uint32_t timeout = 0) {
-    m_one_thread_timeout_usec = timeout;
+  void SetOneThreadTimeout(const Timeout<std::micro> &timeout) {
+    m_one_thread_timeout = timeout;
   }
 
   bool GetTryAllThreads() const { return m_try_others; }
@@ -369,27 +360,27 @@ public:
   bool GetAutoApplyFixIts() const { return m_auto_apply_fixits; }
 
 private:
-  ExecutionPolicy m_execution_policy;
-  lldb::LanguageType m_language;
+  ExecutionPolicy m_execution_policy = default_execution_policy;
+  lldb::LanguageType m_language = lldb::eLanguageTypeUnknown;
   std::string m_prefix;
-  bool m_coerce_to_id;
-  bool m_unwind_on_error;
-  bool m_ignore_breakpoints;
-  bool m_keep_in_memory;
-  bool m_try_others;
-  bool m_stop_others;
-  bool m_debug;
-  bool m_trap_exceptions;
-  bool m_repl;
-  bool m_generate_debug_info;
-  bool m_ansi_color_errors;
-  bool m_result_is_internal;
-  bool m_auto_apply_fixits;
-  lldb::DynamicValueType m_use_dynamic;
-  uint32_t m_timeout_usec;
-  uint32_t m_one_thread_timeout_usec;
-  lldb::ExpressionCancelCallback m_cancel_callback;
-  void *m_cancel_callback_baton;
+  bool m_coerce_to_id = false;
+  bool m_unwind_on_error = true;
+  bool m_ignore_breakpoints = false;
+  bool m_keep_in_memory = false;
+  bool m_try_others = true;
+  bool m_stop_others = true;
+  bool m_debug = false;
+  bool m_trap_exceptions = true;
+  bool m_repl = false;
+  bool m_generate_debug_info = false;
+  bool m_ansi_color_errors = false;
+  bool m_result_is_internal = false;
+  bool m_auto_apply_fixits = true;
+  lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
+  Timeout<std::micro> m_timeout = default_timeout;
+  Timeout<std::micro> m_one_thread_timeout = llvm::None;
+  lldb::ExpressionCancelCallback m_cancel_callback = nullptr;
+  void *m_cancel_callback_baton = nullptr;
   // If m_pound_line_file is not empty and m_pound_line_line is non-zero,
   // use #line %u "%s" before the expression content to remap where the source
   // originates

Modified: lldb/trunk/source/API/SBExpressionOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBExpressionOptions.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/API/SBExpressionOptions.cpp (original)
+++ lldb/trunk/source/API/SBExpressionOptions.cpp Tue Dec  6 05:24:51 2016
@@ -67,19 +67,22 @@ void SBExpressionOptions::SetFetchDynami
 }
 
 uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
-  return m_opaque_ap->GetTimeoutUsec();
+  return m_opaque_ap->GetTimeout() ? m_opaque_ap->GetTimeout()->count() : 0;
 }
 
 void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
-  m_opaque_ap->SetTimeoutUsec(timeout);
+  m_opaque_ap->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
+                                       : std::chrono::microseconds(timeout));
 }
 
 uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
-  return m_opaque_ap->GetOneThreadTimeoutUsec();
+  return m_opaque_ap->GetOneThreadTimeout() ? m_opaque_ap->GetOneThreadTimeout()->count() : 0;
 }
 
 void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
-  m_opaque_ap->SetOneThreadTimeoutUsec(timeout);
+  m_opaque_ap->SetOneThreadTimeout(timeout == 0
+                                       ? Timeout<std::micro>(llvm::None)
+                                       : std::chrono::microseconds(timeout));
 }
 
 bool SBExpressionOptions::GetTryAllThreads() const {

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Dec  6 05:24:51 2016
@@ -358,9 +358,9 @@ bool CommandObjectExpression::EvaluateEx
       options.SetGenerateDebugInfo(true);
 
     if (m_command_options.timeout > 0)
-      options.SetTimeoutUsec(m_command_options.timeout);
+      options.SetTimeout(std::chrono::microseconds(m_command_options.timeout));
     else
-      options.SetTimeoutUsec(0);
+      options.SetTimeout(llvm::None);
 
     ExpressionResults success = target->EvaluateExpression(
         expr, frame, result_valobj_sp, options, &m_fixed_expression);

Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp Tue Dec  6 05:24:51 2016
@@ -1100,7 +1100,7 @@ protected:
     options.SetUnwindOnError(true);
     options.SetKeepInMemory(false);
     options.SetTryAllThreads(true);
-    options.SetTimeoutUsec(0);
+    options.SetTimeout(llvm::None);
 
     ExpressionResults expr_result =
         target->EvaluateExpression(expr, frame, valobj_sp, options);

Modified: lldb/trunk/source/Expression/REPL.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/REPL.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Expression/REPL.cpp (original)
+++ lldb/trunk/source/Expression/REPL.cpp Tue Dec  6 05:24:51 2016
@@ -296,9 +296,9 @@ void REPL::IOHandlerInputComplete(IOHand
       expr_options.SetPoundLine(m_repl_source_path.c_str(),
                                 m_code.GetSize() + 1);
       if (m_command_options.timeout > 0)
-        expr_options.SetTimeoutUsec(m_command_options.timeout);
+        expr_options.SetTimeout(std::chrono::microseconds(m_command_options.timeout));
       else
-        expr_options.SetTimeoutUsec(0);
+        expr_options.SetTimeout(llvm::None);
 
       expr_options.SetLanguage(GetLanguage());
 

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Dec  6 05:24:51 2016
@@ -1418,7 +1418,7 @@ Error CommandInterpreter::PreprocessComm
           options.SetIgnoreBreakpoints(true);
           options.SetKeepInMemory(false);
           options.SetTryAllThreads(true);
-          options.SetTimeoutUsec(0);
+          options.SetTimeout(llvm::None);
 
           ExpressionResults expr_result = target->EvaluateExpression(
               expr_str.c_str(), exe_ctx.GetFramePtr(), expr_result_valobj_sp,

Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp Tue Dec  6 05:24:51 2016
@@ -72,7 +72,7 @@ bool AddressSanitizerRuntime::CheckIfRun
   return symbol != nullptr;
 }
 
-#define RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC 2 * 1000 * 1000
+static constexpr std::chrono::seconds g_retrieve_report_data_function_timeout(2);
 const char *address_sanitizer_retrieve_report_data_prefix = R"(
 extern "C"
 {
@@ -127,7 +127,7 @@ StructuredData::ObjectSP AddressSanitize
   options.SetTryAllThreads(true);
   options.SetStopOthers(true);
   options.SetIgnoreBreakpoints(true);
-  options.SetTimeoutUsec(RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC);
+  options.SetTimeout(g_retrieve_report_data_function_timeout);
   options.SetPrefix(address_sanitizer_retrieve_report_data_prefix);
   options.SetAutoApplyFixIts(false);
   options.SetLanguage(eLanguageTypeObjC_plus_plus);

Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp Tue Dec  6 05:24:51 2016
@@ -59,7 +59,7 @@ lldb::InstrumentationRuntimeType ThreadS
 
 ThreadSanitizerRuntime::~ThreadSanitizerRuntime() { Deactivate(); }
 
-#define RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC 2 * 1000 * 1000
+static constexpr std::chrono::seconds g_retrieve_data_function_timeout(2);
 
 const char *thread_sanitizer_retrieve_report_data_prefix = R"(
 extern "C"
@@ -308,7 +308,7 @@ ThreadSanitizerRuntime::RetrieveReportDa
   options.SetTryAllThreads(true);
   options.SetStopOthers(true);
   options.SetIgnoreBreakpoints(true);
-  options.SetTimeoutUsec(RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC);
+  options.SetTimeout(g_retrieve_data_function_timeout);
   options.SetPrefix(thread_sanitizer_retrieve_report_data_prefix);
   options.SetAutoApplyFixIts(false);
   options.SetLanguage(eLanguageTypeObjC_plus_plus);

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Tue Dec  6 05:24:51 2016
@@ -40,7 +40,7 @@
 using namespace lldb;
 using namespace lldb_private;
 
-#define PO_FUNCTION_TIMEOUT_USEC 15 * 1000 * 1000
+static constexpr std::chrono::seconds g_po_function_timeout(15);
 
 AppleObjCRuntime::~AppleObjCRuntime() {}
 
@@ -169,7 +169,7 @@ bool AppleObjCRuntime::GetObjectDescript
   options.SetTryAllThreads(true);
   options.SetStopOthers(true);
   options.SetIgnoreBreakpoints(true);
-  options.SetTimeoutUsec(PO_FUNCTION_TIMEOUT_USEC);
+  options.SetTimeout(g_po_function_timeout);
 
   ExpressionResults results = m_print_object_caller_up->ExecuteFunction(
       exe_ctx, &wrapper_struct_addr, options, diagnostics, ret);

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Tue Dec  6 05:24:51 2016
@@ -66,7 +66,7 @@ using namespace lldb;
 using namespace lldb_private;
 
 // 2 second timeout when running utility functions
-#define UTILITY_FUNCTION_TIMEOUT_USEC 2 * 1000 * 1000
+static constexpr std::chrono::seconds g_utility_function_timeout(2);
 
 static const char *g_get_dynamic_class_info_name =
     "__lldb_apple_objc_v2_get_dynamic_class_info";
@@ -1411,7 +1411,7 @@ AppleObjCRuntimeV2::UpdateISAToDescripto
     options.SetTryAllThreads(false);
     options.SetStopOthers(true);
     options.SetIgnoreBreakpoints(true);
-    options.SetTimeoutUsec(UTILITY_FUNCTION_TIMEOUT_USEC);
+    options.SetTimeout(g_utility_function_timeout);
 
     Value return_value;
     return_value.SetValueType(Value::eValueTypeScalar);
@@ -1656,7 +1656,7 @@ AppleObjCRuntimeV2::UpdateISAToDescripto
     options.SetTryAllThreads(false);
     options.SetStopOthers(true);
     options.SetIgnoreBreakpoints(true);
-    options.SetTimeoutUsec(UTILITY_FUNCTION_TIMEOUT_USEC);
+    options.SetTimeout(g_utility_function_timeout);
 
     Value return_value;
     return_value.SetValueType(Value::eValueTypeScalar);

Modified: lldb/trunk/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp (original)
+++ lldb/trunk/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp Tue Dec  6 05:24:51 2016
@@ -149,7 +149,7 @@ static void CreateHistoryThreadFromValue
   result.push_back(new_thread_sp);
 }
 
-#define GET_STACK_FUNCTION_TIMEOUT_USEC 2 * 1000 * 1000
+static constexpr std::chrono::seconds g_get_stack_function_timeout(2);
 
 HistoryThreads MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address) {
   HistoryThreads result;
@@ -178,7 +178,7 @@ HistoryThreads MemoryHistoryASan::GetHis
   options.SetTryAllThreads(true);
   options.SetStopOthers(true);
   options.SetIgnoreBreakpoints(true);
-  options.SetTimeoutUsec(GET_STACK_FUNCTION_TIMEOUT_USEC);
+  options.SetTimeout(g_get_stack_function_timeout);
   options.SetPrefix(memory_history_asan_command_prefix);
   options.SetAutoApplyFixIts(false);
   options.SetLanguage(eLanguageTypeObjC_plus_plus);

Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Tue Dec  6 05:24:51 2016
@@ -734,7 +734,7 @@ Error PlatformPOSIX::EvaluateLibdlExpres
   expr_options.SetLanguage(eLanguageTypeC_plus_plus);
   expr_options.SetTrapExceptions(false); // dlopen can't throw exceptions, so
                                          // don't do the work to trap them.
-  expr_options.SetTimeoutUsec(2000000);  // 2 seconds
+  expr_options.SetTimeout(std::chrono::seconds(2));
 
   Error expr_error;
   ExpressionResults result =

Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Tue Dec  6 05:24:51 2016
@@ -61,7 +61,7 @@ bool lldb_private::InferiorCallMmap(Proc
       options.SetIgnoreBreakpoints(true);
       options.SetTryAllThreads(true);
       options.SetDebug(false);
-      options.SetTimeoutUsec(500000);
+      options.SetTimeout(std::chrono::milliseconds(500));
       options.SetTrapExceptions(false);
 
       addr_t prot_arg, flags_arg = 0;
@@ -151,7 +151,7 @@ bool lldb_private::InferiorCallMunmap(Pr
       options.SetIgnoreBreakpoints(true);
       options.SetTryAllThreads(true);
       options.SetDebug(false);
-      options.SetTimeoutUsec(500000);
+      options.SetTimeout(std::chrono::milliseconds(500));
       options.SetTrapExceptions(false);
 
       AddressRange munmap_range;
@@ -200,7 +200,7 @@ bool lldb_private::InferiorCall(Process
   options.SetIgnoreBreakpoints(true);
   options.SetTryAllThreads(true);
   options.SetDebug(false);
-  options.SetTimeoutUsec(500000);
+  options.SetTimeout(std::chrono::milliseconds(500));
   options.SetTrapExceptions(trap_exceptions);
 
   ClangASTContext *clang_ast_context =

Modified: lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp Tue Dec  6 05:24:51 2016
@@ -340,7 +340,7 @@ AppleGetItemInfoHandler::GetItemInfo(Thr
   options.SetUnwindOnError(true);
   options.SetIgnoreBreakpoints(true);
   options.SetStopOthers(true);
-  options.SetTimeoutUsec(500000);
+  options.SetTimeout(std::chrono::milliseconds(500));
   options.SetTryAllThreads(false);
   thread.CalculateExecutionContext(exe_ctx);
 

Modified: lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp Tue Dec  6 05:24:51 2016
@@ -351,7 +351,7 @@ AppleGetPendingItemsHandler::GetPendingI
   options.SetUnwindOnError(true);
   options.SetIgnoreBreakpoints(true);
   options.SetStopOthers(true);
-  options.SetTimeoutUsec(500000);
+  options.SetTimeout(std::chrono::milliseconds(500));
   options.SetTryAllThreads(false);
   thread.CalculateExecutionContext(exe_ctx);
 

Modified: lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp Tue Dec  6 05:24:51 2016
@@ -357,7 +357,7 @@ AppleGetQueuesHandler::GetCurrentQueues(
   options.SetUnwindOnError(true);
   options.SetIgnoreBreakpoints(true);
   options.SetStopOthers(true);
-  options.SetTimeoutUsec(500000);
+  options.SetTimeout(std::chrono::milliseconds(500));
   options.SetTryAllThreads(false);
   thread.CalculateExecutionContext(exe_ctx);
 

Modified: lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp Tue Dec  6 05:24:51 2016
@@ -355,7 +355,7 @@ AppleGetThreadItemInfoHandler::GetThread
   options.SetUnwindOnError(true);
   options.SetIgnoreBreakpoints(true);
   options.SetStopOthers(true);
-  options.SetTimeoutUsec(500000);
+  options.SetTimeout(std::chrono::milliseconds(500));
   options.SetTryAllThreads(false);
   thread.CalculateExecutionContext(exe_ctx);
 

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Tue Dec  6 05:24:51 2016
@@ -70,18 +70,8 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace std::chrono;
 
-// A temporary function to convert between old representations of timeouts (0
-// means infinite wait) and new Timeout class (0 means "poll").
-// TODO(labath): Fix up all callers and remove this.
-static Timeout<std::micro> ConvertTimeout(std::chrono::microseconds t) {
-  if (t == std::chrono::microseconds(0))
-    return llvm::None;
-  return t;
-}
-
 // Comment out line below to disable memory caching, overriding the process
-// setting
-// target.process.disable-memory-cache
+// setting target.process.disable-memory-cache
 #define ENABLE_MEMORY_CACHING
 
 #ifdef ENABLE_MEMORY_CACHING
@@ -4805,20 +4795,19 @@ GetOneThreadExpressionTimeout(const Eval
   const milliseconds default_one_thread_timeout(250);
 
   // If the overall wait is forever, then we don't need to worry about it.
-  if (options.GetTimeoutUsec() == 0) {
-    if (options.GetOneThreadTimeoutUsec() != 0)
-      return microseconds(options.GetOneThreadTimeoutUsec());
-    return default_one_thread_timeout;
+  if (!options.GetTimeout()) {
+    return options.GetOneThreadTimeout() ? *options.GetOneThreadTimeout()
+                                         : default_one_thread_timeout;
   }
 
   // If the one thread timeout is set, use it.
-  if (options.GetOneThreadTimeoutUsec() != 0)
-    return microseconds(options.GetOneThreadTimeoutUsec());
+  if (options.GetOneThreadTimeout())
+    return *options.GetOneThreadTimeout();
 
   // Otherwise use half the total timeout, bounded by the
   // default_one_thread_timeout.
   return std::min<microseconds>(default_one_thread_timeout,
-                                microseconds(options.GetTimeoutUsec()) / 2);
+                                *options.GetTimeout() / 2);
 }
 
 static Timeout<std::micro>
@@ -4827,16 +4816,15 @@ GetExpressionTimeout(const EvaluateExpre
   // If we are going to run all threads the whole time, or if we are only
   // going to run one thread, we can just return the overall timeout.
   if (!options.GetStopOthers() || !options.GetTryAllThreads())
-    return ConvertTimeout(microseconds(options.GetTimeoutUsec()));
+    return options.GetTimeout();
 
   if (before_first_timeout)
     return GetOneThreadExpressionTimeout(options);
 
-  if (options.GetTimeoutUsec() == 0)
+  if (!options.GetTimeout())
     return llvm::None;
   else
-    return microseconds(options.GetTimeoutUsec()) -
-           GetOneThreadExpressionTimeout(options);
+    return *options.GetTimeout() - GetOneThreadExpressionTimeout(options);
 }
 
 ExpressionResults
@@ -4921,8 +4909,8 @@ Process::RunThreadPlan(ExecutionContext
 
   // Make sure the timeout values make sense. The one thread timeout needs to be
   // smaller than the overall timeout.
-  if (options.GetOneThreadTimeoutUsec() != 0 && options.GetTimeoutUsec() != 0 &&
-      options.GetTimeoutUsec() < options.GetOneThreadTimeoutUsec()) {
+  if (options.GetOneThreadTimeout() && options.GetTimeout() &&
+      *options.GetTimeout() < *options.GetOneThreadTimeout()) {
     diagnostic_manager.PutString(eDiagnosticSeverityError,
                                  "RunThreadPlan called with one thread "
                                  "timeout greater than total timeout");

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=288797&r1=288796&r2=288797&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Tue Dec  6 05:24:51 2016
@@ -62,6 +62,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
+constexpr std::chrono::milliseconds EvaluateExpressionOptions::default_timeout;
+
 ConstString &Target::GetStaticBroadcasterClass() {
   static ConstString class_name("lldb.target");
   return class_name;




More information about the lldb-commits mailing list