API cleanup.

llvm-svn: 166070
This commit is contained in:
Greg Clayton 2012-10-16 22:58:25 +00:00
parent eb7d598cec
commit cced1566e2
6 changed files with 47 additions and 111 deletions

View File

@ -28,53 +28,40 @@ public:
SBExpressionOptions (const lldb::SBExpressionOptions &rhs); SBExpressionOptions (const lldb::SBExpressionOptions &rhs);
SBExpressionOptions (bool coerce_to_id,
bool unwind_on_error,
bool keep_in_memory,
bool run_others,
DynamicValueType use_dynamic,
uint32_t timeout_usec);
~SBExpressionOptions(); ~SBExpressionOptions();
const SBExpressionOptions & const SBExpressionOptions &
operator = (const lldb::SBExpressionOptions &rhs); operator = (const lldb::SBExpressionOptions &rhs);
bool bool
DoesCoerceToId () const; GetCoerceResultToId () const;
void void
SetCoerceToId (bool coerce = true); SetCoerceResultToId (bool coerce = true);
bool bool
DoesUnwindOnError () const; GetUnwindOnError () const;
void void
SetUnwindOnError (bool unwind = false); SetUnwindOnError (bool unwind = false);
bool
DoesKeepInMemory () const;
void
SetKeepInMemory (bool keep = true);
lldb::DynamicValueType lldb::DynamicValueType
GetUseDynamic () const; GetFetchDynamicValue () const;
void void
SetUseDynamic (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget); SetFetchDynamicValue (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget);
uint32_t uint32_t
GetTimeoutUsec () const; GetTimeoutInMicroSeconds () const;
void void
SetTimeoutUsec (uint32_t timeout = 0); SetTimeoutInMicroSeconds (uint32_t timeout = 0);
bool bool
GetRunOthers () const; GetTryAllThreads () const;
void void
SetRunOthers (bool run_others = true); SetTryAllThreads (bool run_others = true);
protected: protected:

View File

@ -23,69 +23,46 @@ public:
SBExpressionOptions (const lldb::SBExpressionOptions &rhs); SBExpressionOptions (const lldb::SBExpressionOptions &rhs);
SBExpressionOptions (bool coerce_to_id,
bool unwind_on_error,
bool keep_in_memory,
bool run_others,
DynamicValueType use_dynamic,
uint32_t timeout_usec);
~SBExpressionOptions(); ~SBExpressionOptions();
bool bool
DoesCoerceToId () const; GetCoerceResultToId () const;
%feature("docstring", "Sets whether to coerce the expression result to ObjC id type after evaluation.") SetCoerceResultToId;
%feature("docstring",
"Sets whether to coerce the expression result to ObjC id type after evaluation."
) SetCoerceToId;
void void
SetCoerceToId (bool coerce = true); SetCoerceResultToId (bool coerce = true);
bool bool
DoesUnwindOnError () const; GetUnwindOnError () const;
%feature("docstring", "Sets whether to unwind the expression stack on error.") SetUnwindOnError;
%feature("docstring",
"Sets whether to unwind the expression stack on error."
) SetUnwindOnError;
void void
SetUnwindOnError (bool unwind = false); SetUnwindOnError (bool unwind = false);
bool
DoesKeepInMemory () const;
%feature("docstring",
"Sets whether to keep the expression result in the target program's memory - forced to true when creating SBValues."
) SetKeepInMemory;
void
SetKeepInMemory (bool keep = true);
lldb::DynamicValueType lldb::DynamicValueType
GetUseDynamic () const; GetFetchDynamicValue () const;
%feature("docstring", "Sets whether to cast the expression result to its dynamic type.") SetFetchDynamicValue;
%feature("docstring",
"Sets whether to cast the expression result to its dynamic type."
) SetUseDynamic;
void void
SetUseDynamic (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget); SetFetchDynamicValue (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget);
uint32_t uint32_t
GetTimeoutUsec () const; GetTimeoutInMicroSeconds () const;
%feature("docstring", %feature("docstring", "Sets the timeout in microseconds to run the expression for. If try all threads is set to true and the expression doesn't complete within the specified timeout, all threads will be resumed for the same timeout to see if the expresson will finish.") SetTimeoutInMicroSeconds;
"Sets the duration we will wait before cancelling expression evaluation. 0 means wait forever."
) SetTimeoutUsec;
void void
SetTimeoutUsec (uint32_t timeout = 0); SetTimeoutInMicroSeconds (uint32_t timeout = 0);
bool bool
GetRunOthers () const; GetTryAllThreads () const;
%feature("docstring", %feature("docstring", "Sets whether to run all threads if the expression does not complete on one thread.") SetTryAllThreads;
"Sets whether to run all threads if the expression does not complete on one thread."
) SetRunOthers;
void void
SetRunOthers (bool run_others = true); SetTryAllThreads (bool run_others = true);
protected: protected:
SBExpressionOptions (lldb_private::EvaluateExpressionOptions &expression_options); SBExpressionOptions (lldb_private::EvaluateExpressionOptions &expression_options);

