60 const char *name =
nullptr)
64 if ((
m_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(
100 return target_sp && target_sp->IsValid();
107 std::unique_lock<std::recursive_mutex> &lock,
110 error.SetErrorString(
"invalid value object");
116 Target *target = value_sp->GetTargetSP().get();
118 return ValueObjectSP();
120 lock = std::unique_lock<std::recursive_mutex>(target->
GetAPIMutex());
122 ProcessSP process_sp(value_sp->GetProcessSP());
123 if (process_sp && !stop_locker.
TryLock(&process_sp->GetRunLock())) {
127 error.SetErrorString(
"process must be stopped.");
128 return ValueObjectSP();
132 ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(
m_use_dynamic);
134 value_sp = dynamic_sp;
138 ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue();
140 value_sp = synthetic_sp;
144 error.SetErrorString(
"invalid value object");
146 value_sp->SetName(
m_name);
190 return StackFrameSP();
212 std::unique_lock<std::recursive_mutex>
m_lock;
243 return this->
operator bool();
245SBValue::operator bool()
const {
251 return m_opaque_sp.get() !=
nullptr && m_opaque_sp->IsValid() &&
252 m_opaque_sp->GetRootSP().get() !=
nullptr;
267 lldb::ValueObjectSP value_sp(
GetSP(locker));
269 sb_error.
SetError(value_sp->GetError());
281 lldb::ValueObjectSP value_sp(
GetSP(locker));
283 return value_sp->GetID();
290 const char *name =
nullptr;
292 lldb::ValueObjectSP value_sp(
GetSP(locker));
294 name = value_sp->GetName().GetCString();
302 const char *name =
nullptr;
304 lldb::ValueObjectSP value_sp(
GetSP(locker));
306 name = value_sp->GetQualifiedTypeName().GetCString();
315 const char *name =
nullptr;
317 lldb::ValueObjectSP value_sp(
GetSP(locker));
319 name = value_sp->GetDisplayTypeName().GetCString();
331 lldb::ValueObjectSP value_sp(
GetSP(locker));
333 result = value_sp->GetByteSize().value_or(0);
345 lldb::ValueObjectSP value_sp(
GetSP(locker));
347 result = value_sp->IsInScope();
356 const char *cstr =
nullptr;
358 lldb::ValueObjectSP value_sp(
GetSP(locker));
360 cstr = value_sp->GetValueAsCString();
371 lldb::ValueObjectSP value_sp(
GetSP(locker));
373 result = value_sp->GetValueType();
381 const char *cstr =
nullptr;
383 lldb::ValueObjectSP value_sp(
GetSP(locker));
385 cstr = value_sp->GetObjectDescription();
396 lldb::ValueObjectSP value_sp(
GetSP(locker));
399 type_sp = std::make_shared<TypeImpl>(value_sp->GetTypeImpl());
400 sb_type.
SetSP(type_sp);
411 lldb::ValueObjectSP value_sp(
GetSP(locker));
413 if (value_sp->UpdateValueIfNeeded(
false))
414 result = value_sp->GetValueDidChange();
423 const char *cstr =
nullptr;
425 lldb::ValueObjectSP value_sp(
GetSP(locker));
427 cstr = value_sp->GetSummaryAsCString();
438 lldb::ValueObjectSP value_sp(
GetSP(locker));
441 if (value_sp->GetSummaryAsCString(buffer, options.
ref()) && !buffer.empty())
442 stream.
Printf(
"%s", buffer.c_str());
444 const char *cstr = stream.
GetData();
451 const char *cstr =
nullptr;
453 lldb::ValueObjectSP value_sp(
GetSP(locker));
455 cstr = value_sp->GetLocationAsCString();
471 bool success =
false;
473 lldb::ValueObjectSP value_sp(
GetSP(locker));
475 success = value_sp->SetValueFromCString(value_str,
error.ref());
477 error.SetErrorStringWithFormat(
"Could not get value: %s",
488 lldb::ValueObjectSP value_sp(
GetSP(locker));
490 if (value_sp->UpdateValueIfNeeded(
true)) {
491 lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
493 format.
SetSP(format_sp);
504 lldb::ValueObjectSP value_sp(
GetSP(locker));
506 if (value_sp->UpdateValueIfNeeded(
true)) {
507 lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
509 summary.
SetSP(summary_sp);
520 lldb::ValueObjectSP value_sp(
GetSP(locker));
522 if (value_sp->UpdateValueIfNeeded(
true)) {
523 lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
525 if (synthetic_sp && !synthetic_sp->IsScripted()) {
526 TypeFilterImplSP filter_sp =
527 std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
528 filter.
SetSP(filter_sp);
540 lldb::ValueObjectSP value_sp(
GetSP(locker));
542 if (value_sp->UpdateValueIfNeeded(
true)) {
543 lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
545 if (children_sp && children_sp->IsScripted()) {
546 ScriptedSyntheticChildrenSP synth_sp =
547 std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
548 synthetic.
SetSP(synth_sp);
561 lldb::ValueObjectSP value_sp(
GetSP(locker));
562 lldb::ValueObjectSP new_value_sp;
564 TypeImplSP type_sp(type.
GetSP());
566 sb_value.
SetSP(value_sp->GetSyntheticChildAtOffset(
567 offset, type_sp->GetCompilerType(
false),
true),
579 lldb::ValueObjectSP value_sp(
GetSP(locker));
580 TypeImplSP type_sp(type.
GetSP());
581 if (value_sp && type_sp)
582 sb_value.
SetSP(value_sp->Cast(type_sp->GetCompilerType(
false)),
588 const char *expression) {
597 const char *expression,
603 lldb::ValueObjectSP value_sp(
GetSP(locker));
604 lldb::ValueObjectSP new_value_sp;
608 name, expression, exe_ctx, options.
ref());
612 sb_value.
SetSP(new_value_sp);
623 lldb::ValueObjectSP value_sp(
GetSP(locker));
624 lldb::ValueObjectSP new_value_sp;
625 lldb::TypeImplSP type_impl_sp(sb_type.
GetSP());
626 if (value_sp && type_impl_sp) {
627 CompilerType ast_type(type_impl_sp->GetCompilerType(
true));
632 sb_value.
SetSP(new_value_sp);
641 lldb::ValueObjectSP new_value_sp;
643 lldb::ValueObjectSP value_sp(
GetSP(locker));
644 lldb::TypeImplSP type_impl_sp(sb_type.
GetSP());
645 if (value_sp && type_impl_sp) {
648 name, **data, exe_ctx, type_impl_sp->GetCompilerType(
true));
651 sb_value.
SetSP(new_value_sp);
658 const bool can_create_synthetic =
false;
665 use_dynamic = target_sp->GetPreferDynamicValue();
672 bool can_create_synthetic) {
675 lldb::ValueObjectSP child_sp;
678 lldb::ValueObjectSP value_sp(
GetSP(locker));
680 const bool can_create =
true;
681 child_sp = value_sp->GetChildAtIndex(idx, can_create);
682 if (can_create_synthetic && !child_sp) {
683 child_sp = value_sp->GetSyntheticArrayMember(idx, can_create);
698 lldb::ValueObjectSP value_sp(
GetSP(locker));
700 idx = value_sp->GetIndexOfChildWithName(
ConstString(name));
714 use_dynamic_value = target_sp->GetPreferDynamicValue();
723 lldb::ValueObjectSP child_sp;
727 lldb::ValueObjectSP value_sp(
GetSP(locker));
729 child_sp = value_sp->GetChildMemberWithName(str_name,
true);
745 value_sb.
SetSP(proxy_sp);
758 value_sb.
SetSP(proxy_sp);
770 value_sb.
SetSP(proxy_sp);
802 return m_opaque_sp->SetUseSynthetic(use_synthetic);
809 lldb::ValueObjectSP value_sp(
GetSP(locker));
811 return value_sp->IsDynamic();
819 lldb::ValueObjectSP value_sp(
GetSP(locker));
821 return value_sp->IsSynthetic();
829 lldb::ValueObjectSP value_sp(
GetSP(locker));
831 return value_sp->IsSyntheticChildrenGenerated();
839 lldb::ValueObjectSP value_sp(
GetSP(locker));
841 return value_sp->SetSyntheticChildrenGenerated(is);
847 lldb::ValueObjectSP child_sp;
849 lldb::ValueObjectSP value_sp(
GetSP(locker));
852 child_sp = value_sp->GetValueForExpressionPath(expr_path);
866 lldb::ValueObjectSP value_sp(
GetSP(locker));
869 uint64_t ret_val = fail_value;
870 ret_val = value_sp->GetValueAsSigned(fail_value, &success);
872 error.SetErrorString(
"could not resolve value");
875 error.SetErrorStringWithFormat(
"could not get SBValue: %s",
886 lldb::ValueObjectSP value_sp(
GetSP(locker));
889 uint64_t ret_val = fail_value;
890 ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
892 error.SetErrorString(
"could not resolve value");
895 error.SetErrorStringWithFormat(
"could not get SBValue: %s",
905 lldb::ValueObjectSP value_sp(
GetSP(locker));
907 return value_sp->GetValueAsSigned(fail_value);
916 lldb::ValueObjectSP value_sp(
GetSP(locker));
918 return value_sp->GetValueAsUnsigned(fail_value);
926 bool has_children =
false;
928 lldb::ValueObjectSP value_sp(
GetSP(locker));
930 has_children = value_sp->MightHaveChildren();
938 bool is_support =
false;
940 lldb::ValueObjectSP value_sp(
GetSP(locker));
942 is_support = value_sp->IsRuntimeSupportValue();
959 lldb::ValueObjectSP value_sp(
GetSP(locker));
961 num_children = value_sp->GetNumChildren(max);
971 lldb::ValueObjectSP value_sp(
GetSP(locker));
991 lldb::ValueObjectSP value_sp(
GetSP(locker));
993 return value_sp->GetCompilerType().GetOpaqueQualType();
1004 sb_target.
SetSP(target_sp);
1014 ProcessSP process_sp;
1017 sb_process.
SetSP(process_sp);
1040 StackFrameSP frame_sp;
1052 return ValueObjectSP();
1061 return GetSP(locker);
1068 lldb::TargetSP target_sp(
sp->GetTargetSP());
1071 bool use_synthetic =
1072 target_sp->TargetProperties::GetEnableSyntheticValue();
1083 lldb::TargetSP target_sp(
sp->GetTargetSP());
1085 bool use_synthetic =
1086 target_sp->TargetProperties::GetEnableSyntheticValue();
1087 SetSP(
sp, use_dynamic, use_synthetic);
1091 SetSP(
sp, use_dynamic,
false);
1096 lldb::TargetSP target_sp(
sp->GetTargetSP());
1099 SetSP(
sp, use_dynamic, use_synthetic);
1122 lldb::ValueObjectSP value_sp(
GetSP(locker));
1124 value_sp->GetExpressionPath(description.
ref());
1131 bool qualify_cxx_base_classes) {
1135 lldb::ValueObjectSP value_sp(
GetSP(locker));
1137 value_sp->GetExpressionPath(description.
ref());
1147 lldb::ValueObjectSP value_sp(
GetSP(locker));
1151 lldb::TargetSP target_sp = value_sp->GetTargetSP();
1173 const char *name)
const {
1176 if (!expr || expr[0] ==
'\0') {
1182 lldb::ValueObjectSP value_sp(
GetSP(locker));
1187 lldb::TargetSP target_sp = value_sp->GetTargetSP();
1192 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1200 ValueObjectSP res_val_sp;
1201 target_sp->EvaluateExpression(expr, frame, res_val_sp, options.
ref(),
nullptr,
1218 lldb::ValueObjectSP value_sp(
GetSP(locker));
1220 value_sp->Dump(strm);
1231 lldb::ValueObjectSP value_sp(
GetSP(locker));
1233 return value_sp->GetFormat();
1241 lldb::ValueObjectSP value_sp(
GetSP(locker));
1243 value_sp->SetFormat(format);
1251 lldb::ValueObjectSP value_sp(
GetSP(locker));
1266 lldb::ValueObjectSP value_sp(
GetSP(locker));
1268 TargetSP target_sp(value_sp->GetTargetSP());
1270 const bool scalar_is_load_address =
true;
1272 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1274 ModuleSP module_sp(value_sp->GetModule());
1279 module_sp->ResolveFileAddress(value, addr);
1296 lldb::ValueObjectSP value_sp(
GetSP(locker));
1298 TargetSP target_sp(value_sp->GetTargetSP());
1301 const bool scalar_is_load_address =
true;
1303 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1305 ModuleSP module_sp(value_sp->GetModule());
1307 module_sp->ResolveFileAddress(value, addr);
1325 lldb::ValueObjectSP value_sp(
GetSP(locker));
1327 TargetSP target_sp(value_sp->GetTargetSP());
1330 value_sp->GetPointeeData(*data_sp, item_idx, item_count);
1331 if (data_sp->GetByteSize() > 0)
1344 lldb::ValueObjectSP value_sp(
GetSP(locker));
1348 value_sp->GetData(*data_sp,
error);
1349 if (
error.Success())
1360 lldb::ValueObjectSP value_sp(
GetSP(locker));
1366 if (!data_extractor) {
1367 error.SetErrorString(
"No data to set");
1372 value_sp->SetData(*data_extractor, set_error);
1375 error.SetErrorStringWithFormat(
"Couldn't set data: %s",
1381 error.SetErrorStringWithFormat(
1382 "Couldn't set data: could not get SBValue: %s",
1394 lldb::ValueObjectSP value_sp(
GetSP(locker));
1406 lldb::ValueObjectSP value_sp(
GetSP(locker));
1410 if (value_sp->GetDeclaration(decl))
1424 lldb::ValueObjectSP value_sp(
GetSP(locker));
1426 if (value_sp && target_sp) {
1428 if (!read && !write)
1429 return sb_watchpoint;
1433 return sb_watchpoint;
1437 return sb_watchpoint;
1440 return sb_watchpoint;
1450 WatchpointSP watchpoint_sp =
1451 target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
1454 if (watchpoint_sp) {
1455 sb_watchpoint.
SetSP(watchpoint_sp);
1457 if (value_sp->GetDeclaration(decl)) {
1462 watchpoint_sp->SetDeclInfo(std::string(ss.
GetString()));
1466 }
else if (target_sp) {
1467 error.SetErrorStringWithFormat(
"could not get SBValue: %s",
1470 error.SetErrorString(
"could not set watchpoint, a target is required");
1473 return sb_watchpoint;
1484 return Watch(resolve_location, read, write,
error);
1494 return sb_watchpoint;
1501 lldb::ValueObjectSP value_sp(
GetSP(locker));
1504 persisted_sb.
SetSP(value_sp->Persist());
1506 return persisted_sb;
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT_VA(...)
StackFrameSP GetFrameSP()
lldb::DynamicValueType m_use_dynamic
lldb::ValueObjectSP GetRootSP()
void SetUseSynthetic(bool use_synthetic)
ValueImpl(const ValueImpl &rhs)=default
ValueImpl(lldb::ValueObjectSP in_valobj_sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, const char *name=nullptr)
lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker, std::unique_lock< std::recursive_mutex > &lock, Status &error)
ValueImpl & operator=(const ValueImpl &rhs)
lldb::DynamicValueType GetUseDynamic()
void SetUseDynamic(lldb::DynamicValueType use_dynamic)
lldb::ValueObjectSP m_valobj_sp
ValueObjectSP GetLockedSP(ValueImpl &in_value)
Process::StopLocker m_stop_locker
std::unique_lock< std::recursive_mutex > m_lock
lldb_private::DataExtractor * get() const
void SetDeclaration(const lldb_private::Declaration &lldb_object_ref)
void SetError(uint32_t err, lldb::ErrorType type)
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
void SetFetchDynamicValue(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
lldb_private::EvaluateExpressionOptions & ref() const
void SetIgnoreBreakpoints(bool ignore=true)
void SetUnwindOnError(bool unwind=true)
lldb::DynamicValueType GetFetchDynamicValue() const
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
void SetSP(const lldb::ProcessSP &process_sp)
void Printf(const char *format,...) __attribute__((format(printf
lldb_private::Stream & ref()
void SetSP(const lldb::TargetSP &target_sp)
void SetThread(const lldb::ThreadSP &lldb_object_sp)
void SetSP(const lldb::TypeFilterImplSP &typefilter_impl_sp)
lldb_private::TypeSummaryOptions & ref()
void SetSP(const lldb::TypeSummaryImplSP &typefilter_impl_sp)
void SetSP(const lldb::ScriptedSyntheticChildrenSP &typefilter_impl_sp)
void SetSP(const lldb::TypeImplSP &type_impl_sp)
bool SetData(lldb::SBData &data, lldb::SBError &error)
bool GetDescription(lldb::SBStream &description)
lldb::SBValue EvaluateExpression(const char *expr) const
lldb::SBValue GetChildAtIndex(uint32_t idx)
lldb::SBTypeFilter GetTypeFilter()
lldb::SBAddress GetAddress()
lldb::SBData GetPointeeData(uint32_t item_idx=0, uint32_t item_count=1)
Get an SBData wrapping what this SBValue points to.
const char * GetTypeName()
bool GetExpressionPath(lldb::SBStream &description)
lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type)
void SetSP(const lldb::ValueObjectSP &sp)
lldb::SBValue CreateValueFromAddress(const char *name, lldb::addr_t address, lldb::SBType type)
const char * GetDisplayTypeName()
lldb::SBValue CreateValueFromExpression(const char *name, const char *expression)
lldb::SBData GetData()
Get an SBData wrapping the contents of this SBValue.
lldb::SBValue Clone(const char *new_name)
Creates a copy of the SBValue with a new name and setting the current SBValue as its parent.
void SetSyntheticChildrenGenerated(bool)
lldb::SBProcess GetProcess()
const char * GetLocation()
lldb::SBValue & operator=(const lldb::SBValue &rhs)
int64_t GetValueAsSigned(lldb::SBError &error, int64_t fail_value=0)
lldb::SBWatchpoint WatchPointee(bool resolve_location, bool read, bool write, SBError &error)
Watch this value that this value points to in memory.
lldb::SBWatchpoint Watch(bool resolve_location, bool read, bool write, SBError &error)
Watch this value if it resides in memory.
lldb::SBTypeFormat GetTypeFormat()
bool MightHaveChildren()
Find out if a SBValue might have children.
lldb::SBTypeSummary GetTypeSummary()
lldb::SBValue GetDynamicValue(lldb::DynamicValueType use_dynamic)
bool IsSyntheticChildrenGenerated()
lldb::SBValue CreateChildAtOffset(const char *name, uint32_t offset, lldb::SBType type)
lldb::SBValue Dereference()
std::shared_ptr< ValueImpl > ValueImplSP
lldb::SBValue GetStaticValue()
lldb::SBValue Cast(lldb::SBType type)
lldb::SBValue GetNonSyntheticValue()
bool GetPreferSyntheticValue()
uint32_t GetIndexOfChildWithName(const char *name)
const char * GetObjectDescription()
const char * GetSummary()
lldb::ValueObjectSP GetSP() const
Same as the protected version of GetSP that takes a locker, except that we make the locker locally in...
lldb::SBTypeSynthetic GetTypeSynthetic()
void SetFormat(lldb::Format format)
lldb::SBValue AddressOf()
lldb::DynamicValueType GetPreferDynamicValue()
lldb::SBThread GetThread()
lldb::SBValue GetChildMemberWithName(const char *name)
lldb::SBTarget GetTarget()
uint64_t GetValueAsUnsigned(lldb::SBError &error, uint64_t fail_value=0)
uint32_t GetNumChildren()
void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic)
lldb::SBValue GetValueForExpressionPath(const char *expr_path)
lldb::addr_t GetLoadAddress()
bool SetValueFromCString(const char *value_str)
void SetPreferSyntheticValue(bool use_synthetic)
lldb::SBDeclaration GetDeclaration()
bool IsRuntimeSupportValue()
void SetSP(const lldb::WatchpointSP &sp)
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
Generic representation of a type in a programming language.
A uniqued constant string class.
bool IsEmpty() const
Test for empty string.
A class that describes the declaration location of a lldb object.
bool DumpStopContext(Stream *s, bool show_fullpaths) const
FileSpec & GetFile()
Get accessor for file specification.
void SetKeepInMemory(bool keep=true)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
bool TryLock(ProcessRunLock *lock)
This base class provides an interface to stack frames.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
bool Success() const
Test for success condition.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
std::recursive_mutex & GetAPIMutex()
static lldb::ValueObjectSP CreateValueObjectFromExpression(llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx)
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type)
#define LLDB_WATCH_TYPE_WRITE
#define LLDB_WATCH_TYPE_READ
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
@ eAddressTypeFile
Address is an address as found in an object or symbol file.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
@ eAddressTypeHost
Address is an address in the process that is running this code.
Format
Display format definitions.