diff options
author | Pavel Labath <labath@google.com> | 2016-12-06 11:24:51 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2016-12-06 11:24:51 +0000 |
commit | 43d354182f44fac52247a4340462e7471e59a00a (patch) | |
tree | 2caef34124c24c3bf8d636da465758edfdc3cce3 | |
parent | 9335c020c61addbcb8de944d3f44dbfa4a1abafc (diff) | |
download | bcm5719-llvm-43d354182f44fac52247a4340462e7471e59a00a.tar.gz bcm5719-llvm-43d354182f44fac52247a4340462e7471e59a00a.zip |
Use Timeout<> in EvaluateExpressionOptions class
llvm-svn: 288797
19 files changed, 77 insertions, 93 deletions
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 224af6fcb70..5588bdc1594 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -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 diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp index 218d93e96c3..e26fa11651e 100644 --- a/lldb/source/API/SBExpressionOptions.cpp +++ b/lldb/source/API/SBExpressionOptions.cpp @@ -67,19 +67,22 @@ void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) { } 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 { diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index ba477cd5f4c..cfb3a6dd511 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -358,9 +358,9 @@ bool CommandObjectExpression::EvaluateExpression(const char *expr, 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); diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index f143f5ff28d..baa9f4163a6 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -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); diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp index 7c3cd7e3d43..e404537562b 100644 --- a/lldb/source/Expression/REPL.cpp +++ b/lldb/source/Expression/REPL.cpp @@ -296,9 +296,9 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { 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()); diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 36651519eb9..bb23d9884a8 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1418,7 +1418,7 @@ Error CommandInterpreter::PreprocessCommand(std::string &command) { 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, diff --git a/lldb/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp index 2f82328864a..db626b06615 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp @@ -72,7 +72,7 @@ bool AddressSanitizerRuntime::CheckIfRuntimeIsValid( 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 AddressSanitizerRuntime::RetrieveReportData() { 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); diff --git a/lldb/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp index 84c8b6443f7..3010724306e 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp @@ -59,7 +59,7 @@ lldb::InstrumentationRuntimeType ThreadSanitizerRuntime::GetTypeStatic() { 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::RetrieveReportData(ExecutionContextRef exe_ctx_ref) { 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); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 24eddb51600..4a90f5c1663 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -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::GetObjectDescription(Stream &strm, Value &value, 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); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 47bf4acd497..e9958a5ef75 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -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::UpdateISAToDescriptorMapDynamic( 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::UpdateISAToDescriptorMapSharedCache() { 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); diff --git a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp index 620e839896c..35247edfbd5 100644 --- a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp +++ b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp @@ -149,7 +149,7 @@ static void CreateHistoryThreadFromValueObject(ProcessSP process_sp, 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::GetHistoryThreads(lldb::addr_t address) { 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); diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index 676e330c625..e51029c3630 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -734,7 +734,7 @@ Error PlatformPOSIX::EvaluateLibdlExpression( 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 = diff --git a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp index e10e9a2e4b3..4e1f10c6ae1 100644 --- a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -61,7 +61,7 @@ bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr, 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(Process *process, addr_t addr, 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 *process, const Address *address, 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 = diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp index 9d0f0dace3d..dcc532db202 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp @@ -340,7 +340,7 @@ AppleGetItemInfoHandler::GetItemInfo(Thread &thread, uint64_t item, 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); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp index 38bf3368c71..fc91ba47ba1 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp @@ -351,7 +351,7 @@ AppleGetPendingItemsHandler::GetPendingItems(Thread &thread, addr_t queue, 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); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp index 3994c2817e6..ddc56d8feb3 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp @@ -357,7 +357,7 @@ AppleGetQueuesHandler::GetCurrentQueues(Thread &thread, addr_t page_to_free, 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); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp index 4ed43e5e6e5..c05523e0f33 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp @@ -355,7 +355,7 @@ AppleGetThreadItemInfoHandler::GetThreadItemInfo(Thread &thread, 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); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 7031267711d..76b95f23b15 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -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 EvaluateExpressionOptions &options) { 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 EvaluateExpressionOptions &options, // 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 &exe_ctx, // 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"); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 8f501248e72..160f831e0dc 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -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; |