summaryrefslogtreecommitdiffstats
path: root/source/API/SBValue.cpp
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2015-02-06 21:38:51 +0000
committeremaste <emaste@FreeBSD.org>2015-02-06 21:38:51 +0000
commit0c2019f4ca6b2dc6d710f6bb16a0e3ed10271531 (patch)
tree09bc83f73246ee3c7a779605cd0122093d2a8a19 /source/API/SBValue.cpp
parent01ee1789d6aa7294e5966a97f8d29387f6f81699 (diff)
downloadFreeBSD-src-0c2019f4ca6b2dc6d710f6bb16a0e3ed10271531.zip
FreeBSD-src-0c2019f4ca6b2dc6d710f6bb16a0e3ed10271531.tar.gz
Import LLDB as of upstream SVN r225923 (git 2b588ecd)
This corresponds with the branchpoint for the 3.6 release. A number of files not required for the FreeBSD build have been removed. Sponsored by: DARPA, AFRL
Diffstat (limited to 'source/API/SBValue.cpp')
-rw-r--r--source/API/SBValue.cpp123
1 files changed, 79 insertions, 44 deletions
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index 3a9621b..0d3d7ad 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -543,6 +543,36 @@ SBValue::GetObjectDescription ()
return cstr;
}
+const char *
+SBValue::GetTypeValidatorResult ()
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ const char *cstr = NULL;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ {
+ const auto& validation(value_sp->GetValidationStatus());
+ if (TypeValidatorResult::Failure == validation.first)
+ {
+ if (validation.second.empty())
+ cstr = "unknown error";
+ else
+ cstr = validation.second.c_str();
+ }
+ }
+ if (log)
+ {
+ if (cstr)
+ log->Printf ("SBValue(%p)::GetTypeValidatorResult() => \"%s\"",
+ static_cast<void*>(value_sp.get()), cstr);
+ else
+ log->Printf ("SBValue(%p)::GetTypeValidatorResult() => NULL",
+ static_cast<void*>(value_sp.get()));
+ }
+ return cstr;
+}
+
SBType
SBValue::GetType()
{
@@ -610,6 +640,32 @@ SBValue::GetSummary ()
}
return cstr;
}
+
+const char *
+SBValue::GetSummary (lldb::SBStream& stream,
+ lldb::SBTypeSummaryOptions& options)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ {
+ std::string buffer;
+ if (value_sp->GetSummaryAsCString(buffer,options.ref()) && !buffer.empty())
+ stream.Printf("%s",buffer.c_str());
+ }
+ const char* cstr = stream.GetData();
+ if (log)
+ {
+ if (cstr)
+ log->Printf ("SBValue(%p)::GetSummary() => \"%s\"",
+ static_cast<void*>(value_sp.get()), cstr);
+ else
+ log->Printf ("SBValue(%p)::GetSummary() => NULL",
+ static_cast<void*>(value_sp.get()));
+ }
+ return cstr;
+}
#endif // LLDB_DISABLE_PYTHON
const char *
@@ -808,21 +864,11 @@ SBValue::CreateValueFromExpression (const char *name, const char *expression, SB
if (value_sp)
{
ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
- Target* target = exe_ctx.GetTargetPtr();
- if (target)
- {
- options.ref().SetKeepInMemory(true);
- target->EvaluateExpression (expression,
- exe_ctx.GetFramePtr(),
- new_value_sp,
- options.ref());
- if (new_value_sp)
- {
- new_value_sp->SetName(ConstString(name));
- sb_value.SetSP(new_value_sp);
- }
- }
+ new_value_sp = ValueObject::CreateValueObjectFromExpression(name, expression, exe_ctx, options.ref());
+ if (new_value_sp)
+ new_value_sp->SetName(ConstString(name));
}
+ sb_value.SetSP(new_value_sp);
if (log)
{
if (new_value_sp)
@@ -846,30 +892,11 @@ SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType s
lldb::TypeImplSP type_impl_sp (sb_type.GetSP());
if (value_sp && type_impl_sp)
{
- ClangASTType pointer_ast_type(type_impl_sp->GetClangASTType(false).GetPointerType ());
- if (pointer_ast_type)
- {
- lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
-
- ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
- ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
- pointer_ast_type,
- ConstString(name),
- buffer,
- exe_ctx.GetByteOrder(),
- exe_ctx.GetAddressByteSize()));
-
- if (ptr_result_valobj_sp)
- {
- ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress);
- Error err;
- new_value_sp = ptr_result_valobj_sp->Dereference(err);
- if (new_value_sp)
- new_value_sp->SetName(ConstString(name));
- }
- sb_value.SetSP(new_value_sp);
- }
+ ClangASTType ast_type(type_impl_sp->GetClangASTType(true));
+ ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
+ new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, ast_type);
}
+ sb_value.SetSP(new_value_sp);
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
@@ -894,15 +921,10 @@ SBValue::CreateValueFromData (const char* name, SBData data, SBType type)
if (value_sp)
{
ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
-
- new_value_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
- type.m_opaque_sp->GetClangASTType(false),
- ConstString(name),
- *data.m_opaque_sp,
- LLDB_INVALID_ADDRESS);
+ new_value_sp = ValueObject::CreateValueObjectFromData(name, **data, exe_ctx, type.GetSP()->GetClangASTType(true));
new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
- sb_value.SetSP(new_value_sp);
}
+ sb_value.SetSP(new_value_sp);
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
@@ -1836,3 +1858,16 @@ SBValue::WatchPointee (bool resolve_location, bool read, bool write, SBError &er
sb_watchpoint = Dereference().Watch (resolve_location, read, write, error);
return sb_watchpoint;
}
+
+lldb::SBValue
+SBValue::Persist ()
+{
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ SBValue persisted_sb;
+ if (value_sp)
+ {
+ persisted_sb.SetSP(value_sp->Persist());
+ }
+ return persisted_sb;
+}
OpenPOWER on IntegriCloud