22#include "lldb/Host/Config.h"
54#include "llvm/Support/Compiler.h"
93 m_flags.m_is_synthetic_children_generated =
110 const ArchSpec &arch = target_sp->GetArchitecture();
123 bool did_change_formats =
false;
137 if (update_format && !did_change_formats)
151 m_flags.m_old_value_valid =
false;
153 m_flags.m_old_value_valid =
true;
168 bool need_compare_checksums =
false;
169 llvm::SmallVector<uint8_t, 16> old_checksum;
172 need_compare_checksums =
true;
175 old_checksum.begin());
184 const uint64_t max_checksum_size = 128;
187 need_compare_checksums =
false;
191 assert(!need_compare_checksums ||
196 else if (!
m_flags.m_value_did_change && !success) {
200 }
else if (need_compare_checksums) {
215 "[%s %p] checking for FormatManager revisions. ValueObject "
216 "rev: %d - Global rev: %d",
217 GetName().GetCString(),
static_cast<void *
>(
this),
221 bool any_change =
false;
245 m_flags.m_children_count_valid =
false;
246 m_flags.m_did_calculate_complete_objc_class_type =
false;
257 if (
m_flags.m_did_calculate_complete_objc_class_type) {
261 return compiler_type;
264 m_flags.m_did_calculate_complete_objc_class_type =
true;
270 return compiler_type;
274 if (std::optional<CompilerType> complete_type =
275 runtime->GetRuntimeType(compiler_type)) {
281 return compiler_type;
302 switch (value_type) {
328 sstr.
Printf(
"0x%*.*llx", addr_nibble_size, addr_nibble_size,
347 if (bitfield_bit_size)
358 LazyBool is_logical_true = language->IsLogicalTrue(*
this,
error);
359 switch (is_logical_true) {
362 return (is_logical_true ==
true);
390 "ValueObject: '{0}' not owned by its parent: '{1}'", child->
GetName(),
406 if (can_create && !
m_children.HasChildAtIndex(idx)) {
413 if (child !=
nullptr)
414 return child->
GetSP();
421 if (names.size() == 0)
424 for (llvm::StringRef name : names) {
425 root = root->GetChildMemberWithName(name);
433llvm::Expected<size_t>
435 bool omit_empty_base_classes =
true;
437 omit_empty_base_classes);
449 std::vector<uint32_t> child_indexes;
450 bool omit_empty_base_classes =
true;
455 const size_t num_child_indexes =
457 name, omit_empty_base_classes, child_indexes);
458 if (num_child_indexes == 0)
462 for (uint32_t idx : child_indexes)
464 child_sp = child_sp->GetChildAtIndex(idx, can_create);
472 if (
m_flags.m_children_count_valid) {
473 size_t children_count =
m_children.GetChildrenCount();
474 return children_count <= max ? children_count : max;
479 if (!
m_flags.m_children_count_valid) {
481 if (num_children_or_err)
484 return num_children_or_err;
492 return *value_or_err;
499 bool has_children =
false;
502 if (type_info & (eTypeHasChildren | eTypeIsPointer | eTypeIsReference))
512 m_flags.m_children_count_valid =
true;
517 bool omit_empty_base_classes =
true;
518 bool ignore_array_bounds =
false;
519 std::string child_name;
520 uint32_t child_byte_size = 0;
521 int32_t child_byte_offset = 0;
522 uint32_t child_bitfield_bit_size = 0;
523 uint32_t child_bitfield_bit_offset = 0;
524 bool child_is_base_class =
false;
525 bool child_is_deref_of_parent =
false;
526 uint64_t language_flags = 0;
527 const bool transparent_pointers =
true;
531 auto child_compiler_type_or_err =
533 &exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
534 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
535 child_bitfield_bit_size, child_bitfield_bit_offset,
536 child_is_base_class, child_is_deref_of_parent,
this, language_flags);
537 if (!child_compiler_type_or_err || !child_compiler_type_or_err->IsValid()) {
539 child_compiler_type_or_err.takeError(),
540 "could not find child: {0}");
545 *
this, *child_compiler_type_or_err,
ConstString(child_name),
546 child_byte_size, child_byte_offset, child_bitfield_bit_size,
547 child_bitfield_bit_offset, child_is_base_class, child_is_deref_of_parent,
552 bool omit_empty_base_classes =
true;
553 bool ignore_array_bounds =
true;
554 std::string child_name;
555 uint32_t child_byte_size = 0;
556 int32_t child_byte_offset = 0;
557 uint32_t child_bitfield_bit_size = 0;
558 uint32_t child_bitfield_bit_offset = 0;
559 bool child_is_base_class =
false;
560 bool child_is_deref_of_parent =
false;
561 uint64_t language_flags = 0;
562 const bool transparent_pointers =
false;
566 auto child_compiler_type_or_err =
568 &exe_ctx, 0, transparent_pointers, omit_empty_base_classes,
569 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
570 child_bitfield_bit_size, child_bitfield_bit_offset,
571 child_is_base_class, child_is_deref_of_parent,
this, language_flags);
572 if (!child_compiler_type_or_err) {
574 child_compiler_type_or_err.takeError(),
575 "could not find child: {0}");
579 if (child_compiler_type_or_err->IsValid()) {
580 child_byte_offset += child_byte_size * idx;
583 *
this, *child_compiler_type_or_err,
ConstString(child_name),
584 child_byte_size, child_byte_offset, child_bitfield_bit_size,
585 child_bitfield_bit_offset, child_is_base_class,
592 return synth_valobj_sp->GetChildAtIndex(idx,
true).get();
598 std::string &destination,
605 std::string &destination,
613 destination =
"<incomplete type>";
619 if (
m_flags.m_is_getting_summary)
622 m_flags.m_is_getting_summary =
true;
646 target_sp->GetSummaryStatisticsCache()
647 .GetSummaryStatisticsForProvider(*summary_ptr);
651 summary_ptr->
FormatObject(
this, destination, actual_options);
653 summary_ptr->
FormatObject(
this, destination, actual_options);
655 m_flags.m_is_getting_summary =
false;
656 return !destination.empty();
679 bool is_char_arr_ptr(type_flags.
AnySet(eTypeIsArray | eTypeIsPointer) &&
680 pointee_or_element_compiler_type.
IsCharType());
681 if (!is_char_arr_ptr)
685 if (type_flags.
Test(eTypeIsArray))
692 uint32_t item_count) {
694 const uint32_t type_info =
GetTypeInfo(&pointee_or_element_compiler_type);
695 const bool is_pointer_type = type_info & eTypeIsPointer;
696 const bool is_array_type = type_info & eTypeIsArray;
697 if (!(is_pointer_type || is_array_type))
705 std::optional<uint64_t> item_type_size =
706 llvm::expectedToOptional(pointee_or_element_compiler_type.
GetByteSize(
710 const uint64_t bytes = item_count * *item_type_size;
711 const uint64_t offset = item_idx * *item_type_size;
713 if (item_idx == 0 && item_count == 1)
715 if (is_pointer_type) {
718 if (
error.Fail() || pointee_sp.get() ==
nullptr)
720 return pointee_sp->GetData(data,
error);
723 if (child_sp.get() ==
nullptr)
726 return child_sp->GetData(data,
error);
736 auto [addr, addr_type] =
743 addr = addr + offset;
745 module_sp->ResolveFileAddress(addr, so_addr);
752 if (
error.Success()) {
766 target->ReadMemory(target_addr, heap_buf_ptr->
GetBytes(), bytes,
768 if (!
error.Success()) {
773 size_t file_bytes_read =
774 target->ReadMemory(target_addr, heap_buf_ptr->
GetBytes(), bytes,
776 if (file_error.
Success() || file_bytes_read > 0) {
777 bytes_read = file_bytes_read;
778 error = std::move(file_error);
781 if (
error.Success() || bytes_read > 0) {
790 if (max_bytes && *max_bytes > offset) {
791 size_t bytes_read = std::min<uint64_t>(*max_bytes - offset, bytes);
795 heap_buf_ptr->
CopyData((uint8_t *)(addr + offset), bytes_read);
812 if (
m_data.GetByteSize()) {
840 const size_t byte_size = llvm::expectedToOptional(
GetByteSize()).value_or(0);
844 switch (value_type) {
850 m_value.GetScalar().SetValueFromData(data, encoding, byte_size);
854 "unable to set scalar value: %s", set_error.
AsCString());
867 if (!
error.Success())
869 if (bytes_written != byte_size) {
879 m_data.SetData(buffer_sp, 0);
881 const_cast<uint8_t *
>(
m_data.GetDataStart()),
882 byte_size,
m_data.GetByteOrder());
902 if ((uint64_t)
m_data.GetDataStart() == start)
905 if ((uint64_t)
m_value.GetBuffer().GetBytes() == start)
906 return m_value.GetBuffer().GetData();
913 llvm::StringRef src = source.
GetString();
914 src = src.rtrim(
'\0');
915 destination = std::make_shared<DataBufferHeap>(src.size(), 0);
916 memcpy(destination->GetBytes(), src.data(), src.size());
920std::pair<size_t, bool>
923 bool was_capped =
false;
929 s <<
"<no target to read from>";
932 return {0, was_capped};
937 size_t bytes_read = 0;
938 size_t total_bytes_read = 0;
943 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer) &&
948 bool capped_data =
false;
949 const bool is_array = type_flags.
Test(eTypeIsArray);
952 uint64_t array_size = 0;
953 if (compiler_type.
IsArrayType(
nullptr, &array_size)) {
954 cstr_len = array_size;
955 if (cstr_len > max_length) {
957 cstr_len = max_length;
966 if (cstr_address.
address == 0 ||
974 const uint8_t *cstr = data.
PeekData(0, 1);
975 if (cstr ==
nullptr) {
976 s <<
"<invalid address>";
979 return {0, was_capped};
981 cstr_len = std::min<uint64_t>(cstr_len, data.
GetByteSize());
982 s << llvm::StringRef(reinterpret_cast<const char *>(cstr), cstr_len);
984 return {cstr_len, was_capped};
986 s <<
"<invalid address>";
989 return {0, was_capped};
995 if (cstr_len > 0 && honor_array) {
1003 total_bytes_read = bytes_read;
1004 for (
size_t offset = 0; offset < bytes_read; offset++)
1010 cstr_len = max_length;
1011 const size_t k_max_buf_size = 64;
1015 int cstr_len_displayed = -1;
1016 bool capped_cstr =
false;
1021 while ((bytes_read =
GetPointeeData(data, offset, k_max_buf_size)) > 0) {
1022 total_bytes_read += bytes_read;
1025 const uint8_t *bytes = data.
PeekData(0, bytes_read);
1026 if (bytes ==
nullptr)
1028 size_t len = strnlen(
reinterpret_cast<const char *
>(bytes), bytes_read);
1029 if (cstr_len_displayed < 0)
1030 cstr_len_displayed = len;
1034 cstr_len_displayed += len;
1035 if (len > bytes_read)
1040 for (
size_t offset = 0; offset < bytes_read; offset++)
1043 if (len < k_max_buf_size)
1046 if (len >= cstr_len) {
1055 if (cstr_len_displayed >= 0) {
1062 s <<
"<not a string object>";
1065 return {total_bytes_read, was_capped};
1070 return llvm::createStringError(
"could not update value");
1079 return llvm::createStringError(
"no process");
1082 auto get_object_description =
1083 [&](
LanguageType language) -> llvm::Expected<std::string> {
1086 if (llvm::Error
error = runtime->GetObjectDescription(s, *
this))
1091 return llvm::createStringError(
"no native language runtime");
1096 llvm::Expected<std::string> desc = get_object_description(native_language);
1104 llvm::consumeError(desc.takeError());
1111 std::string &destination) {
1119 std::string &destination) {
1131 if (
m_flags.m_is_bitfield_for_scalar)
1137 my_format = reg_info->
format;
1147 format_sp = std::make_shared<TypeFormatImpl_Format>(my_format);
1208 return llvm::createStringError(
"type cannot be converted to APSInt");
1216 return llvm::createStringError(
"error occurred; unable to convert to APSInt");
1221 return llvm::createStringError(
"type cannot be converted to APFloat");
1229 return llvm::createStringError(
1230 "error occurred; unable to convert to APFloat");
1239 return value_or_err->getBoolValue();
1242 "GetValueAsAPSInt failed: {0}");
1247 return value_or_err->isNonZero();
1250 "GetValueAsAPFloat failed: {0}");
1257 return llvm::createStringError(
"type cannot be converted to bool");
1261 bool can_update_var) {
1267 return llvm::createStringError(
1268 "Not allowed to change the value of a non-scalar object");
1273 return llvm::createStringError(
1274 "Not allowed to update program variables in this case");
1278 return llvm::createStringError(
1279 "Not allowed to change the value of a constant");
1283 uint64_t byte_size = 0;
1285 if (!val_type.
IsBoolean() || (!value.isOne() && !value.isZero())) {
1286 byte_size = llvm::expectedToOptional(
GetByteSize()).value_or(0);
1288 unsigned dest_bits = byte_size * CHAR_BIT;
1289 unsigned needed_bits = val_type.
IsSigned() ? value.getSignificantBits()
1290 : value.getActiveBits();
1291 if (needed_bits > dest_bits)
1292 return llvm::createStringError(
"Illegal argument: new value is too big");
1301 llvm::APInt sized_value = value;
1302 if (sized_value.getBitWidth() < byte_size * CHAR_BIT)
1303 sized_value = sized_value.sext(byte_size * CHAR_BIT);
1307 reinterpret_cast<const void *
>(sized_value.getRawData()), byte_size,
1308 target->GetArchitecture().GetByteOrder(),
1309 static_cast<uint8_t
>(target->GetArchitecture().GetAddressByteSize()));
1311 return error.takeError();
1315 bool can_update_var) {
1321 return llvm::createStringError(
"Not allowed to update a non-scalar object");
1326 return llvm::createStringError(
1327 "Not allowed to update program variables in this case");
1330 CompilerType new_val_type = new_val_sp->GetCompilerType();
1333 return llvm::createStringError(
1334 "Illegal argument: new value is not a scalar object");
1337 auto value_or_err = new_val_sp->GetValueAsAPSInt();
1341 auto value_or_err = new_val_sp->GetValueAsAPFloat();
1346 bool success =
true;
1347 uint64_t int_val = new_val_sp->GetValueAsUnsigned(0, &success);
1350 uint64_t num_bits = 0;
1351 if (
auto temp = llvm::expectedToOptional(
1352 new_val_sp->GetCompilerType().GetBitSize(target.get())))
1353 num_bits = temp.value();
1357 return llvm::createStringError(
"Error converting new_val_sp to integer");
1359 llvm_unreachable(
"Unrecognized type for RHS of assignment");
1369 if (flags.
AnySet(eTypeIsArray | eTypeIsPointer) &&
1376 if (flags.
Test(eTypeIsArray)) {
1402 bool do_dump_error) {
1415 bool allow_special =
1417 const bool only_special =
false;
1419 if (allow_special) {
1420 if (flags.
AnySet(eTypeIsArray | eTypeIsPointer) &&
1433 std::pair<size_t, bool> read_string =
1437 lldb_private::formatters::StringPrinter::
1438 ReadBufferAndDumpToStreamOptions options(*
this);
1442 options.SetStream(&s);
1443 options.SetPrefixToken(
nullptr);
1444 options.SetQuote(
'"');
1445 options.SetSourceSize(buffer_sp->GetByteSize());
1446 options.SetIsTruncated(read_string.second);
1448 options.SetZeroTermination(
1451 options.SetZeroTermination(
1455 lldb_private::formatters::StringPrinter::StringElementType::ASCII>(
1457 return !
error.Fail();
1465 if (flags.
Test(eTypeIsArray)) {
1471 for (
size_t low = 0; low < count; low++) {
1478 s <<
"<invalid child>";
1481 child->DumpPrintableRepresentation(
1512 for (
size_t low = 0; low < count; low++) {
1519 s <<
"<invalid child>";
1522 child->DumpPrintableRepresentation(
1555 bool var_success =
false;
1558 llvm::StringRef str;
1569 switch (val_obj_display) {
1581 strm <<
"error: " <<
toString(desc.takeError());
1595 strm.
Printf(
"%" PRIu32, *err);
1598 strm <<
"error: " <<
toString(err.takeError());
1646 else if (val_obj_display ==
1648 s.
PutCString(
"<not a valid Objective-C object>");
1653 s.
PutCString(
"<no printable representation>");
1677 switch (
m_value.GetValueType()) {
1681 if (scalar_is_load_address) {
1690 m_value.GetValueAddressType()};
1694 llvm_unreachable(
"Unhandled value type!");
1701 if (
ABISP abi_sp = process->GetABI())
1702 return abi_sp->FixCodeAddress(address);
1704 return std::nullopt;
1711 switch (
m_value.GetValueType()) {
1726 llvm_unreachable(
"Unhandled value type!");
1730 const char *value_str) {
1732 if (
auto boolean = language->GetBooleanFromString(value_str))
1733 return *
boolean ?
"1" :
"0";
1735 return llvm::StringSwitch<const char *>(value_str)
1738 .Default(value_str);
1756 const size_t byte_size = llvm::expectedToOptional(
GetByteSize()).value_or(0);
1762 m_value.GetScalar().SetValueFromCString(value_str, encoding, byte_size);
1763 }
else if (byte_size <= 16) {
1772 if (
error.Success()) {
1773 switch (value_type) {
1784 target_addr, new_scalar, byte_size,
error);
1785 if (!
error.Success())
1787 if (bytes_written != byte_size) {
1800 m_data.SetData(buffer_sp, 0);
1801 bool success = new_scalar.
GetData(new_data);
1804 0, byte_size,
const_cast<uint8_t *
>(
m_data.GetDataStart()),
1805 byte_size,
m_data.GetByteOrder());
1843 std::map<ConstString, ValueObject *>::const_iterator pos =
1846 synthetic_child_sp = pos->second->GetSP();
1847 return synthetic_child_sp;
1870 if (runtime->IsAllowedRuntimeValue(
GetName()))
1878 return language->IsNilReference(*
this);
1885 return language->IsUninitializedReference(*
this);
1903 uint64_t array_size = 0;
1906 index >= array_size)
1911 std::string index_str = llvm::formatv(
"[{0}]", index);
1916 if (!synthetic_child_sp) {
1923 if (synthetic_child) {
1925 synthetic_child_sp = synthetic_child->
GetSP();
1926 synthetic_child_sp->SetName(index_str);
1927 synthetic_child_sp->m_flags.m_is_array_item_for_pointer =
true;
1931 return synthetic_child_sp;
1941 std::optional<uint64_t> byte_size = llvm::expectedToOptional(
GetByteSize());
1942 if (!byte_size || to / 8 >= *byte_size)
1948 std::string index_str = llvm::formatv(
"[{0}-{1}]", from, to);
1953 if (!synthetic_child_sp) {
1954 uint32_t bit_field_size = to - from + 1;
1955 uint32_t bit_field_offset = from;
1958 llvm::expectedToOptional(
GetByteSize()).value_or(0) * 8 -
1959 bit_field_size - bit_field_offset;
1964 llvm::expectedToOptional(
GetByteSize()).value_or(0), 0,
1969 if (synthetic_child) {
1971 synthetic_child_sp = synthetic_child->
GetSP();
1972 synthetic_child_sp->SetName(index_str);
1973 synthetic_child_sp->m_flags.m_is_bitfield_for_scalar =
true;
1977 return synthetic_child_sp;
1981 uint32_t offset,
const CompilerType &type,
bool can_create,
1986 if (name_const_str.
IsEmpty()) {
1987 name_const_str.
SetString(
"@" + std::to_string(offset));
1994 if (synthetic_child_sp.get())
1995 return synthetic_child_sp;
2001 std::optional<uint64_t> size = llvm::expectedToOptional(
2008 if (synthetic_child) {
2010 synthetic_child_sp = synthetic_child->
GetSP();
2011 synthetic_child_sp->SetName(name_const_str);
2012 synthetic_child_sp->m_flags.m_is_child_at_offset =
true;
2013 synthetic_child_sp->SetSyntheticChildrenGenerated(
true);
2015 return synthetic_child_sp;
2024 if (name_const_str.
IsEmpty()) {
2026 snprintf(name_str,
sizeof(name_str),
"base%s@%i",
2035 if (synthetic_child_sp.get())
2036 return synthetic_child_sp;
2041 const bool is_base_class =
true;
2044 std::optional<uint64_t> size = llvm::expectedToOptional(
2051 if (synthetic_child) {
2053 synthetic_child_sp = synthetic_child->
GetSP();
2054 synthetic_child_sp->SetName(name_const_str);
2056 return synthetic_child_sp;
2063static llvm::StringRef
2065 if (expression.starts_with(
'.'))
2066 return expression.drop_front();
2067 if (expression.starts_with(
"->"))
2068 return expression.drop_front(2);
2080 if (!synthetic_child_sp) {
2084 expression,
nullptr,
nullptr,
2090 if (synthetic_child_sp.get()) {
2094 synthetic_child_sp->SetName(
2098 return synthetic_child_sp;
2103 if (target_sp && !target_sp->GetEnableSyntheticValue()) {
2115 if (curr_synth_sp.get() ==
nullptr)
2187 if (
m_flags.m_is_synthetic_children_generated) {
2196 uint64_t load_addr =
2217 if (is_deref_of_parent &&
2249 if (
m_flags.m_is_array_item_for_pointer &&
2254 if (!is_deref_of_parent) {
2256 if (non_base_class_parent &&
2260 if (non_base_class_parent_compiler_type) {
2265 const uint32_t non_base_class_parent_type_info =
2266 non_base_class_parent_compiler_type.
GetTypeInfo();
2268 if (non_base_class_parent_type_info & eTypeIsPointer) {
2270 }
else if ((non_base_class_parent_type_info & eTypeHasChildren) &&
2271 !(non_base_class_parent_type_info &
2272 (eTypeIsArray | eTypeIsVector))) {
2285 if (is_deref_of_parent &&
2297 using SynthTraversal =
2301 if (synth_traversal == SynthTraversal::FromSynthetic ||
2302 synth_traversal == SynthTraversal::Both)
2305 if (synth_traversal == SynthTraversal::ToSynthetic ||
2306 synth_traversal == SynthTraversal::Both)
2321 if (!result ||
error.Fail()) {
2324 result = alt_obj->Dereference(
error);
2344 expression, reason_to_stop ? reason_to_stop : &dummy_reason_to_stop,
2345 final_value_type ? final_value_type : &dummy_final_value_type, options,
2346 final_task_on_target ? final_task_on_target
2347 : &dummy_final_task_on_target);
2349 if (!final_task_on_target ||
2353 if (ret_val.get() &&
2354 ((final_value_type ? *final_value_type : dummy_final_value_type) ==
2358 if ((final_task_on_target ? *final_task_on_target
2359 : dummy_final_task_on_target) ==
2364 if (
error.Fail() || !final_value.get()) {
2368 if (final_value_type)
2372 if (final_task_on_target)
2377 if (*final_task_on_target ==
2381 if (
error.Fail() || !final_value.get()) {
2385 if (final_value_type)
2389 if (final_task_on_target)
2409 llvm::StringRef remainder = expression;
2412 llvm::StringRef temp_expression = remainder;
2414 CompilerType root_compiler_type = root->GetCompilerType();
2416 Flags pointee_compiler_type_info;
2418 Flags root_compiler_type_info(
2419 root_compiler_type.
GetTypeInfo(&pointee_compiler_type));
2420 if (pointee_compiler_type)
2423 if (temp_expression.empty()) {
2428 switch (temp_expression.front()) {
2430 temp_expression = temp_expression.drop_front();
2432 root_compiler_type_info.
Test(eTypeIsPointer))
2442 if (root_compiler_type_info.
Test(eTypeIsObjC) &&
2445 root_compiler_type_info.
Test(eTypeIsPointer) &&
2452 if (!temp_expression.starts_with(
">")) {
2463 temp_expression.front() ==
'.' &&
2464 root_compiler_type_info.
Test(eTypeIsPointer))
2474 temp_expression = temp_expression.drop_front();
2476 size_t next_sep_pos = temp_expression.find_first_of(
"-.[", 1);
2477 if (next_sep_pos == llvm::StringRef::npos) {
2479 llvm::StringRef child_name = temp_expression;
2481 root->GetChildMemberWithName(child_name);
2482 if (!child_valobj_sp) {
2485 child_valobj_sp = altroot->GetChildMemberWithName(child_name);
2487 if (child_valobj_sp) {
2491 return child_valobj_sp;
2498 llvm::StringRef next_separator = temp_expression.substr(next_sep_pos);
2499 llvm::StringRef child_name = temp_expression.slice(0, next_sep_pos);
2501 ValueObjectSP child_valobj_sp = root->GetChildMemberWithName(child_name);
2502 if (!child_valobj_sp) {
2505 child_valobj_sp = altroot->GetChildMemberWithName(child_name);
2507 if (child_valobj_sp) {
2508 root = child_valobj_sp;
2509 remainder = next_separator;
2518 if (!root_compiler_type_info.
Test(eTypeIsArray) &&
2519 !root_compiler_type_info.
Test(eTypeIsPointer) &&
2520 !root_compiler_type_info.
Test(
2523 if (!root_compiler_type_info.
Test(
2545 if (temp_expression.size() == 1) {
2552 if (temp_expression[1] ==
2555 if (!root_compiler_type_info.
Test(eTypeIsArray)) {
2571 size_t close_bracket_position = temp_expression.find(
']', 1);
2572 if (close_bracket_position ==
2573 llvm::StringRef::npos)
2581 llvm::StringRef bracket_expr =
2582 temp_expression.slice(1, close_bracket_position);
2586 assert(!bracket_expr.empty());
2588 if (!bracket_expr.contains(
'-')) {
2592 unsigned long index = 0;
2593 if (bracket_expr.getAsInteger(0, index)) {
2600 !root_compiler_type_info.
Test(eTypeIsPointer) &&
2609 if (root_compiler_type_info.
Test(eTypeIsArray)) {
2610 ValueObjectSP child_valobj_sp = root->GetChildAtIndex(index);
2611 if (!child_valobj_sp)
2612 child_valobj_sp = root->GetSyntheticArrayMember(index,
true);
2613 if (!child_valobj_sp)
2614 if (root->HasSyntheticValue() &&
2615 llvm::expectedToOptional(
2616 root->GetSyntheticValue()->GetNumChildren())
2617 .value_or(0) > index)
2619 root->GetSyntheticValue()->GetChildAtIndex(index);
2620 if (child_valobj_sp) {
2621 root = child_valobj_sp;
2623 temp_expression.substr(close_bracket_position + 1);
2632 }
else if (root_compiler_type_info.
Test(eTypeIsPointer)) {
2644 pointee_compiler_type_info.
Test(eTypeIsScalar)) {
2648 if (
error.Fail() || !root) {
2658 if (root->GetCompilerType().GetMinimumLanguage() ==
2660 pointee_compiler_type_info.
AllClear(eTypeIsPointer) &&
2661 root->HasSyntheticValue() &&
2664 SyntheticChildrenTraversal::ToSynthetic ||
2667 SyntheticChildrenTraversal::Both)) {
2668 root = root->GetSyntheticValue()->GetChildAtIndex(index);
2670 root = root->GetSyntheticArrayMember(index,
true);
2678 temp_expression.substr(close_bracket_position + 1);
2683 }
else if (root_compiler_type_info.
Test(eTypeIsScalar)) {
2684 root = root->GetSyntheticBitFieldChild(index, index,
true);
2693 *reason_to_stop = ValueObject::
2694 eExpressionPathScanEndReasonBitfieldRangeOperatorMet;
2698 }
else if (root_compiler_type_info.
Test(eTypeIsVector)) {
2699 root = root->GetChildAtIndex(index);
2707 temp_expression.substr(close_bracket_position + 1);
2713 SyntheticChildrenTraversal::ToSynthetic ||
2716 SyntheticChildrenTraversal::Both) {
2717 if (root->HasSyntheticValue())
2718 root = root->GetSyntheticValue();
2719 else if (!root->IsSynthetic()) {
2734 root = root->GetChildAtIndex(index);
2742 temp_expression.substr(close_bracket_position + 1);
2754 llvm::StringRef sleft, sright;
2755 unsigned long low_index, high_index;
2756 std::tie(sleft, sright) = bracket_expr.split(
'-');
2757 if (sleft.getAsInteger(0, low_index) ||
2758 sright.getAsInteger(0, high_index)) {
2765 if (low_index > high_index)
2766 std::swap(low_index, high_index);
2776 if (root_compiler_type_info.
Test(
2779 root = root->GetSyntheticBitFieldChild(low_index, high_index,
true);
2786 *reason_to_stop = ValueObject::
2787 eExpressionPathScanEndReasonBitfieldRangeOperatorMet;
2791 }
else if (root_compiler_type_info.
Test(
2798 pointee_compiler_type_info.
Test(eTypeIsScalar)) {
2802 if (
error.Fail() || !root) {
2885 result_sp =
GetSP();
2888 bool is_synthetic = result_sp->IsSynthetic();
2889 if (synthValue && !is_synthetic) {
2890 if (
auto synth_sp = result_sp->GetSyntheticValue())
2893 if (!synthValue && is_synthetic) {
2894 if (
auto non_synth_sp = result_sp->GetNonSyntheticValue())
2895 return non_synth_sp;
2905 std::string deref_name_str;
2906 uint32_t deref_byte_size = 0;
2907 int32_t deref_byte_offset = 0;
2909 uint64_t language_flags = 0;
2915 &exe_ctx, deref_name_str, deref_byte_size, deref_byte_offset,
this,
2918 std::string deref_error;
2919 if (deref_compiler_type_or_err) {
2920 deref_compiler_type = *deref_compiler_type_or_err;
2922 deref_error = llvm::toString(deref_compiler_type_or_err.takeError());
2926 if (deref_compiler_type && deref_byte_size) {
2928 if (!deref_name_str.empty())
2929 deref_name.
SetCString(deref_name_str.c_str());
2933 deref_byte_size, deref_byte_offset, 0, 0,
false,
2946 if (deref_compiler_type) {
2948 if (!deref_name_str.empty())
2949 deref_name.
SetCString(deref_name_str.c_str());
2952 *
this, deref_compiler_type, deref_name, deref_byte_size,
2969 if (deref_error.empty())
2971 "dereference failed: (%s) %s",
2975 "dereference failed: %s: (%s) %s", deref_error.c_str(),
2985 switch (address_type) {
3000 if (compiler_type) {
3001 std::string name(1,
'&');
3002 name.append(
m_name.AsCString(
""));
3021 "'%s' doesn't have a valid address", expr_path_strm.
GetData());
3051 if (llvm::expectedToOptional(compiler_type.
GetByteSize(exe_scope))
3056 return DoCast(compiler_type);
3059 "Can only cast to a type that is equal to or smaller "
3060 "than the orignal type.");
3100 const bool scalar_is_load_address =
true;
3101 auto [addr_value, addr_type] =
GetAddressOf(scalar_is_load_address);
3108 module_sp->ResolveFileAddress(addr_value, tmp_addr);
3120 CompilerType type,
const llvm::ArrayRef<uint32_t> &base_type_indices) {
3125 return llvm::createStringError(
3126 "Invalid target type: should be a pointer or a reference");
3132 auto target_record_type =
3134 auto start_record_type =
3137 if (!target_record_type.IsRecordType() || !start_record_type.IsRecordType())
3138 return llvm::createStringError(
3139 "Underlying start & target types should be record types");
3141 if (target_record_type.CompareTypes(start_record_type))
3142 return llvm::createStringError(
3143 "Underlying start & target types should be different");
3145 if (base_type_indices.empty())
3146 return llvm::createStringError(
"children sequence must be non-empty");
3155 for (
const uint32_t i : base_type_indices)
3158 inner_value->GetChildAtIndex(i,
true);
3162 CompilerType inner_value_type = inner_value->GetCompilerType();
3165 return llvm::createStringError(
3166 "casted value doesn't match the desired type");
3168 uintptr_t addr = inner_value->GetLoadAddress();
3169 llvm::StringRef name =
"";
3177 return llvm::createStringError(
3178 "casted value doesn't match the desired type");
3183llvm::Expected<lldb::ValueObjectSP>
3189 return llvm::createStringError(
3190 "Invalid target type: should be a pointer or a reference");
3196 auto target_record_type =
3198 auto start_record_type =
3201 if (!target_record_type.IsRecordType() || !start_record_type.IsRecordType())
3202 return llvm::createStringError(
3203 "Underlying start & target types should be record types");
3205 if (target_record_type.CompareTypes(start_record_type))
3206 return llvm::createStringError(
3207 "Underlying start & target types should be different");
3210 if (target_record_type.IsVirtualBase(start_record_type, &virtual_base)) {
3212 return llvm::createStringError(
"virtual base should be valid");
3213 return llvm::createStringError(
3230 llvm::StringRef name =
"";
3233 name, addr - offset, exe_ctx, pointer_type,
false);
3241 return value->Dereference(
error);
3258 if (!is_scalar && !is_enum && !is_pointer)
3264 uint64_t type_byte_size = 0;
3265 uint64_t val_byte_size = 0;
3266 if (
auto temp = llvm::expectedToOptional(type.
GetByteSize(target.get())))
3267 type_byte_size = temp.value();
3270 val_byte_size = temp.value();
3277 if (!type.
IsBoolean() && type_byte_size < val_byte_size)
3281 "target type cannot be smaller than the pointer type"));
3285 if (!is_scalar || is_integer)
3289 else if (is_scalar && is_float) {
3291 if (float_value_or_err)
3294 !float_value_or_err->isZero(),
"result");
3299 "cannot get value as APFloat: %s",
3300 llvm::toString(float_value_or_err.takeError()).c_str()));
3305 if (!is_scalar || is_integer) {
3307 if (int_value_or_err) {
3311 int_value_or_err->extOrTrunc(type_byte_size * CHAR_BIT);
3318 "cannot get value as APSInt: %s",
3319 llvm::toString(int_value_or_err.takeError()).c_str()));
3320 }
else if (is_scalar && is_float) {
3324 if (float_value_or_err) {
3325 llvm::APFloatBase::opStatus status =
3326 float_value_or_err->convertToInteger(
3327 integer, llvm::APFloat::rmTowardZero, &is_exact);
3331 if (status & llvm::APFloatBase::opInvalidOp)
3335 "invalid cast from float to integer"));
3342 "cannot get value as APFloat: %s",
3343 llvm::toString(float_value_or_err.takeError()).c_str()));
3351 if (int_value_or_err) {
3353 int_value_or_err->extOrTrunc(type_byte_size * CHAR_BIT);
3363 "cannot get value as APSInt: %s",
3364 llvm::toString(int_value_or_err.takeError()).c_str()));
3369 if (int_value_or_err) {
3370 Scalar scalar_int(*int_value_or_err);
3379 "cannot get value as APSInt: %s",
3380 llvm::toString(int_value_or_err.takeError()).c_str()));
3385 if (float_value_or_err) {
3386 Scalar scalar_float(*float_value_or_err);
3395 "cannot get value as APFloat: %s",
3396 llvm::toString(float_value_or_err.takeError()).c_str()));
3413 if (!is_enum && !is_integer && !is_float)
3417 "argument must be an integer, a float, or an enum"));
3425 uint64_t byte_size = 0;
3426 if (
auto temp = llvm::expectedToOptional(type.
GetByteSize(target.get())))
3427 byte_size = temp.value();
3430 llvm::APSInt
integer(byte_size * CHAR_BIT,
3435 llvm::APFloatBase::opStatus status = value_or_err->convertToInteger(
3436 integer, llvm::APFloat::rmTowardZero, &is_exact);
3440 if (status & llvm::APFloatBase::opInvalidOp)
3450 "cannot get value as APFloat: {0}",
3451 llvm::toString(value_or_err.takeError())));
3456 llvm::APSInt ext = value_or_err->extOrTrunc(byte_size * CHAR_BIT);
3463 "cannot get value as APSInt: %s",
3464 llvm::toString(value_or_err.takeError()).c_str()));
3482 process_sp = target_sp->GetProcessSP();
3492 thread_sp = process_sp->GetThreadList().GetSelectedThread();
3525 bool accept_invalid_exe_ctx) {
3528 const bool thread_and_frame_only_if_stopped =
true;
3537 if (process ==
nullptr)
3549 bool changed =
false;
3550 const bool was_valid =
m_mod_id.IsValid();
3568 if (!accept_invalid_exe_ctx) {
3577 changed = was_valid;
3583 changed = was_valid;
3624 if (!
m_parent->IsPointerOrReferenceType())
3625 return m_parent->GetSymbolContextScope();
3631 llvm::StringRef name, llvm::StringRef expression,
3638 llvm::StringRef name, llvm::StringRef expression,
3648 if (expression.empty())
3651 target_sp->EvaluateExpression(expression, exe_ctx.
GetFrameSP().get(),
3652 retval_sp, options);
3653 if (retval_sp && !name.empty())
3654 retval_sp->SetName(name);
3664 pointer_type = type;
3673 if (ptr_result_valobj_sp) {
3675 ptr_result_valobj_sp->GetValue().SetValueType(
3679 ptr_result_valobj_sp = ptr_result_valobj_sp->Dereference(err);
3680 if (ptr_result_valobj_sp && !name.empty())
3681 ptr_result_valobj_sp->SetName(name);
3683 return ptr_result_valobj_sp;
3697 if (new_value_sp && !name.empty())
3698 new_value_sp->SetName(name);
3699 return new_value_sp;
3705 uint64_t byte_size =
3706 llvm::expectedToOptional(
3710 reinterpret_cast<const void *
>(v.getRawData()), byte_size,
3728 nullptr, parent ? parent->
GetManager() :
nullptr);
3736 uint64_t byte_size =
3737 llvm::expectedToOptional(type.
GetByteSize(exe_scope)).value_or(0);
3739 reinterpret_cast<const void *
>(&value), byte_size, exe_ctx.
GetByteOrder(),
3753 uint64_t byte_size = 0;
3754 if (
auto temp = llvm::expectedToOptional(
3756 byte_size = temp.value();
3758 reinterpret_cast<const void *
>(zero), byte_size, exe_ctx.
GetByteOrder(),
3801 while (with_dv_info) {
3804 with_dv_info = with_dv_info->
m_parent;
3811 while (with_fmt_info) {
3814 with_fmt_info = with_fmt_info->
m_parent;
3826 frame_sp->GetSymbolContext(eSymbolContextCompUnit));
3828 type = cu->GetLanguage();
3860 target_sp->GetPersistentExpressionStateForLanguage(
3863 if (!persistent_state)
3873 persistent_var_sp->m_live_sp = persistent_var_sp->m_frozen_sp;
3876 return persistent_var_sp->GetValueObject();
3888 if ((
m_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(
3922 return target_sp && target_sp->IsValid();
3927 std::unique_lock<TargetAPIMutex> &lock,
3936 Target *target = value_sp->GetTargetSP().get();
3938 if (value_sp->GetError().Fail())
3945 lock = std::unique_lock<TargetAPIMutex>(api_mutex);
3947 ProcessSP process_sp(value_sp->GetProcessSP());
3948 if (process_sp && !stop_locker.
TryLock(&process_sp->GetRunLock())) {
3959 value_sp = dynamic_sp;
3965 value_sp = synthetic_sp;
3971 value_sp->SetName(
m_name);
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOG_ERRORV(log, error,...)
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
static const char * ConvertBoolean(lldb::LanguageType language_type, const char *value_str)
static llvm::StringRef SkipLeadingExpressionPathSeparators(llvm::StringRef expression)
static bool CopyStringDataToBufferSP(const StreamString &source, lldb::WritableDataBufferSP &destination)
static ValueObjectSP DereferenceValueOrAlternate(ValueObject &valobj, ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal synth_traversal, Status &error)
static bool HasFloatingRepresentation(CompilerType ct)
static ValueObjectSP GetAlternateValue(ValueObject &valobj, ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal synth_traversal)
static std::atomic< user_id_t > g_value_obj_uid
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.
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
A class that describes a compilation unit.
lldb::TypeSystemSP GetSharedPointer() const
Generic representation of a type in a programming language.
bool IsEnumerationType(bool &is_signed) const
lldb::BasicType GetBasicTypeEnumeration() const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
bool IsPossibleDynamicType(CompilerType *target_type, bool check_cplusplus, bool check_objc) const
bool IsArrayType(CompilerType *element_type=nullptr, uint64_t *size=nullptr, bool *is_incomplete=nullptr) const
size_t GetIndexOfChildMemberWithName(llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) const
Lookup a child member given a name.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
lldb::Encoding GetEncoding() const
CompilerType GetNonReferenceType() const
If this type is a reference to a type (L value or R value reference), return a new type with the refe...
ConstString GetTypeName(bool BaseOnly=false) const
bool IsEnumerationIntegerTypeSigned() const
bool IsReferenceType(CompilerType *pointee_type=nullptr, bool *is_rvalue=nullptr) const
std::string TypeDescription()
bool IsInteger() const
This is used when you don't care about the signedness of the integer.
llvm::Expected< CompilerType > GetDereferencedType(ExecutionContext *exe_ctx, std::string &deref_name, uint32_t &deref_byte_size, int32_t &deref_byte_offset, ValueObject *valobj, uint64_t &language_flags) const
lldb::Format GetFormat() const
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
bool IsUnscopedEnumerationType() const
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
llvm::Expected< uint32_t > GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const
Lookup a child given a name.
bool CompareTypes(CompilerType rhs) const
bool IsScalarType() const
bool IsNullPtrType() const
bool IsPointerType(CompilerType *pointee_type=nullptr) const
A uniqued constant string class.
void SetCString(const char *cstr)
Set the C string value.
bool IsEmpty() const
Test for empty string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
void SetString(llvm::StringRef s)
const char * GetCString() const
Get the string value as a C string.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
A subclass of DataBuffer that stores a data buffer on the heap.
lldb::offset_t SetByteSize(lldb::offset_t byte_size)
Set the number of bytes in the data buffer.
void CopyData(const void *src, lldb::offset_t src_len)
Makes a copy of the src_len bytes in src.
static lldb::TypeSummaryImplSP GetSummaryFormat(ValueObject &valobj, lldb::DynamicValueType use_dynamic)
static lldb::TypeFormatImplSP GetFormat(ValueObject &valobj, lldb::DynamicValueType use_dynamic)
static lldb::SyntheticChildrenSP GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic)
static uint32_t GetCurrentRevision()
A class that describes the declaration location of a lldb object.
void Clear()
Clear the object's state.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
virtual lldb::TargetSP CalculateTarget()=0
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
uint32_t GetAddressByteSize() const
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
lldb::ByteOrder GetByteOrder() const
const lldb::StackFrameSP & GetFrameSP() const
Get accessor to get the frame shared pointer.
Target * GetTargetPtr() const
Returns a pointer to the target object.
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
Process * GetProcessPtr() const
Returns a pointer to the process object.
@ EVIsProgramReference
This variable is a reference to a (possibly invalid) area managed by the target program.
bool AllClear(ValueType mask) const
Test if all bits in mask are clear.
void Reset(ValueType flags)
Set accessor for all flags.
bool Test(ValueType bit) const
Test a single flag bit.
bool AnySet(ValueType mask) const
Test one or more flags.
static Language * FindPlugin(lldb::LanguageType language)
static bool LanguageIsCFamily(lldb::LanguageType language)
Equivalent to LanguageIsC||LanguageIsObjC||LanguageIsCPlusPlus.
static bool LanguageIsObjC(lldb::LanguageType language)
virtual lldb::ExpressionVariableSP CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp)=0
virtual ConstString GetNextPersistentVariableName(bool is_error=false)=0
Return a new persistent variable name with the specified prefix.
uint32_t GetStopID() const
bool TryLock(ProcessRunLock *lock)
Try to acquire the read lock.
A plug-in interface definition class for debugging a process.
ProcessModID GetModID() const
Get the Modification ID of the process.
ProcessRunLock::ProcessRunLocker StopLocker
bool IsPossibleDynamicValue(ValueObject &in_value)
LanguageRuntime * GetLanguageRuntime(lldb::LanguageType language)
size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error)
Write memory to a process.
size_t WriteScalarToMemory(lldb::addr_t vm_addr, const Scalar &scalar, size_t size, Status &error)
Write all or part of a scalar value to memory.
llvm::APFloat CreateAPFloatFromAPFloat(lldb::BasicType basic_type)
llvm::APFloat CreateAPFloatFromAPSInt(lldb::BasicType basic_type)
unsigned long long ULongLong(unsigned long long fail_value=0) const
llvm::APFloat GetAPFloat() const
long long SLongLong(long long fail_value=0) const
bool ExtractBitfield(uint32_t bit_size, uint32_t bit_offset)
Status SetValueFromCString(const char *s, lldb::Encoding encoding, size_t byte_size)
bool GetData(DataExtractor &data) const
Get data with a byte size of GetByteSize().
llvm::APSInt GetAPSInt() const
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
bool Success() const
Test for success condition.
const char * GetData() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Basic RAII class to increment the summary count when the call is complete.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
CompileUnit * comp_unit
The CompileUnit for a given query.
A Lockable handle over a Target's API mutex, returned by Target::GetAPIMutex() and backing the public...
uint32_t GetMaximumSizeOfStringSummary() const
bool GetCheckValueObjectOwnership() const
TargetAPIMutex GetAPIMutex()
Returns a handle resolved to the mutex to serialize on before touching the target through the SB API.
virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len, Status &error, bool force_live_memory=false, lldb::addr_t *load_addr_ptr=nullptr, bool *did_read_live_memory=nullptr)
virtual bool FormatObject(ValueObject *valobj, std::string &dest, const TypeSummaryOptions &options)=0
lldb::LanguageType GetLanguage() const
TypeSummaryOptions & SetLanguage(lldb::LanguageType)
lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker, TargetAPIMutex &api_mutex, std::unique_lock< TargetAPIMutex > &lock, Status &error)
lldb::ValueObjectSP m_valobj_sp
lldb::DynamicValueType m_use_dynamic
ValueImpl & operator=(const ValueImpl &rhs)
static lldb::ValueObjectSP Create(ValueObject &parent, llvm::StringRef name, const CompilerType &cast_type)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS, ValueObjectManager *manager=nullptr)
These routines create ValueObjectConstResult ValueObjects from various data sources.
A ValueObject that represents memory at a given address, viewed as some set lldb type.
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, llvm::StringRef name, const Address &address, lldb::TypeSP &type_sp, ValueObject *parent=nullptr)
llvm::Error PrintValueObject()
static lldb::ValueObjectSP Create(ValueObject &parent)
bool SyncWithProcessState(bool accept_invalid_exe_ctx)
ExecutionContextRef m_exe_ctx_ref
AddressType m_address_type_of_ptr_or_ref_children
void SetValueIsValid(bool valid)
EvaluationPoint m_update_point
Stores both the stop id and the full context at which this value was last updated.
lldb::TypeSummaryImplSP GetSummaryFormat()
lldb::ValueObjectSP CheckValueObjectOwnership(ValueObject *child)
llvm::SmallVector< uint8_t, 16 > m_value_checksum
static lldb::ValueObjectSP CreateValueObjectFromNullptr(const ExecutionContext &exe_ctx, CompilerType type, llvm::StringRef name, ValueObject *parent=nullptr)
Create a nullptr value object with the specified type (must be a nullptr type).
llvm::Expected< llvm::APFloat > GetValueAsAPFloat()
If the current ValueObject is of an appropriate type, convert the value to an APFloat and return that...
virtual uint32_t GetBitfieldBitSize()
void ClearUserVisibleData(uint32_t items=ValueObject::eClearUserVisibleDataItemsAllStrings)
ValueObject * FollowParentChain(std::function< bool(ValueObject *)>)
Given a ValueObject, loop over itself and its parent, and its parent's parent, .
CompilerType m_override_type
If the type of the value object should be overridden, the type to impose.
lldb::ValueObjectSP Cast(const CompilerType &compiler_type)
const EvaluationPoint & GetUpdatePoint() const
void AddSyntheticChild(ConstString key, ValueObject *valobj)
virtual uint64_t GetData(DataExtractor &data, Status &error)
uint32_t m_last_format_mgr_revision
friend class ValueObjectSynthetic
bool DumpPrintableRepresentation(Stream &s, ValueObjectRepresentationStyle val_obj_display=eValueObjectRepresentationStyleSummary, lldb::Format custom_format=lldb::eFormatInvalid, PrintableRepresentationSpecialCases special=PrintableRepresentationSpecialCases::eAllow, bool do_dump_error=true)
ValueObject * m_deref_valobj
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx, bool can_create=true)
virtual lldb::DynamicValueType GetDynamicValueTypeImpl()
PrintableRepresentationSpecialCases
virtual bool GetIsConstant() const
virtual bool MightHaveChildren()
Find out if a ValueObject might have children.
virtual bool IsDereferenceOfParent()
virtual llvm::Expected< size_t > GetIndexOfChildWithName(llvm::StringRef name)
Return the index of the child named name.
static lldb::ValueObjectSP CreateValueObjectFromScalar(const ExecutionContext &exe_ctx, Scalar &s, CompilerType type, llvm::StringRef name, ValueObject *parent=nullptr)
Create a value object containing the given Scalar value.
virtual ValueObject * CreateSyntheticArrayMember(size_t idx)
Should only be called by ValueObject::GetSyntheticArrayMember().
void SetValueFormat(lldb::TypeFormatImplSP format)
virtual void CalculateSyntheticValue()
void SetPreferredDisplayLanguage(lldb::LanguageType lt)
struct lldb_private::ValueObject::Bitflags m_flags
ClusterManager< ValueObject > ValueObjectManager
ValueObject(ExecutionContextScope *exe_scope, ValueObjectManager &manager, AddressType child_ptr_or_ref_addr_type=eAddressTypeLoad)
Use this constructor to create a "root variable object".
std::string m_summary_str
Cached summary string that will get cleared if/when the value is updated.
virtual lldb::ValueObjectSP DoCast(const CompilerType &compiler_type)
lldb::ValueObjectSP GetSP()
virtual llvm::Error CanSetValue()
Check if the value may be writable.
ChildrenManager m_children
virtual lldb::ValueObjectSP CastPointerType(const char *name, CompilerType &ast_type)
Status m_error
An error object that can describe any errors that occur when updating values.
virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx=0, uint32_t item_count=1)
lldb::ValueObjectSP GetSyntheticValue()
ValueObjectManager * m_manager
This object is managed by the root object (any ValueObject that gets created without a parent....
lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to, bool can_create)
lldb::ProcessSP GetProcessSP() const
lldb::ValueObjectSP GetSyntheticChild(ConstString key) const
ExpressionPathScanEndReason
@ eExpressionPathScanEndReasonArrowInsteadOfDot
-> used when . should be used.
@ eExpressionPathScanEndReasonDereferencingFailed
Impossible to apply * operator.
@ eExpressionPathScanEndReasonNoSuchChild
Child element not found.
@ eExpressionPathScanEndReasonUnknown
@ eExpressionPathScanEndReasonDotInsteadOfArrow
. used when -> should be used.
@ eExpressionPathScanEndReasonEndOfString
Out of data to parse.
@ eExpressionPathScanEndReasonRangeOperatorNotAllowed
[] not allowed by options.
@ eExpressionPathScanEndReasonEmptyRangeNotAllowed
[] only allowed for arrays.
@ eExpressionPathScanEndReasonRangeOperatorInvalid
[] not valid on objects other than scalars, pointers or arrays.
@ eExpressionPathScanEndReasonUnexpectedSymbol
Something is malformed in he expression.
@ eExpressionPathScanEndReasonArrayRangeOperatorMet
[] is good for arrays, but I cannot parse it.
@ eExpressionPathScanEndReasonSyntheticValueMissing
getting the synthetic children failed.
@ eExpressionPathScanEndReasonTakingAddressFailed
Impossible to apply & operator.
@ eExpressionPathScanEndReasonFragileIVarNotAllowed
ObjC ivar expansion not allowed.
virtual bool UpdateValue()=0
lldb::Format GetFormat() const
virtual lldb::VariableSP GetVariable()
@ eExpressionPathAftermathNothing
Just return it.
@ eExpressionPathAftermathDereference
Dereference the target.
@ eExpressionPathAftermathTakeAddress
Take target's address.
lldb::ValueObjectSP CastToBasicType(CompilerType type)
ValueObject * GetNonBaseClassParent()
virtual ValueObject * CreateChildAtIndex(size_t idx)
Should only be called by ValueObject::GetChildAtIndex().
lldb::ValueObjectSP GetValueForExpressionPath(llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop=nullptr, ExpressionPathEndResultType *final_value_type=nullptr, const GetValueForExpressionPathOptions &options=GetValueForExpressionPathOptions::DefaultOptions(), ExpressionPathAftermath *final_task_on_target=nullptr)
virtual lldb::ValueObjectSP GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type, bool can_create, ConstString name_const_str=ConstString())
virtual void CalculateDynamicValue(lldb::DynamicValueType use_dynamic)
bool IsPossibleDynamicType()
DataExtractor m_data
A data extractor that can be used to extract the value.
virtual llvm::Expected< uint64_t > GetByteSize()=0
virtual CompilerType GetCompilerTypeImpl()=0
virtual lldb::ValueObjectSP GetSyntheticBase(uint32_t offset, const CompilerType &type, bool can_create, ConstString name_const_str=ConstString())
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
@ eGetExpressionPathFormatDereferencePointers
@ eGetExpressionPathFormatHonorPointers
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
lldb::ValueObjectSP CastToEnumType(CompilerType type)
llvm::Expected< uint32_t > GetNumChildren(uint32_t max=UINT32_MAX)
virtual lldb::ValueType GetValueType() const =0
virtual void GetExpressionPath(Stream &s, GetExpressionPathFormat=eGetExpressionPathFormatDereferencePointers)
bool UpdateFormatsIfNeeded()
virtual bool HasSyntheticValue()
lldb::StackFrameSP GetFrameSP() const
friend class ValueObjectChild
lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef< llvm::StringRef > names)
void SetSummaryFormat(lldb::TypeSummaryImplSP format)
virtual bool IsRuntimeSupportValue()
virtual ConstString GetTypeName()
DataExtractor & GetDataExtractor()
void SetValueDidChange(bool value_changed)
static lldb::ValueObjectSP CreateValueObjectFromBool(const ExecutionContext &exe_ctx, lldb::TypeSystemSP typesystem, bool value, llvm::StringRef name, ValueObject *parent=nullptr)
Create a value object containing the given boolean value.
@ eClearUserVisibleDataItemsDescription
@ eClearUserVisibleDataItemsLocation
@ eClearUserVisibleDataItemsSummary
@ eClearUserVisibleDataItemsValue
@ eClearUserVisibleDataItemsSyntheticChildren
ValueObjectManager * GetManager()
ValueObject * m_root
The root of the hierarchy for this ValueObject (or nullptr if never calculated).
lldb::addr_t GetLoadAddress()
Return the target load address associated with this value object.
bool GetValueIsValid() const
virtual lldb::ModuleSP GetModule()
Return the module associated with this value object in case the value is from an executable file and ...
virtual lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType)
void UpdateChildrenAddressType()
llvm::Expected< lldb::ValueObjectSP > CastDerivedToBaseType(CompilerType type, const llvm::ArrayRef< uint32_t > &base_type_indices)
Take a ValueObject whose type is an inherited class, and cast it to 'type', which should be one of it...
virtual lldb::ValueObjectSP AddressOf(Status &error)
lldb::DynamicValueType GetDynamicValueType()
llvm::Expected< lldb::ValueObjectSP > CastBaseToDerivedType(CompilerType type, uint64_t offset)
Take a ValueObject whose type is a base class, and cast it to 'type', which should be one of its deri...
lldb::SyntheticChildrenSP GetSyntheticChildren()
lldb::LanguageType m_preferred_display_language
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr)
virtual llvm::Expected< uint32_t > CalculateNumChildren(uint32_t max=UINT32_MAX)=0
Should only be called by ValueObject::GetNumChildren().
lldb::LanguageType GetObjectRuntimeLanguage()
virtual lldb::ValueObjectSP CreateConstantValue(ConstString name)
lldb::ValueObjectSP GetSyntheticExpressionPathChild(llvm::StringRef expression, bool can_create)
virtual bool IsLogicalTrue(Status &error)
lldb::Format m_last_format
virtual SymbolContextScope * GetSymbolContextScope()
virtual bool HasDynamicValueTypeInfo()
ValueObject * m_synthetic_value
virtual lldb::ValueObjectSP Clone(llvm::StringRef new_name)
Creates a copy of the ValueObject with a new name and setting the current ValueObject as its parent.
void SetNumChildren(uint32_t num_children)
ValueObject * m_parent
The parent value object, or nullptr if this has no parent.
static lldb::ValueObjectSP CreateValueObjectFromAPInt(const ExecutionContext &exe_ctx, const llvm::APInt &v, CompilerType type, llvm::StringRef name, ValueObject *parent=nullptr)
Create a value object containing the given APInt value.
virtual bool IsBaseClass()
llvm::Expected< bool > GetValueAsBool()
If the current ValueObject is of an appropriate type, convert the value to a boolean and return that.
virtual bool GetDeclaration(Declaration &decl)
llvm::Error SetValueFromInteger(const llvm::APInt &value, bool can_update_var=true)
Update an existing integer ValueObject with a new integer value.
static lldb::ValueObjectSP CreateValueObjectFromExpression(llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx, ValueObject *parent=nullptr)
The following static routines create "Root" ValueObjects if parent is null.
lldb::ValueObjectSP GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue, bool synthValue)
lldb::ValueObjectSP m_addr_of_valobj_sp
We have to hold onto a shared pointer to this one because it is created as an independent ValueObject...
std::pair< size_t, bool > ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, bool honor_array)
llvm::Error Dump(Stream &s)
bool IsUninitializedReference()
bool UpdateValueIfNeeded(bool update_format=true)
AddressType GetAddressTypeOfChildren()
const Status & GetError()
lldb::TypeFormatImplSP m_type_format_sp
lldb::TargetSP GetTargetSP() const
ExpressionPathEndResultType
@ eExpressionPathEndResultTypeInvalid
@ eExpressionPathEndResultTypePlain
Anything but...
@ eExpressionPathEndResultTypeBoundedRange
A range [low-high].
@ eExpressionPathEndResultTypeBitfield
A bitfield.
@ eExpressionPathEndResultTypeUnboundedRange
A range [].
virtual lldb::ValueObjectSP Dereference(Status &error)
CompilerType GetCompilerType()
void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType)
virtual const char * GetValueAsCString()
bool HasSpecialPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display, lldb::Format custom_format)
virtual const char * GetLocationAsCString()
AddrAndType GetPointerValue()
ConstString GetName() const
std::string m_location_str
Cached location string that will get cleared if/when the value is updated.
lldb::ValueObjectSP GetVTable()
If this object represents a C++ class with a vtable, return an object that represents the virtual fun...
virtual bool SetValueFromCString(const char *value_str, Status &error)
virtual lldb::ValueObjectSP GetStaticValue()
lldb::ValueObjectSP Persist()
std::string m_object_desc_str
Cached result of the "object printer".
virtual ValueObject * GetParent()
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type, ValueObject *parent=nullptr)
lldb::SyntheticChildrenSP m_synthetic_children_sp
As determined by DataVisualization - may be overridden.
static lldb::ValueObjectSP CreateValueObjectFromAPFloat(const ExecutionContext &exe_ctx, const llvm::APFloat &v, CompilerType type, llvm::StringRef name, ValueObject *parent=nullptr)
Create a value object containing the given APFloat value.
virtual uint32_t GetBitfieldBitOffset()
llvm::Expected< std::string > GetObjectDescription()
std::string m_old_value_str
Cached old value string from the last time the value was gotten.
virtual lldb::ValueObjectSP GetNonSyntheticValue()
virtual bool SetData(DataExtractor &data, Status &error)
virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success=nullptr)
const char * GetSummaryAsCString(lldb::LanguageType lang=lldb::eLanguageTypeUnknown)
ValueObjectRepresentationStyle
@ eValueObjectRepresentationStyleLocation
@ eValueObjectRepresentationStyleSummary
@ eValueObjectRepresentationStyleName
@ eValueObjectRepresentationStyleType
@ eValueObjectRepresentationStyleChildrenCount
@ eValueObjectRepresentationStyleExpressionPath
@ eValueObjectRepresentationStyleValue
@ eValueObjectRepresentationStyleLanguageSpecific
std::string m_value_str
Cached value string that will get cleared if/when the value is updated.
lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create)
virtual bool ResolveValue(Scalar &scalar)
llvm::Expected< llvm::APSInt > GetValueAsAPSInt()
If the current ValueObject is of an appropriate type, convert the value to an APSInt and return that.
void SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp)
ConstString m_name
The name of this object.
bool IsPointerOrReferenceType()
const char * GetLocationAsCStringImpl(const Value &value, const DataExtractor &data)
virtual void SetFormat(lldb::Format format)
ValueObject * m_dynamic_value
void ClearDynamicTypeInformation()
bool IsCStringContainer(bool check_pointer=false)
Returns true if this is a char* or a char[] if it is a char* and check_pointer is true,...
virtual bool IsSynthetic()
std::map< ConstString, ValueObject * > m_synthetic_children
llvm::ArrayRef< uint8_t > GetLocalBuffer() const
Returns the local buffer that this ValueObject points to if it's available.
std::optional< lldb::addr_t > GetStrippedPointerValue(lldb::addr_t address)
Remove ptrauth bits from address if the type has a ptrauth qualifier.
const ExecutionContextRef & GetExecutionContextRef() const
virtual AddrAndType GetAddressOf(bool scalar_is_load_address=true)
uint32_t GetNumChildrenIgnoringErrors(uint32_t max=UINT32_MAX)
Like GetNumChildren but returns 0 on error.
virtual bool CanProvideValue()
UserID m_id
Unique identifier for every value object.
const Value & GetValue() const
virtual lldb::LanguageType GetPreferredDisplayLanguage()
lldb::ValueObjectSP GetValueForExpressionPath_Impl(llvm::StringRef expression_cstr, ExpressionPathScanEndReason *reason_to_stop, ExpressionPathEndResultType *final_value_type, const GetValueForExpressionPathOptions &options, ExpressionPathAftermath *final_task_on_target)
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true, ValueObject *parent=nullptr)
Given an address either create a value object containing the value at that address,...
const Scalar & GetScalar() const
See comment on m_scalar to understand what GetScalar returns.
Status GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, Module *module)
RegisterInfo * GetRegisterInfo() const
ValueType
Type that describes Value::m_value.
@ HostAddress
A host address value (for memory in the process that < A is using liblldb).
@ FileAddress
A file address value.
@ LoadAddress
A load address value.
@ Scalar
A raw scalar value.
ValueType GetValueType() const
Scalar & ResolveValue(ExecutionContext *exe_ctx, Module *module=nullptr)
@ RegisterInfo
RegisterInfo * (can be a scalar or a vector register).
ContextType GetContextType() const
const CompilerType & GetCompilerType()
uint8_t * GetBytes()
Get a pointer to the data.
#define LLDB_INVALID_ADDRESS
@ DoNoSelectMostRelevantFrame
lldb::ByteOrder InlHostByteOrder()
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< SummaryStatistics > SummaryStatisticsSP
@ 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.
std::string toString(FormatterBytecode::OpCodes op)
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::TypeFormatImpl > TypeFormatImplSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
Format
Display format definitions.
@ eFormatCString
Null-terminated C strings.
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
@ eFormatComplex
Floating point complex type.
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
@ eFormatFloat128
Disambiguate between 128-bit long double (which uses eFormatFloat) and __float128 (which uses eFormat...
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeObjC
Objective-C.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::Process > ProcessSP
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eValueTypeRegister
stack frame register value
std::shared_ptr< lldb_private::SyntheticChildren > SyntheticChildrenSP
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP
Every register is described in detail including its name, alternate name (optional),...
lldb::Encoding encoding
Encoding of the register bits.
const char * alt_name
Alternate name of this register, can be NULL.
const char * name
Name of this register, can't be NULL.
lldb::Format format
Default display format.
bool m_is_synthetic_children_generated
SyntheticChildrenTraversal m_synthetic_children_traversal
bool m_check_dot_vs_arrow_syntax
bool m_allow_bitfields_syntax
SyntheticChildrenTraversal