View File

@ -16,25 +16,9 @@ using namespace lldb;
using namespace lldb_private; using namespace lldb_private;
SBExpressionOptions::SBExpressionOptions () SBExpressionOptions::SBExpressionOptions () :
m_opaque_ap(new EvaluateExpressionOptions())
{ {
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) SBExpressionOptions::SBExpressionOptions (const SBExpressionOptions &rhs)
@ -58,19 +42,19 @@ SBExpressionOptions::~SBExpressionOptions()
} }
bool bool
SBExpressionOptions::DoesCoerceToId () const SBExpressionOptions::GetCoerceResultToId () const
{ {
return m_opaque_ap->DoesCoerceToId (); return m_opaque_ap->DoesCoerceToId ();
} }
void void
SBExpressionOptions::SetCoerceToId (bool coerce) SBExpressionOptions::SetCoerceResultToId (bool coerce)
{ {
m_opaque_ap->SetCoerceToId (coerce); m_opaque_ap->SetCoerceToId (coerce);
} }
bool bool
SBExpressionOptions::DoesUnwindOnError () const SBExpressionOptions::GetUnwindOnError () const
{ {
return m_opaque_ap->DoesUnwindOnError (); return m_opaque_ap->DoesUnwindOnError ();
} }
@ -81,50 +65,38 @@ SBExpressionOptions::SetUnwindOnError (bool unwind)
m_opaque_ap->SetUnwindOnError (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 lldb::DynamicValueType
SBExpressionOptions::GetUseDynamic () const SBExpressionOptions::GetFetchDynamicValue () const
{ {
return m_opaque_ap->GetUseDynamic (); return m_opaque_ap->GetUseDynamic ();
} }
void void
SBExpressionOptions::SetUseDynamic (lldb::DynamicValueType dynamic) SBExpressionOptions::SetFetchDynamicValue (lldb::DynamicValueType dynamic)
{ {
m_opaque_ap->SetUseDynamic (dynamic); m_opaque_ap->SetUseDynamic (dynamic);
} }
uint32_t uint32_t
SBExpressionOptions::GetTimeoutUsec () const SBExpressionOptions::GetTimeoutInMicroSeconds () const
{ {
return m_opaque_ap->GetTimeoutUsec (); return m_opaque_ap->GetTimeoutUsec ();
} }
void void
SBExpressionOptions::SetTimeoutUsec (uint32_t timeout) SBExpressionOptions::SetTimeoutInMicroSeconds (uint32_t timeout)
{ {
m_opaque_ap->SetTimeoutUsec (timeout); m_opaque_ap->SetTimeoutUsec (timeout);
} }
bool bool
SBExpressionOptions::GetRunOthers () const SBExpressionOptions::GetTryAllThreads () const
{ {
return m_opaque_ap->GetRunOthers (); return m_opaque_ap->GetRunOthers ();
} }
void void
SBExpressionOptions::SetRunOthers (bool run_others) SBExpressionOptions::SetTryAllThreads (bool run_others)
{ {
m_opaque_ap->SetRunOthers (run_others); m_opaque_ap->SetRunOthers (run_others);
} }

View File

@ -1043,7 +1043,7 @@ SBFrame::EvaluateExpression (const char *expr)
{ {
SBExpressionOptions options; SBExpressionOptions options;
lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue(); lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue();
options.SetUseDynamic (fetch_dynamic_value); options.SetFetchDynamicValue (fetch_dynamic_value);
options.SetUnwindOnError (true); options.SetUnwindOnError (true);
return EvaluateExpression (expr, options); return EvaluateExpression (expr, options);
} }
@ -1054,7 +1054,7 @@ SBValue
SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value) SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value)
{ {
SBExpressionOptions options; SBExpressionOptions options;
options.SetUseDynamic (fetch_dynamic_value); options.SetFetchDynamicValue (fetch_dynamic_value);
options.SetUnwindOnError (true); options.SetUnwindOnError (true);
return EvaluateExpression (expr, options); return EvaluateExpression (expr, options);
} }
@ -1063,7 +1063,7 @@ SBValue
SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error) SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error)
{ {
SBExpressionOptions options; SBExpressionOptions options;
options.SetUseDynamic (fetch_dynamic_value); options.SetFetchDynamicValue (fetch_dynamic_value);
options.SetUnwindOnError (unwind_on_error); options.SetUnwindOnError (unwind_on_error);
return EvaluateExpression (expr, options); return EvaluateExpression (expr, options);
} }
@ -1096,7 +1096,7 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option
StreamString frame_description; StreamString frame_description;
frame->DumpUsingSettingsFormat (&frame_description); frame->DumpUsingSettingsFormat (&frame_description);
Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s", Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
expr, options.GetUseDynamic(), frame_description.GetString().c_str()); expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str());
#endif #endif
exe_results = target->EvaluateExpression (expr, exe_results = target->EvaluateExpression (expr,
frame, frame,

View File

@ -720,7 +720,7 @@ lldb::SBValue
SBValue::CreateValueFromExpression (const char *name, const char* expression) SBValue::CreateValueFromExpression (const char *name, const char* expression)
{ {
SBExpressionOptions options; SBExpressionOptions options;
options.SetKeepInMemory(true); options.ref().SetKeepInMemory(true);
return CreateValueFromExpression (name, expression, options); return CreateValueFromExpression (name, expression, options);
} }
@ -746,7 +746,7 @@ SBValue::CreateValueFromExpression (const char *name, const char *expression, SB
Target* target = exe_ctx.GetTargetPtr(); Target* target = exe_ctx.GetTargetPtr();
if (target) if (target)
{ {
options.SetKeepInMemory(true); options.ref().SetKeepInMemory(true);
target->EvaluateExpression (expression, target->EvaluateExpression (expression,
exe_ctx.GetFramePtr(), exe_ctx.GetFramePtr(),
new_value_sp, new_value_sp,

View File

@ -57,7 +57,7 @@ class ExprCommandWithTimeoutsTestCase(TestBase):
# First set the timeout too short, and make sure we fail. # First set the timeout too short, and make sure we fail.
options = lldb.SBExpressionOptions() options = lldb.SBExpressionOptions()
options.SetTimeoutUsec(100) options.SetTimeoutInMicroSeconds(100)
options.SetUnwindOnError(True) options.SetUnwindOnError(True)
frame = thread.GetFrameAtIndex(0) frame = thread.GetFrameAtIndex(0)
@ -75,7 +75,7 @@ class ExprCommandWithTimeoutsTestCase(TestBase):
# Okay, now do it again with long enough time outs: # Okay, now do it again with long enough time outs:
options.SetTimeoutUsec(1000000) options.SetTimeoutInMicroSeconds(1000000)
value = frame.EvaluateExpression ("wait_a_while (1000)", options) value = frame.EvaluateExpression ("wait_a_while (1000)", options)
self.assertTrue(value.IsValid()) self.assertTrue(value.IsValid())
self.assertTrue (value.GetError().Success() == True) self.assertTrue (value.GetError().Success() == True)