diff options
author | Jim Ingham <jingham@apple.com> | 2012-10-16 21:41:58 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2012-10-16 21:41:58 +0000 |
commit | 35e1bda6957bb7e5d26f6a50e473ca3aa22a1386 (patch) | |
tree | 8ae0c9392cf55fc5c112148231d78729935de8e9 /lldb/source/API | |
parent | 02a1141e5a36928f7a0ac9d2e0ee44dca3be3a01 (diff) | |
download | bcm5719-llvm-35e1bda6957bb7e5d26f6a50e473ca3aa22a1386.tar.gz bcm5719-llvm-35e1bda6957bb7e5d26f6a50e473ca3aa22a1386.zip |
Add the ability to set timeout & "run all threads" options both from the "expr" command and from
the SB API's that evaluate expressions.
<rdar://problem/12457211>
llvm-svn: 166062
Diffstat (limited to 'lldb/source/API')
-rw-r--r-- | lldb/source/API/SBExpressionOptions.cpp | 142 | ||||
-rw-r--r-- | lldb/source/API/SBFrame.cpp | 30 | ||||
-rw-r--r-- | lldb/source/API/SBValue.cpp | 27 |
3 files changed, 183 insertions, 16 deletions
diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp new file mode 100644 index 00000000000..2a4b9f564b2 --- /dev/null +++ b/lldb/source/API/SBExpressionOptions.cpp @@ -0,0 +1,142 @@ +//===-- SBExpressionOptions.cpp ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBExpressionOptions.h" +#include "lldb/API/SBStream.h" + +#include "lldb/Target/Target.h" + +using namespace lldb; +using namespace lldb_private; + + +SBExpressionOptions::SBExpressionOptions () +{ + m_opaque_ap.reset(new EvaluateExpressionOptions()); +} + +SBExpressionOptions::SBExpressionOptions (bool coerce_to_id, + bool unwind_on_error, + bool keep_in_memory, + bool run_others, + DynamicValueType use_dynamic, + uint32_t timeout_usec) +{ + m_opaque_ap.reset(new EvaluateExpressionOptions()); + m_opaque_ap->SetCoerceToId(coerce_to_id); + m_opaque_ap->SetUnwindOnError(unwind_on_error); + m_opaque_ap->SetKeepInMemory(keep_in_memory); + m_opaque_ap->SetRunOthers(run_others); + m_opaque_ap->SetUseDynamic (use_dynamic); + m_opaque_ap->SetTimeoutUsec (timeout_usec); +} + +SBExpressionOptions::SBExpressionOptions (const SBExpressionOptions &rhs) +{ + m_opaque_ap.reset(new EvaluateExpressionOptions()); + *(m_opaque_ap.get()) = rhs.ref(); +} + +const SBExpressionOptions & +SBExpressionOptions::operator = (const SBExpressionOptions &rhs) +{ + if (this != &rhs) + { + this->ref() = rhs.ref(); + } + return *this; +} + +SBExpressionOptions::~SBExpressionOptions() +{ +} + +bool +SBExpressionOptions::DoesCoerceToId () const +{ + return m_opaque_ap->DoesCoerceToId (); +} + +void +SBExpressionOptions::SetCoerceToId (bool coerce) +{ + m_opaque_ap->SetCoerceToId (coerce); +} + +bool +SBExpressionOptions::DoesUnwindOnError () const +{ + return m_opaque_ap->DoesUnwindOnError (); +} + +void +SBExpressionOptions::SetUnwindOnError (bool unwind) +{ + m_opaque_ap->SetUnwindOnError (unwind); +} + +bool +SBExpressionOptions::DoesKeepInMemory () const +{ + return m_opaque_ap->DoesKeepInMemory (); +} + +void +SBExpressionOptions::SetKeepInMemory (bool keep) +{ + m_opaque_ap->SetKeepInMemory (keep); +} + +lldb::DynamicValueType +SBExpressionOptions::GetUseDynamic () const +{ + return m_opaque_ap->GetUseDynamic (); +} + +void +SBExpressionOptions::SetUseDynamic (lldb::DynamicValueType dynamic) +{ + m_opaque_ap->SetUseDynamic (dynamic); +} + +uint32_t +SBExpressionOptions::GetTimeoutUsec () const +{ + return m_opaque_ap->GetTimeoutUsec (); +} + +void +SBExpressionOptions::SetTimeoutUsec (uint32_t timeout) +{ + m_opaque_ap->SetTimeoutUsec (timeout); +} + +bool +SBExpressionOptions::GetRunOthers () const +{ + return m_opaque_ap->GetRunOthers (); +} + +void +SBExpressionOptions::SetRunOthers (bool run_others) +{ + m_opaque_ap->SetRunOthers (run_others); +} + +EvaluateExpressionOptions * +SBExpressionOptions::get() const +{ + return m_opaque_ap.get(); +} + +EvaluateExpressionOptions & +SBExpressionOptions::ref () const +{ + return *(m_opaque_ap.get()); +} diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index b94a0ce9267..f89c25b27e1 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -40,6 +40,7 @@ #include "lldb/API/SBDebugger.h" #include "lldb/API/SBValue.h" #include "lldb/API/SBAddress.h" +#include "lldb/API/SBExpressionOptions.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBThread.h" @@ -1040,8 +1041,11 @@ SBFrame::EvaluateExpression (const char *expr) Target *target = exe_ctx.GetTargetPtr(); if (frame && target) { - lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue(); - result = EvaluateExpression (expr, use_dynamic); + SBExpressionOptions options; + lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue(); + options.SetUseDynamic (fetch_dynamic_value); + options.SetUnwindOnError (true); + return EvaluateExpression (expr, options); } return result; } @@ -1049,12 +1053,24 @@ SBFrame::EvaluateExpression (const char *expr) SBValue SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value) { - return EvaluateExpression (expr, fetch_dynamic_value, true); + SBExpressionOptions options; + options.SetUseDynamic (fetch_dynamic_value); + options.SetUnwindOnError (true); + return EvaluateExpression (expr, options); } SBValue SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error) { + SBExpressionOptions options; + options.SetUseDynamic (fetch_dynamic_value); + options.SetUnwindOnError (unwind_on_error); + return EvaluateExpression (expr, options); +} + +lldb::SBValue +SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &options) +{ LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -1080,16 +1096,12 @@ SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dyna StreamString frame_description; frame->DumpUsingSettingsFormat (&frame_description); Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s", - expr, fetch_dynamic_value, frame_description.GetString().c_str()); + expr, options.GetUseDynamic(), frame_description.GetString().c_str()); #endif - Target::EvaluateExpressionOptions options; - options.SetUnwindOnError(unwind_on_error) - .SetUseDynamic(fetch_dynamic_value); - exe_results = target->EvaluateExpression (expr, frame, expr_value_sp, - options); + options.ref()); expr_result.SetSP(expr_value_sp); #ifdef LLDB_CONFIGURATION_DEBUG Host::SetCrashDescription (NULL); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 913a447aba5..0aa01a6c9cc 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -40,11 +40,12 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBExpressionOptions.h" +#include "lldb/API/SBFrame.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" -#include "lldb/API/SBFrame.h" -#include "lldb/API/SBDebugger.h" using namespace lldb; using namespace lldb_private; @@ -694,9 +695,12 @@ SBValue::CreateChildAtOffset (const char *name, uint32_t offset, SBType type) if (log) { if (new_value_sp) - log->Printf ("SBValue(%p)::CreateChildAtOffset => \"%s\"", value_sp.get(), new_value_sp->GetName().AsCString()); + log->Printf ("SBValue(%p)::CreateChildAtOffset => \"%s\"", + value_sp.get(), + new_value_sp->GetName().AsCString()); else - log->Printf ("SBValue(%p)::CreateChildAtOffset => NULL", value_sp.get()); + log->Printf ("SBValue(%p)::CreateChildAtOffset => NULL", + value_sp.get()); } return sb_value; } @@ -715,6 +719,14 @@ SBValue::Cast (SBType type) lldb::SBValue SBValue::CreateValueFromExpression (const char *name, const char* expression) { + SBExpressionOptions options; + options.SetKeepInMemory(true); + return CreateValueFromExpression (name, expression, options); +} + +lldb::SBValue +SBValue::CreateValueFromExpression (const char *name, const char *expression, SBExpressionOptions &options) +{ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); lldb::SBValue sb_value; lldb::ValueObjectSP value_sp(GetSP()); @@ -734,12 +746,11 @@ SBValue::CreateValueFromExpression (const char *name, const char* expression) Target* target = exe_ctx.GetTargetPtr(); if (target) { - Target::EvaluateExpressionOptions options; options.SetKeepInMemory(true); target->EvaluateExpression (expression, exe_ctx.GetFramePtr(), new_value_sp, - options); + options.ref()); if (new_value_sp) { new_value_sp->SetName(ConstString(name)); @@ -1617,7 +1628,9 @@ SBValue::GetAddress() } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBValue(%p)::GetAddress () => (%s,%llu)", value_sp.get(), (addr.GetSection() ? addr.GetSection()->GetName().GetCString() : "NULL"), addr.GetOffset()); + log->Printf ("SBValue(%p)::GetAddress () => (%s,%llu)", value_sp.get(), + (addr.GetSection() ? addr.GetSection()->GetName().GetCString() : "NULL"), + addr.GetOffset()); return SBAddress(new Address(addr)); } |