2012-10-17 05:41:58 +08:00
|
|
|
//===-- 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;
|
|
|
|
|
|
|
|
|
2012-10-17 06:58:25 +08:00
|
|
|
SBExpressionOptions::SBExpressionOptions () :
|
|
|
|
m_opaque_ap(new EvaluateExpressionOptions())
|
2012-10-17 05:41:58 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2012-10-17 06:58:25 +08:00
|
|
|
SBExpressionOptions::GetCoerceResultToId () const
|
2012-10-17 05:41:58 +08:00
|
|
|
{
|
|
|
|
return m_opaque_ap->DoesCoerceToId ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-10-17 06:58:25 +08:00
|
|
|
SBExpressionOptions::SetCoerceResultToId (bool coerce)
|
2012-10-17 05:41:58 +08:00
|
|
|
{
|
|
|
|
m_opaque_ap->SetCoerceToId (coerce);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-10-17 06:58:25 +08:00
|
|
|
SBExpressionOptions::GetUnwindOnError () const
|
2012-10-17 05:41:58 +08:00
|
|
|
{
|
|
|
|
return m_opaque_ap->DoesUnwindOnError ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBExpressionOptions::SetUnwindOnError (bool unwind)
|
|
|
|
{
|
|
|
|
m_opaque_ap->SetUnwindOnError (unwind);
|
|
|
|
}
|
|
|
|
|
2013-01-15 10:47:48 +08:00
|
|
|
bool
|
|
|
|
SBExpressionOptions::GetIgnoreBreakpoints () const
|
|
|
|
{
|
|
|
|
return m_opaque_ap->DoesIgnoreBreakpoints ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBExpressionOptions::SetIgnoreBreakpoints (bool ignore)
|
|
|
|
{
|
|
|
|
m_opaque_ap->SetIgnoreBreakpoints (ignore);
|
|
|
|
}
|
|
|
|
|
2012-10-17 05:41:58 +08:00
|
|
|
lldb::DynamicValueType
|
2012-10-17 06:58:25 +08:00
|
|
|
SBExpressionOptions::GetFetchDynamicValue () const
|
2012-10-17 05:41:58 +08:00
|
|
|
{
|
|
|
|
return m_opaque_ap->GetUseDynamic ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-10-17 06:58:25 +08:00
|
|
|
SBExpressionOptions::SetFetchDynamicValue (lldb::DynamicValueType dynamic)
|
2012-10-17 05:41:58 +08:00
|
|
|
{
|
|
|
|
m_opaque_ap->SetUseDynamic (dynamic);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2012-10-17 06:58:25 +08:00
|
|
|
SBExpressionOptions::GetTimeoutInMicroSeconds () const
|
2012-10-17 05:41:58 +08:00
|
|
|
{
|
|
|
|
return m_opaque_ap->GetTimeoutUsec ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-10-17 06:58:25 +08:00
|
|
|
SBExpressionOptions::SetTimeoutInMicroSeconds (uint32_t timeout)
|
2012-10-17 05:41:58 +08:00
|
|
|
{
|
|
|
|
m_opaque_ap->SetTimeoutUsec (timeout);
|
|
|
|
}
|
|
|
|
|
2014-03-29 05:58:28 +08:00
|
|
|
uint32_t
|
|
|
|
SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds () const
|
|
|
|
{
|
|
|
|
return m_opaque_ap->GetOneThreadTimeoutUsec ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds (uint32_t timeout)
|
|
|
|
{
|
|
|
|
m_opaque_ap->SetOneThreadTimeoutUsec (timeout);
|
|
|
|
}
|
|
|
|
|
2012-10-17 05:41:58 +08:00
|
|
|
bool
|
2012-10-17 06:58:25 +08:00
|
|
|
SBExpressionOptions::GetTryAllThreads () const
|
2012-10-17 05:41:58 +08:00
|
|
|
{
|
2013-11-07 08:11:47 +08:00
|
|
|
return m_opaque_ap->GetTryAllThreads ();
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-10-17 06:58:25 +08:00
|
|
|
SBExpressionOptions::SetTryAllThreads (bool run_others)
|
2012-10-17 05:41:58 +08:00
|
|
|
{
|
2013-11-07 08:11:47 +08:00
|
|
|
m_opaque_ap->SetTryAllThreads (run_others);
|
|
|
|
}
|
|
|
|
|
2014-02-28 10:52:06 +08:00
|
|
|
bool
|
|
|
|
SBExpressionOptions::GetStopOthers () const
|
|
|
|
{
|
|
|
|
return m_opaque_ap->GetStopOthers ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBExpressionOptions::SetStopOthers (bool run_others)
|
|
|
|
{
|
|
|
|
m_opaque_ap->SetStopOthers (run_others);
|
|
|
|
}
|
|
|
|
|
2013-11-07 08:11:47 +08:00
|
|
|
bool
|
|
|
|
SBExpressionOptions::GetTrapExceptions () const
|
|
|
|
{
|
|
|
|
return m_opaque_ap->GetTrapExceptions ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBExpressionOptions::SetTrapExceptions (bool trap_exceptions)
|
|
|
|
{
|
|
|
|
m_opaque_ap->SetTrapExceptions (trap_exceptions);
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2014-06-13 10:37:02 +08:00
|
|
|
void
|
|
|
|
SBExpressionOptions::SetLanguage (lldb::LanguageType language)
|
|
|
|
{
|
|
|
|
m_opaque_ap->SetLanguage(language);
|
|
|
|
}
|
|
|
|
|
2014-05-05 10:26:40 +08:00
|
|
|
void
|
|
|
|
SBExpressionOptions::SetCancelCallback (lldb::ExpressionCancelCallback callback, void *baton)
|
|
|
|
{
|
|
|
|
m_opaque_ap->SetCancelCallback (callback, baton);
|
|
|
|
}
|
|
|
|
|
2014-07-11 09:03:57 +08:00
|
|
|
bool
|
|
|
|
SBExpressionOptions::GetGenerateDebugInfo ()
|
|
|
|
{
|
|
|
|
return m_opaque_ap->GetGenerateDebugInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBExpressionOptions::SetGenerateDebugInfo (bool b)
|
|
|
|
{
|
|
|
|
return m_opaque_ap->SetGenerateDebugInfo(b);
|
|
|
|
}
|
|
|
|
|
2014-08-09 05:45:36 +08:00
|
|
|
bool
|
|
|
|
SBExpressionOptions::GetSuppressPersistentResult ()
|
|
|
|
{
|
|
|
|
return m_opaque_ap->GetResultIsInternal ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBExpressionOptions::SetSuppressPersistentResult (bool b)
|
|
|
|
{
|
|
|
|
return m_opaque_ap->SetResultIsInternal (b);
|
|
|
|
}
|
|
|
|
|
Allow expresions to have unique expression prefixes:
expr_options = lldb.SBExpressionOptions()
expr_options.SetPrefix('''
struct Foo {
int a;
int b;
int c;
}
'''
expr_result = frame.EvaluateExpression ("Foo foo = { 1, 2, 3}; foo", expr_options)
This fixed a current issue with ptr_refs, cstr_refs and malloc_info so that they can work. If expressions define their own types and then return expression results that use those types, those types get copied into the target's AST context so they persist and the expression results can be still printed and used in future expressions. Code was added to the expression parser to copy the context in which types are defined if they are used as the expression results. So in the case of types defined by expressions, they get defined in a lldb_expr function and that function and _all_ of its statements get copied. Many types of statements are not supported in this copy (array subscript, lambdas, etc) so this causes expressions to fail as they can't copy the result types. To work around this issue I have added code that allows expressions to specify an expression specific prefix. Then when you evaluate the expression you can pass the "expr_options" and have types that can be correctly copied out into the target. I added this as a way to work around an issue, but I also think it is nice to be allowed to specify an expression prefix that can be reused by many expressions, so this feature is very useful.
<rdar://problem/21130675>
llvm-svn: 238365
2015-05-28 06:32:39 +08:00
|
|
|
const char *
|
|
|
|
SBExpressionOptions::GetPrefix () const
|
|
|
|
{
|
|
|
|
return m_opaque_ap->GetPrefix();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBExpressionOptions::SetPrefix (const char *prefix)
|
|
|
|
{
|
|
|
|
return m_opaque_ap->SetPrefix(prefix);
|
|
|
|
}
|
2014-08-09 05:45:36 +08:00
|
|
|
|
2016-03-25 09:57:14 +08:00
|
|
|
bool
|
|
|
|
SBExpressionOptions::GetAutoApplyFixIts ()
|
|
|
|
{
|
|
|
|
return m_opaque_ap->GetAutoApplyFixIts ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBExpressionOptions::SetAutoApplyFixIts (bool b)
|
|
|
|
{
|
|
|
|
return m_opaque_ap->SetAutoApplyFixIts (b);
|
|
|
|
}
|
|
|
|
|
2012-10-17 05:41:58 +08:00
|
|
|
EvaluateExpressionOptions *
|
|
|
|
SBExpressionOptions::get() const
|
|
|
|
{
|
|
|
|
return m_opaque_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
EvaluateExpressionOptions &
|
|
|
|
SBExpressionOptions::ref () const
|
|
|
|
{
|
|
|
|
return *(m_opaque_ap.get());
|
|
|
|
}
|