2016-09-07 04:57:50 +08:00
|
|
|
//===-- SBExpressionOptions.cpp ---------------------------------------------*-
|
|
|
|
//C++ -*-===//
|
2012-10-17 05:41:58 +08:00
|
|
|
//
|
|
|
|
// 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;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBExpressionOptions::SBExpressionOptions()
|
|
|
|
: m_opaque_ap(new EvaluateExpressionOptions()) {}
|
2012-10-17 05:41:58 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) {
|
|
|
|
m_opaque_ap.reset(new EvaluateExpressionOptions());
|
|
|
|
*(m_opaque_ap.get()) = rhs.ref();
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const SBExpressionOptions &SBExpressionOptions::
|
|
|
|
operator=(const SBExpressionOptions &rhs) {
|
|
|
|
if (this != &rhs) {
|
|
|
|
this->ref() = rhs.ref();
|
|
|
|
}
|
|
|
|
return *this;
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBExpressionOptions::~SBExpressionOptions() {}
|
2012-10-17 05:41:58 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBExpressionOptions::GetCoerceResultToId() const {
|
|
|
|
return m_opaque_ap->DoesCoerceToId();
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
|
|
|
|
m_opaque_ap->SetCoerceToId(coerce);
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBExpressionOptions::GetUnwindOnError() const {
|
|
|
|
return m_opaque_ap->DoesUnwindOnError();
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetUnwindOnError(bool unwind) {
|
|
|
|
m_opaque_ap->SetUnwindOnError(unwind);
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBExpressionOptions::GetIgnoreBreakpoints() const {
|
|
|
|
return m_opaque_ap->DoesIgnoreBreakpoints();
|
2013-01-15 10:47:48 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
|
|
|
|
m_opaque_ap->SetIgnoreBreakpoints(ignore);
|
2013-01-15 10:47:48 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
|
|
|
|
return m_opaque_ap->GetUseDynamic();
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
|
|
|
|
m_opaque_ap->SetUseDynamic(dynamic);
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
|
2016-12-06 19:24:51 +08:00
|
|
|
return m_opaque_ap->GetTimeout() ? m_opaque_ap->GetTimeout()->count() : 0;
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
|
2016-12-06 19:24:51 +08:00
|
|
|
m_opaque_ap->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
|
|
|
|
: std::chrono::microseconds(timeout));
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
|
2016-12-06 19:24:51 +08:00
|
|
|
return m_opaque_ap->GetOneThreadTimeout() ? m_opaque_ap->GetOneThreadTimeout()->count() : 0;
|
2014-03-29 05:58:28 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
|
2016-12-06 19:24:51 +08:00
|
|
|
m_opaque_ap->SetOneThreadTimeout(timeout == 0
|
|
|
|
? Timeout<std::micro>(llvm::None)
|
|
|
|
: std::chrono::microseconds(timeout));
|
2014-03-29 05:58:28 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBExpressionOptions::GetTryAllThreads() const {
|
|
|
|
return m_opaque_ap->GetTryAllThreads();
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetTryAllThreads(bool run_others) {
|
|
|
|
m_opaque_ap->SetTryAllThreads(run_others);
|
2013-11-07 08:11:47 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBExpressionOptions::GetStopOthers() const {
|
|
|
|
return m_opaque_ap->GetStopOthers();
|
2014-02-28 10:52:06 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetStopOthers(bool run_others) {
|
|
|
|
m_opaque_ap->SetStopOthers(run_others);
|
2014-02-28 10:52:06 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBExpressionOptions::GetTrapExceptions() const {
|
|
|
|
return m_opaque_ap->GetTrapExceptions();
|
2013-11-07 08:11:47 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
|
|
|
|
m_opaque_ap->SetTrapExceptions(trap_exceptions);
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
|
|
|
|
m_opaque_ap->SetLanguage(language);
|
2014-06-13 10:37:02 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetCancelCallback(
|
|
|
|
lldb::ExpressionCancelCallback callback, void *baton) {
|
|
|
|
m_opaque_ap->SetCancelCallback(callback, baton);
|
2014-05-05 10:26:40 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBExpressionOptions::GetGenerateDebugInfo() {
|
|
|
|
return m_opaque_ap->GetGenerateDebugInfo();
|
2014-07-11 09:03:57 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
|
|
|
|
return m_opaque_ap->SetGenerateDebugInfo(b);
|
2014-07-11 09:03:57 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBExpressionOptions::GetSuppressPersistentResult() {
|
|
|
|
return m_opaque_ap->GetResultIsInternal();
|
2014-08-09 05:45:36 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
|
|
|
|
return m_opaque_ap->SetResultIsInternal(b);
|
2014-08-09 05:45:36 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *SBExpressionOptions::GetPrefix() const {
|
|
|
|
return m_opaque_ap->GetPrefix();
|
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
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetPrefix(const char *prefix) {
|
|
|
|
return m_opaque_ap->SetPrefix(prefix);
|
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
|
|
|
}
|
2014-08-09 05:45:36 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBExpressionOptions::GetAutoApplyFixIts() {
|
|
|
|
return m_opaque_ap->GetAutoApplyFixIts();
|
2016-03-25 09:57:14 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
|
|
|
|
return m_opaque_ap->SetAutoApplyFixIts(b);
|
2016-03-25 09:57:14 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBExpressionOptions::GetTopLevel() {
|
|
|
|
return m_opaque_ap->GetExecutionPolicy() == eExecutionPolicyTopLevel;
|
2016-03-29 05:20:05 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBExpressionOptions::SetTopLevel(bool b) {
|
|
|
|
m_opaque_ap->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
|
|
|
|
: m_opaque_ap->default_execution_policy);
|
2016-03-29 05:20:05 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
EvaluateExpressionOptions *SBExpressionOptions::get() const {
|
|
|
|
return m_opaque_ap.get();
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
EvaluateExpressionOptions &SBExpressionOptions::ref() const {
|
|
|
|
return *(m_opaque_ap.get());
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|