LLDB mainline
ValueObject.cpp
Go to the documentation of this file.
1//===-- ValueObject.cpp ---------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11#include "lldb/Core/Address.h"
13#include "lldb/Core/Module.h"
29#include "lldb/Host/Config.h"
33#include "lldb/Symbol/Type.h"
38#include "lldb/Target/Process.h"
40#include "lldb/Target/Target.h"
41#include "lldb/Target/Thread.h"
45#include "lldb/Utility/Flags.h"
47#include "lldb/Utility/Log.h"
48#include "lldb/Utility/Scalar.h"
49#include "lldb/Utility/Stream.h"
52
53#include "llvm/Support/Compiler.h"
54
55#include <algorithm>
56#include <cstdint>
57#include <cstdlib>
58#include <memory>
59#include <optional>
60#include <tuple>
61
62#include <cassert>
63#include <cinttypes>
64#include <cstdio>
65#include <cstring>
66
68
69namespace lldb_private {
71}
72namespace lldb_private {
74}
75
76using namespace lldb;
77using namespace lldb_private;
78
80
81// ValueObject constructor
83 : m_parent(&parent), m_update_point(parent.GetUpdatePoint()),
84 m_manager(parent.GetManager()), m_id(++g_value_obj_uid) {
90}
91
92// ValueObject constructor
94 ValueObjectManager &manager,
95 AddressType child_ptr_or_ref_addr_type)
96 : m_update_point(exe_scope), m_manager(&manager),
97 m_address_type_of_ptr_or_ref_children(child_ptr_or_ref_addr_type),
98 m_id(++g_value_obj_uid) {
99 if (exe_scope) {
100 TargetSP target_sp(exe_scope->CalculateTarget());
101 if (target_sp) {
102 const ArchSpec &arch = target_sp->GetArchitecture();
105 }
106 }
107 m_manager->ManageObject(this);
108}
109
110// Destructor
111ValueObject::~ValueObject() = default;
112
113bool ValueObject::UpdateValueIfNeeded(bool update_format) {
114
115 bool did_change_formats = false;
116
117 if (update_format)
118 did_change_formats = UpdateFormatsIfNeeded();
119
120 // If this is a constant value, then our success is predicated on whether we
121 // have an error or not
122 if (GetIsConstant()) {
123 // if you are constant, things might still have changed behind your back
124 // (e.g. you are a frozen object and things have changed deeper than you
125 // cared to freeze-dry yourself) in this case, your value has not changed,
126 // but "computed" entries might have, so you might now have a different
127 // summary, or a different object description. clear these so we will
128 // recompute them
129 if (update_format && !did_change_formats)
132 return m_error.Success();
133 }
134
135 bool first_update = IsChecksumEmpty();
136
137 if (NeedsUpdating()) {
139
140 // Save the old value using swap to avoid a string copy which also will
141 // clear our m_value_str
142 if (m_value_str.empty()) {
144 } else {
148 }
149
151
152 if (IsInScope()) {
153 const bool value_was_valid = GetValueIsValid();
154 SetValueDidChange(false);
155
156 m_error.Clear();
157
158 // Call the pure virtual function to update the value
159
160 bool need_compare_checksums = false;
161 llvm::SmallVector<uint8_t, 16> old_checksum;
162
163 if (!first_update && CanProvideValue()) {
164 need_compare_checksums = true;
165 old_checksum.resize(m_value_checksum.size());
166 std::copy(m_value_checksum.begin(), m_value_checksum.end(),
167 old_checksum.begin());
168 }
169
170 bool success = UpdateValue();
171
172 SetValueIsValid(success);
173
174 if (success) {
176 const uint64_t max_checksum_size = 128;
177 m_data.Checksum(m_value_checksum, max_checksum_size);
178 } else {
179 need_compare_checksums = false;
180 m_value_checksum.clear();
181 }
182
183 assert(!need_compare_checksums ||
184 (!old_checksum.empty() && !m_value_checksum.empty()));
185
186 if (first_update)
187 SetValueDidChange(false);
188 else if (!m_flags.m_value_did_change && !success) {
189 // The value wasn't gotten successfully, so we mark this as changed if
190 // the value used to be valid and now isn't
191 SetValueDidChange(value_was_valid);
192 } else if (need_compare_checksums) {
193 SetValueDidChange(memcmp(&old_checksum[0], &m_value_checksum[0],
194 m_value_checksum.size()));
195 }
196
197 } else {
198 m_error.SetErrorString("out of scope");
199 }
200 }
201 return m_error.Success();
202}
203
206 LLDB_LOGF(log,
207 "[%s %p] checking for FormatManager revisions. ValueObject "
208 "rev: %d - Global rev: %d",
209 GetName().GetCString(), static_cast<void *>(this),
212
213 bool any_change = false;
214
217 any_change = true;
218
224 }
225
226 return any_change;
227}
228
231 // We have to clear the value string here so ConstResult children will notice
232 // if their values are changed by hand (i.e. with SetValueAsCString).
234}
235
244}
245
247 CompilerType compiler_type(GetCompilerTypeImpl());
248
251 return m_override_type;
252 else
253 return compiler_type;
254 }
255
257
258 ProcessSP process_sp(
260
261 if (!process_sp)
262 return compiler_type;
263
264 if (auto *runtime =
265 process_sp->GetLanguageRuntime(GetObjectRuntimeLanguage())) {
266 if (std::optional<CompilerType> complete_type =
267 runtime->GetRuntimeType(compiler_type)) {
268 m_override_type = *complete_type;
270 return m_override_type;
271 }
272 }
273 return compiler_type;
274}
275
276
277
279 UpdateValueIfNeeded(false);
280 return m_data;
281}
282
284 UpdateValueIfNeeded(false);
285 return m_error;
286}
287
289 const DataExtractor &data) {
290 if (UpdateValueIfNeeded(false)) {
291 if (m_location_str.empty()) {
292 StreamString sstr;
293
294 Value::ValueType value_type = value.GetValueType();
295
296 switch (value_type) {
298 m_location_str = "invalid";
299 break;
302 RegisterInfo *reg_info = value.GetRegisterInfo();
303 if (reg_info) {
304 if (reg_info->name)
305 m_location_str = reg_info->name;
306 else if (reg_info->alt_name)
307 m_location_str = reg_info->alt_name;
308 if (m_location_str.empty())
310 ? "vector"
311 : "scalar";
312 }
313 }
314 if (m_location_str.empty())
315 m_location_str = "scalar";
316 break;
317
321 uint32_t addr_nibble_size = data.GetAddressByteSize() * 2;
322 sstr.Printf("0x%*.*llx", addr_nibble_size, addr_nibble_size,
324 m_location_str = std::string(sstr.GetString());
325 } break;
326 }
327 }
328 }
329 return m_location_str.c_str();
330}
331
334 false)) // make sure that you are up to date before returning anything
335 {
337 Value tmp_value(m_value);
338 scalar = tmp_value.ResolveValue(&exe_ctx, GetModule().get());
339 if (scalar.IsValid()) {
340 const uint32_t bitfield_bit_size = GetBitfieldBitSize();
341 if (bitfield_bit_size)
342 return scalar.ExtractBitfield(bitfield_bit_size,
344 return true;
345 }
346 }
347 return false;
348}
349
352 LazyBool is_logical_true = language->IsLogicalTrue(*this, error);
353 switch (is_logical_true) {
354 case eLazyBoolYes:
355 case eLazyBoolNo:
356 return (is_logical_true == true);
358 break;
359 }
360 }
361
362 Scalar scalar_value;
363
364 if (!ResolveValue(scalar_value)) {
365 error.SetErrorString("failed to get a scalar result");
366 return false;
367 }
368
369 bool ret;
370 ret = scalar_value.ULongLong(1) != 0;
371 error.Clear();
372 return ret;
373}
374
375ValueObjectSP ValueObject::GetChildAtIndex(size_t idx, bool can_create) {
376 ValueObjectSP child_sp;
377 // We may need to update our value if we are dynamic
379 UpdateValueIfNeeded(false);
380 if (idx < GetNumChildren()) {
381 // Check if we have already made the child value object?
382 if (can_create && !m_children.HasChildAtIndex(idx)) {
383 // No we haven't created the child at this index, so lets have our
384 // subclass do it and cache the result for quick future access.
385 m_children.SetChildAtIndex(idx, CreateChildAtIndex(idx, false, 0));
386 }
387
389 if (child != nullptr)
390 return child->GetSP();
391 }
392 return child_sp;
393}
394
396ValueObject::GetChildAtNamePath(llvm::ArrayRef<llvm::StringRef> names) {
397 if (names.size() == 0)
398 return GetSP();
399 ValueObjectSP root(GetSP());
400 for (llvm::StringRef name : names) {
401 root = root->GetChildMemberWithName(name);
402 if (!root) {
403 return root;
404 }
405 }
406 return root;
407}
408
409size_t ValueObject::GetIndexOfChildWithName(llvm::StringRef name) {
410 bool omit_empty_base_classes = true;
412 omit_empty_base_classes);
413}
414
416 bool can_create) {
417 // We may need to update our value if we are dynamic.
419 UpdateValueIfNeeded(false);
420
421 // When getting a child by name, it could be buried inside some base classes
422 // (which really aren't part of the expression path), so we need a vector of
423 // indexes that can get us down to the correct child.
424 std::vector<uint32_t> child_indexes;
425 bool omit_empty_base_classes = true;
426
427 if (!GetCompilerType().IsValid())
428 return ValueObjectSP();
429
430 const size_t num_child_indexes =
432 name, omit_empty_base_classes, child_indexes);
433 if (num_child_indexes == 0)
434 return nullptr;
435
436 ValueObjectSP child_sp = GetSP();
437 for (uint32_t idx : child_indexes)
438 if (child_sp)
439 child_sp = child_sp->GetChildAtIndex(idx, can_create);
440 return child_sp;
441}
442
443size_t ValueObject::GetNumChildren(uint32_t max) {
445
446 if (max < UINT32_MAX) {
448 size_t children_count = m_children.GetChildrenCount();
449 return children_count <= max ? children_count : max;
450 } else
451 return CalculateNumChildren(max);
452 }
453
456 }
458}
459
461 bool has_children = false;
462 const uint32_t type_info = GetTypeInfo();
463 if (type_info) {
464 if (type_info & (eTypeHasChildren | eTypeIsPointer | eTypeIsReference))
465 has_children = true;
466 } else {
467 has_children = GetNumChildren() > 0;
468 }
469 return has_children;
470}
471
472// Should only be called by ValueObject::GetNumChildren()
473void ValueObject::SetNumChildren(size_t num_children) {
475 m_children.SetChildrenCount(num_children);
476}
477
479 bool synthetic_array_member,
480 int32_t synthetic_index) {
481 ValueObject *valobj = nullptr;
482
483 bool omit_empty_base_classes = true;
484 bool ignore_array_bounds = synthetic_array_member;
485 std::string child_name_str;
486 uint32_t child_byte_size = 0;
487 int32_t child_byte_offset = 0;
488 uint32_t child_bitfield_bit_size = 0;
489 uint32_t child_bitfield_bit_offset = 0;
490 bool child_is_base_class = false;
491 bool child_is_deref_of_parent = false;
492 uint64_t language_flags = 0;
493
494 const bool transparent_pointers = !synthetic_array_member;
495 CompilerType child_compiler_type;
496
498
499 child_compiler_type = GetCompilerType().GetChildCompilerTypeAtIndex(
500 &exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
501 ignore_array_bounds, child_name_str, child_byte_size, child_byte_offset,
502 child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
503 child_is_deref_of_parent, this, language_flags);
504 if (child_compiler_type) {
505 if (synthetic_index)
506 child_byte_offset += child_byte_size * synthetic_index;
507
508 ConstString child_name;
509 if (!child_name_str.empty())
510 child_name.SetCString(child_name_str.c_str());
511
512 valobj = new ValueObjectChild(
513 *this, child_compiler_type, child_name, child_byte_size,
514 child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
515 child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
516 language_flags);
517 }
518
519 // In case of an incomplete type, try to use the ValueObject's
520 // synthetic value to create the child ValueObject.
521 if (!valobj && synthetic_array_member) {
522 if (ValueObjectSP synth_valobj_sp = GetSyntheticValue()) {
523 valobj = synth_valobj_sp
524 ->GetChildAtIndex(synthetic_index, synthetic_array_member)
525 .get();
526 }
527 }
528
529 return valobj;
530}
531
533 std::string &destination,
534 lldb::LanguageType lang) {
535 return GetSummaryAsCString(summary_ptr, destination,
536 TypeSummaryOptions().SetLanguage(lang));
537}
538
540 std::string &destination,
541 const TypeSummaryOptions &options) {
542 destination.clear();
543
544 // If we have a forcefully completed type, don't try and show a summary from
545 // a valid summary string or function because the type is not complete and
546 // no member variables or member functions will be available.
547 if (GetCompilerType().IsForcefullyCompleted()) {
548 destination = "<incomplete type>";
549 return true;
550 }
551
552 // ideally we would like to bail out if passing NULL, but if we do so we end
553 // up not providing the summary for function pointers anymore
554 if (/*summary_ptr == NULL ||*/ m_flags.m_is_getting_summary)
555 return false;
556
558
559 TypeSummaryOptions actual_options(options);
560
561 if (actual_options.GetLanguage() == lldb::eLanguageTypeUnknown)
563
564 // this is a hot path in code and we prefer to avoid setting this string all
565 // too often also clearing out other information that we might care to see in
566 // a crash log. might be useful in very specific situations though.
567 /*Host::SetCrashDescriptionWithFormat("Trying to fetch a summary for %s %s.
568 Summary provider's description is %s",
569 GetTypeName().GetCString(),
570 GetName().GetCString(),
571 summary_ptr->GetDescription().c_str());*/
572
573 if (UpdateValueIfNeeded(false) && summary_ptr) {
574 if (HasSyntheticValue())
575 m_synthetic_value->UpdateValueIfNeeded(); // the summary might depend on
576 // the synthetic children being
577 // up-to-date (e.g. ${svar%#})
578 summary_ptr->FormatObject(this, destination, actual_options);
579 }
581 return !destination.empty();
582}
583
585 if (UpdateValueIfNeeded(true) && m_summary_str.empty()) {
586 TypeSummaryOptions summary_options;
587 summary_options.SetLanguage(lang);
589 summary_options);
590 }
591 if (m_summary_str.empty())
592 return nullptr;
593 return m_summary_str.c_str();
594}
595
596bool ValueObject::GetSummaryAsCString(std::string &destination,
597 const TypeSummaryOptions &options) {
598 return GetSummaryAsCString(GetSummaryFormat().get(), destination, options);
599}
600
601bool ValueObject::IsCStringContainer(bool check_pointer) {
602 CompilerType pointee_or_element_compiler_type;
603 const Flags type_flags(GetTypeInfo(&pointee_or_element_compiler_type));
604 bool is_char_arr_ptr(type_flags.AnySet(eTypeIsArray | eTypeIsPointer) &&
605 pointee_or_element_compiler_type.IsCharType());
606 if (!is_char_arr_ptr)
607 return false;
608 if (!check_pointer)
609 return true;
610 if (type_flags.Test(eTypeIsArray))
611 return true;
612 addr_t cstr_address = LLDB_INVALID_ADDRESS;
613 AddressType cstr_address_type = eAddressTypeInvalid;
614 cstr_address = GetPointerValue(&cstr_address_type);
615 return (cstr_address != LLDB_INVALID_ADDRESS);
616}
617
618size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,
619 uint32_t item_count) {
620 CompilerType pointee_or_element_compiler_type;
621 const uint32_t type_info = GetTypeInfo(&pointee_or_element_compiler_type);
622 const bool is_pointer_type = type_info & eTypeIsPointer;
623 const bool is_array_type = type_info & eTypeIsArray;
624 if (!(is_pointer_type || is_array_type))
625 return 0;
626
627 if (item_count == 0)
628 return 0;
629
631
632 std::optional<uint64_t> item_type_size =
633 pointee_or_element_compiler_type.GetByteSize(
635 if (!item_type_size)
636 return 0;
637 const uint64_t bytes = item_count * *item_type_size;
638 const uint64_t offset = item_idx * *item_type_size;
639
640 if (item_idx == 0 && item_count == 1) // simply a deref
641 {
642 if (is_pointer_type) {
644 ValueObjectSP pointee_sp = Dereference(error);
645 if (error.Fail() || pointee_sp.get() == nullptr)
646 return 0;
647 return pointee_sp->GetData(data, error);
648 } else {
649 ValueObjectSP child_sp = GetChildAtIndex(0);
650 if (child_sp.get() == nullptr)
651 return 0;
653 return child_sp->GetData(data, error);
654 }
655 return true;
656 } else /* (items > 1) */
657 {
659 lldb_private::DataBufferHeap *heap_buf_ptr = nullptr;
660 lldb::DataBufferSP data_sp(heap_buf_ptr =
662
663 AddressType addr_type;
664 lldb::addr_t addr = is_pointer_type ? GetPointerValue(&addr_type)
665 : GetAddressOf(true, &addr_type);
666
667 switch (addr_type) {
668 case eAddressTypeFile: {
669 ModuleSP module_sp(GetModule());
670 if (module_sp) {
671 addr = addr + offset;
672 Address so_addr;
673 module_sp->ResolveFileAddress(addr, so_addr);
675 Target *target = exe_ctx.GetTargetPtr();
676 if (target) {
677 heap_buf_ptr->SetByteSize(bytes);
678 size_t bytes_read = target->ReadMemory(
679 so_addr, heap_buf_ptr->GetBytes(), bytes, error, true);
680 if (error.Success()) {
681 data.SetData(data_sp);
682 return bytes_read;
683 }
684 }
685 }
686 } break;
687 case eAddressTypeLoad: {
689 Process *process = exe_ctx.GetProcessPtr();
690 if (process) {
691 heap_buf_ptr->SetByteSize(bytes);
692 size_t bytes_read = process->ReadMemory(
693 addr + offset, heap_buf_ptr->GetBytes(), bytes, error);
694 if (error.Success() || bytes_read > 0) {
695 data.SetData(data_sp);
696 return bytes_read;
697 }
698 }
699 } break;
700 case eAddressTypeHost: {
701 auto max_bytes =
703 if (max_bytes && *max_bytes > offset) {
704 size_t bytes_read = std::min<uint64_t>(*max_bytes - offset, bytes);
706 if (addr == 0 || addr == LLDB_INVALID_ADDRESS)
707 break;
708 heap_buf_ptr->CopyData((uint8_t *)(addr + offset), bytes_read);
709 data.SetData(data_sp);
710 return bytes_read;
711 }
712 } break;
714 break;
715 }
716 }
717 return 0;
718}
719
721 UpdateValueIfNeeded(false);
723 error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
724 if (error.Fail()) {
725 if (m_data.GetByteSize()) {
726 data = m_data;
727 error.Clear();
728 return data.GetByteSize();
729 } else {
730 return 0;
731 }
732 }
735 return data.GetByteSize();
736}
737
739 error.Clear();
740 // Make sure our value is up to date first so that our location and location
741 // type is valid.
742 if (!UpdateValueIfNeeded(false)) {
743 error.SetErrorString("unable to read value");
744 return false;
745 }
746
747 uint64_t count = 0;
748 const Encoding encoding = GetCompilerType().GetEncoding(count);
749
750 const size_t byte_size = GetByteSize().value_or(0);
751
753
754 switch (value_type) {
756 error.SetErrorString("invalid location");
757 return false;
759 Status set_error =
760 m_value.GetScalar().SetValueFromData(data, encoding, byte_size);
761
762 if (!set_error.Success()) {
763 error.SetErrorStringWithFormat("unable to set scalar value: %s",
764 set_error.AsCString());
765 return false;
766 }
767 } break;
769 // If it is a load address, then the scalar value is the storage location
770 // of the data, and we have to shove this value down to that load location.
772 Process *process = exe_ctx.GetProcessPtr();
773 if (process) {
775 size_t bytes_written = process->WriteMemory(
776 target_addr, data.GetDataStart(), byte_size, error);
777 if (!error.Success())
778 return false;
779 if (bytes_written != byte_size) {
780 error.SetErrorString("unable to write value to memory");
781 return false;
782 }
783 }
784 } break;
786 // If it is a host address, then we stuff the scalar as a DataBuffer into
787 // the Value's data.
788 DataBufferSP buffer_sp(new DataBufferHeap(byte_size, 0));
789 m_data.SetData(buffer_sp, 0);
790 data.CopyByteOrderedData(0, byte_size,
791 const_cast<uint8_t *>(m_data.GetDataStart()),
792 byte_size, m_data.GetByteOrder());
793 m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
794 } break;
796 break;
797 }
798
799 // If we have reached this point, then we have successfully changed the
800 // value.
802 return true;
803}
804
805static bool CopyStringDataToBufferSP(const StreamString &source,
806 lldb::WritableDataBufferSP &destination) {
807 llvm::StringRef src = source.GetString();
808 src = src.rtrim('\0');
809 destination = std::make_shared<DataBufferHeap>(src.size(), 0);
810 memcpy(destination->GetBytes(), src.data(), src.size());
811 return true;
812}
813
814std::pair<size_t, bool>
816 Status &error, bool honor_array) {
817 bool was_capped = false;
818 StreamString s;
820 Target *target = exe_ctx.GetTargetPtr();
821
822 if (!target) {
823 s << "<no target to read from>";
824 error.SetErrorString("no target to read from");
825 CopyStringDataToBufferSP(s, buffer_sp);
826 return {0, was_capped};
827 }
828
829 const auto max_length = target->GetMaximumSizeOfStringSummary();
830
831 size_t bytes_read = 0;
832 size_t total_bytes_read = 0;
833
834 CompilerType compiler_type = GetCompilerType();
835 CompilerType elem_or_pointee_compiler_type;
836 const Flags type_flags(GetTypeInfo(&elem_or_pointee_compiler_type));
837 if (type_flags.AnySet(eTypeIsArray | eTypeIsPointer) &&
838 elem_or_pointee_compiler_type.IsCharType()) {
839 addr_t cstr_address = LLDB_INVALID_ADDRESS;
840 AddressType cstr_address_type = eAddressTypeInvalid;
841
842 size_t cstr_len = 0;
843 bool capped_data = false;
844 const bool is_array = type_flags.Test(eTypeIsArray);
845 if (is_array) {
846 // We have an array
847 uint64_t array_size = 0;
848 if (compiler_type.IsArrayType(nullptr, &array_size)) {
849 cstr_len = array_size;
850 if (cstr_len > max_length) {
851 capped_data = true;
852 cstr_len = max_length;
853 }
854 }
855 cstr_address = GetAddressOf(true, &cstr_address_type);
856 } else {
857 // We have a pointer
858 cstr_address = GetPointerValue(&cstr_address_type);
859 }
860
861 if (cstr_address == 0 || cstr_address == LLDB_INVALID_ADDRESS) {
862 if (cstr_address_type == eAddressTypeHost && is_array) {
863 const char *cstr = GetDataExtractor().PeekCStr(0);
864 if (cstr == nullptr) {
865 s << "<invalid address>";
866 error.SetErrorString("invalid address");
867 CopyStringDataToBufferSP(s, buffer_sp);
868 return {0, was_capped};
869 }
870 s << llvm::StringRef(cstr, cstr_len);
871 CopyStringDataToBufferSP(s, buffer_sp);
872 return {cstr_len, was_capped};
873 } else {
874 s << "<invalid address>";
875 error.SetErrorString("invalid address");
876 CopyStringDataToBufferSP(s, buffer_sp);
877 return {0, was_capped};
878 }
879 }
880
881 Address cstr_so_addr(cstr_address);
882 DataExtractor data;
883 if (cstr_len > 0 && honor_array) {
884 // I am using GetPointeeData() here to abstract the fact that some
885 // ValueObjects are actually frozen pointers in the host but the pointed-
886 // to data lives in the debuggee, and GetPointeeData() automatically
887 // takes care of this
888 GetPointeeData(data, 0, cstr_len);
889
890 if ((bytes_read = data.GetByteSize()) > 0) {
891 total_bytes_read = bytes_read;
892 for (size_t offset = 0; offset < bytes_read; offset++)
893 s.Printf("%c", *data.PeekData(offset, 1));
894 if (capped_data)
895 was_capped = true;
896 }
897 } else {
898 cstr_len = max_length;
899 const size_t k_max_buf_size = 64;
900
901 size_t offset = 0;
902
903 int cstr_len_displayed = -1;
904 bool capped_cstr = false;
905 // I am using GetPointeeData() here to abstract the fact that some
906 // ValueObjects are actually frozen pointers in the host but the pointed-
907 // to data lives in the debuggee, and GetPointeeData() automatically
908 // takes care of this
909 while ((bytes_read = GetPointeeData(data, offset, k_max_buf_size)) > 0) {
910 total_bytes_read += bytes_read;
911 const char *cstr = data.PeekCStr(0);
912 size_t len = strnlen(cstr, k_max_buf_size);
913 if (cstr_len_displayed < 0)
914 cstr_len_displayed = len;
915
916 if (len == 0)
917 break;
918 cstr_len_displayed += len;
919 if (len > bytes_read)
920 len = bytes_read;
921 if (len > cstr_len)
922 len = cstr_len;
923
924 for (size_t offset = 0; offset < bytes_read; offset++)
925 s.Printf("%c", *data.PeekData(offset, 1));
926
927 if (len < k_max_buf_size)
928 break;
929
930 if (len >= cstr_len) {
931 capped_cstr = true;
932 break;
933 }
934
935 cstr_len -= len;
936 offset += len;
937 }
938
939 if (cstr_len_displayed >= 0) {
940 if (capped_cstr)
941 was_capped = true;
942 }
943 }
944 } else {
945 error.SetErrorString("not a string object");
946 s << "<not a string object>";
947 }
948 CopyStringDataToBufferSP(s, buffer_sp);
949 return {total_bytes_read, was_capped};
950}
951
953 if (!UpdateValueIfNeeded(true))
954 return nullptr;
955
956 // Return cached value.
957 if (!m_object_desc_str.empty())
958 return m_object_desc_str.c_str();
959
961 Process *process = exe_ctx.GetProcessPtr();
962 if (!process)
963 return nullptr;
964
965 // Returns the object description produced by one language runtime.
966 auto get_object_description = [&](LanguageType language) -> const char * {
967 if (LanguageRuntime *runtime = process->GetLanguageRuntime(language)) {
968 StreamString s;
969 if (runtime->GetObjectDescription(s, *this)) {
970 m_object_desc_str.append(std::string(s.GetString()));
971 return m_object_desc_str.c_str();
972 }
973 }
974 return nullptr;
975 };
976
977 // Try the native language runtime first.
978 LanguageType native_language = GetObjectRuntimeLanguage();
979 if (const char *desc = get_object_description(native_language))
980 return desc;
981
982 // Try the Objective-C language runtime. This fallback is necessary
983 // for Objective-C++ and mixed Objective-C / C++ programs.
984 if (Language::LanguageIsCFamily(native_language))
985 return get_object_description(eLanguageTypeObjC);
986 return nullptr;
987}
988
990 std::string &destination) {
991 if (UpdateValueIfNeeded(false))
992 return format.FormatObject(this, destination);
993 else
994 return false;
995}
996
998 std::string &destination) {
999 return GetValueAsCString(TypeFormatImpl_Format(format), destination);
1000}
1001
1003 if (UpdateValueIfNeeded(true)) {
1004 lldb::TypeFormatImplSP format_sp;
1005 lldb::Format my_format = GetFormat();
1006 if (my_format == lldb::eFormatDefault) {
1007 if (m_type_format_sp)
1008 format_sp = m_type_format_sp;
1009 else {
1011 my_format = eFormatUnsigned;
1012 else {
1014 const RegisterInfo *reg_info = m_value.GetRegisterInfo();
1015 if (reg_info)
1016 my_format = reg_info->format;
1017 } else {
1018 my_format = GetValue().GetCompilerType().GetFormat();
1019 }
1020 }
1021 }
1022 }
1023 if (my_format != m_last_format || m_value_str.empty()) {
1024 m_last_format = my_format;
1025 if (!format_sp)
1026 format_sp = std::make_shared<TypeFormatImpl_Format>(my_format);
1027 if (GetValueAsCString(*format_sp.get(), m_value_str)) {
1029 // The value was gotten successfully, so we consider the value as
1030 // changed if the value string differs
1032 }
1033 }
1034 }
1035 }
1036 if (m_value_str.empty())
1037 return nullptr;
1038 return m_value_str.c_str();
1039}
1040
1041// if > 8bytes, 0 is returned. this method should mostly be used to read
1042// address values out of pointers
1043uint64_t ValueObject::GetValueAsUnsigned(uint64_t fail_value, bool *success) {
1044 // If our byte size is zero this is an aggregate type that has children
1045 if (CanProvideValue()) {
1046 Scalar scalar;
1047 if (ResolveValue(scalar)) {
1048 if (success)
1049 *success = true;
1050 scalar.MakeUnsigned();
1051 return scalar.ULongLong(fail_value);
1052 }
1053 // fallthrough, otherwise...
1054 }
1055
1056 if (success)
1057 *success = false;
1058 return fail_value;
1059}
1060
1061int64_t ValueObject::GetValueAsSigned(int64_t fail_value, bool *success) {
1062 // If our byte size is zero this is an aggregate type that has children
1063 if (CanProvideValue()) {
1064 Scalar scalar;
1065 if (ResolveValue(scalar)) {
1066 if (success)
1067 *success = true;
1068 scalar.MakeSigned();
1069 return scalar.SLongLong(fail_value);
1070 }
1071 // fallthrough, otherwise...
1072 }
1073
1074 if (success)
1075 *success = false;
1076 return fail_value;
1077}
1078
1079// if any more "special cases" are added to
1080// ValueObject::DumpPrintableRepresentation() please keep this call up to date
1081// by returning true for your new special cases. We will eventually move to
1082// checking this call result before trying to display special cases
1084 ValueObjectRepresentationStyle val_obj_display, Format custom_format) {
1085 Flags flags(GetTypeInfo());
1086 if (flags.AnySet(eTypeIsArray | eTypeIsPointer) &&
1088 if (IsCStringContainer(true) &&
1089 (custom_format == eFormatCString || custom_format == eFormatCharArray ||
1090 custom_format == eFormatChar || custom_format == eFormatVectorOfChar))
1091 return true;
1092
1093 if (flags.Test(eTypeIsArray)) {
1094 if ((custom_format == eFormatBytes) ||
1095 (custom_format == eFormatBytesWithASCII))
1096 return true;
1097
1098 if ((custom_format == eFormatVectorOfChar) ||
1099 (custom_format == eFormatVectorOfFloat32) ||
1100 (custom_format == eFormatVectorOfFloat64) ||
1101 (custom_format == eFormatVectorOfSInt16) ||
1102 (custom_format == eFormatVectorOfSInt32) ||
1103 (custom_format == eFormatVectorOfSInt64) ||
1104 (custom_format == eFormatVectorOfSInt8) ||
1105 (custom_format == eFormatVectorOfUInt128) ||
1106 (custom_format == eFormatVectorOfUInt16) ||
1107 (custom_format == eFormatVectorOfUInt32) ||
1108 (custom_format == eFormatVectorOfUInt64) ||
1109 (custom_format == eFormatVectorOfUInt8))
1110 return true;
1111 }
1112 }
1113 return false;
1114}
1115
1117 Stream &s, ValueObjectRepresentationStyle val_obj_display,
1118 Format custom_format, PrintableRepresentationSpecialCases special,
1119 bool do_dump_error) {
1120
1121 // If the ValueObject has an error, we might end up dumping the type, which
1122 // is useful, but if we don't even have a type, then don't examine the object
1123 // further as that's not meaningful, only the error is.
1124 if (m_error.Fail() && !GetCompilerType().IsValid()) {
1125 if (do_dump_error)
1126 s.Printf("<%s>", m_error.AsCString());
1127 return false;
1128 }
1129
1130 Flags flags(GetTypeInfo());
1131
1132 bool allow_special =
1134 const bool only_special = false;
1135
1136 if (allow_special) {
1137 if (flags.AnySet(eTypeIsArray | eTypeIsPointer) &&
1139 // when being asked to get a printable display an array or pointer type
1140 // directly, try to "do the right thing"
1141
1142 if (IsCStringContainer(true) &&
1143 (custom_format == eFormatCString ||
1144 custom_format == eFormatCharArray || custom_format == eFormatChar ||
1145 custom_format ==
1146 eFormatVectorOfChar)) // print char[] & char* directly
1147 {
1148 Status error;
1150 std::pair<size_t, bool> read_string =
1151 ReadPointedString(buffer_sp, error,
1152 (custom_format == eFormatVectorOfChar) ||
1153 (custom_format == eFormatCharArray));
1154 lldb_private::formatters::StringPrinter::
1155 ReadBufferAndDumpToStreamOptions options(*this);
1156 options.SetData(DataExtractor(
1157 buffer_sp, lldb::eByteOrderInvalid,
1158 8)); // none of this matters for a string - pass some defaults
1159 options.SetStream(&s);
1160 options.SetPrefixToken(nullptr);
1161 options.SetQuote('"');
1162 options.SetSourceSize(buffer_sp->GetByteSize());
1163 options.SetIsTruncated(read_string.second);
1164 options.SetBinaryZeroIsTerminator(custom_format != eFormatVectorOfChar);
1166 lldb_private::formatters::StringPrinter::StringElementType::ASCII>(
1167 options);
1168 return !error.Fail();
1169 }
1170
1171 if (custom_format == eFormatEnum)
1172 return false;
1173
1174 // this only works for arrays, because I have no way to know when the
1175 // pointed memory ends, and no special \0 end of data marker
1176 if (flags.Test(eTypeIsArray)) {
1177 if ((custom_format == eFormatBytes) ||
1178 (custom_format == eFormatBytesWithASCII)) {
1179 const size_t count = GetNumChildren();
1180
1181 s << '[';
1182 for (size_t low = 0; low < count; low++) {
1183
1184 if (low)
1185 s << ',';
1186
1187 ValueObjectSP child = GetChildAtIndex(low);
1188 if (!child.get()) {
1189 s << "<invalid child>";
1190 continue;
1191 }
1192 child->DumpPrintableRepresentation(
1194 custom_format);
1195 }
1196
1197 s << ']';
1198
1199 return true;
1200 }
1201
1202 if ((custom_format == eFormatVectorOfChar) ||
1203 (custom_format == eFormatVectorOfFloat32) ||
1204 (custom_format == eFormatVectorOfFloat64) ||
1205 (custom_format == eFormatVectorOfSInt16) ||
1206 (custom_format == eFormatVectorOfSInt32) ||
1207 (custom_format == eFormatVectorOfSInt64) ||
1208 (custom_format == eFormatVectorOfSInt8) ||
1209 (custom_format == eFormatVectorOfUInt128) ||
1210 (custom_format == eFormatVectorOfUInt16) ||
1211 (custom_format == eFormatVectorOfUInt32) ||
1212 (custom_format == eFormatVectorOfUInt64) ||
1213 (custom_format == eFormatVectorOfUInt8)) // arrays of bytes, bytes
1214 // with ASCII or any vector
1215 // format should be printed
1216 // directly
1217 {
1218 const size_t count = GetNumChildren();
1219
1220 Format format = FormatManager::GetSingleItemFormat(custom_format);
1221
1222 s << '[';
1223 for (size_t low = 0; low < count; low++) {
1224
1225 if (low)
1226 s << ',';
1227
1228 ValueObjectSP child = GetChildAtIndex(low);
1229 if (!child.get()) {
1230 s << "<invalid child>";
1231 continue;
1232 }
1233 child->DumpPrintableRepresentation(
1235 }
1236
1237 s << ']';
1238
1239 return true;
1240 }
1241 }
1242
1243 if ((custom_format == eFormatBoolean) ||
1244 (custom_format == eFormatBinary) || (custom_format == eFormatChar) ||
1245 (custom_format == eFormatCharPrintable) ||
1246 (custom_format == eFormatComplexFloat) ||
1247 (custom_format == eFormatDecimal) || (custom_format == eFormatHex) ||
1248 (custom_format == eFormatHexUppercase) ||
1249 (custom_format == eFormatFloat) || (custom_format == eFormatOctal) ||
1250 (custom_format == eFormatOSType) ||
1251 (custom_format == eFormatUnicode16) ||
1252 (custom_format == eFormatUnicode32) ||
1253 (custom_format == eFormatUnsigned) ||
1254 (custom_format == eFormatPointer) ||
1255 (custom_format == eFormatComplexInteger) ||
1256 (custom_format == eFormatComplex) ||
1257 (custom_format == eFormatDefault)) // use the [] operator
1258 return false;
1259 }
1260 }
1261
1262 if (only_special)
1263 return false;
1264
1265 bool var_success = false;
1266
1267 {
1268 llvm::StringRef str;
1269
1270 // this is a local stream that we are using to ensure that the data pointed
1271 // to by cstr survives long enough for us to copy it to its destination -
1272 // it is necessary to have this temporary storage area for cases where our
1273 // desired output is not backed by some other longer-term storage
1274 StreamString strm;
1275
1276 if (custom_format != eFormatInvalid)
1277 SetFormat(custom_format);
1278
1279 switch (val_obj_display) {
1281 str = GetValueAsCString();
1282 break;
1283
1285 str = GetSummaryAsCString();
1286 break;
1287
1289 str = GetObjectDescription();
1290 break;
1291
1293 str = GetLocationAsCString();
1294 break;
1295
1297 strm.Printf("%" PRIu64 "", (uint64_t)GetNumChildren());
1298 str = strm.GetString();
1299 break;
1300
1302 str = GetTypeName().GetStringRef();
1303 break;
1304
1306 str = GetName().GetStringRef();
1307 break;
1308
1310 GetExpressionPath(strm);
1311 str = strm.GetString();
1312 break;
1313 }
1314
1315 // If the requested display style produced no output, try falling back to
1316 // alternative presentations.
1317 if (str.empty()) {
1318 if (val_obj_display == eValueObjectRepresentationStyleValue)
1319 str = GetSummaryAsCString();
1320 else if (val_obj_display == eValueObjectRepresentationStyleSummary) {
1321 if (!CanProvideValue()) {
1322 strm.Printf("%s @ %s", GetTypeName().AsCString(),
1324 str = strm.GetString();
1325 } else
1326 str = GetValueAsCString();
1327 }
1328 }
1329
1330 if (!str.empty())
1331 s << str;
1332 else {
1333 // We checked for errors at the start, but do it again here in case
1334 // realizing the value for dumping produced an error.
1335 if (m_error.Fail()) {
1336 if (do_dump_error)
1337 s.Printf("<%s>", m_error.AsCString());
1338 else
1339 return false;
1340 } else if (val_obj_display == eValueObjectRepresentationStyleSummary)
1341 s.PutCString("<no summary available>");
1342 else if (val_obj_display == eValueObjectRepresentationStyleValue)
1343 s.PutCString("<no value available>");
1344 else if (val_obj_display ==
1346 s.PutCString("<not a valid Objective-C object>"); // edit this if we
1347 // have other runtimes
1348 // that support a
1349 // description
1350 else
1351 s.PutCString("<no printable representation>");
1352 }
1353
1354 // we should only return false here if we could not do *anything* even if
1355 // we have an error message as output, that's a success from our callers'
1356 // perspective, so return true
1357 var_success = true;
1358
1359 if (custom_format != eFormatInvalid)
1361 }
1362
1363 return var_success;
1364}
1365
1366addr_t ValueObject::GetAddressOf(bool scalar_is_load_address,
1367 AddressType *address_type) {
1368 // Can't take address of a bitfield
1369 if (IsBitfield())
1370 return LLDB_INVALID_ADDRESS;
1371
1372 if (!UpdateValueIfNeeded(false))
1373 return LLDB_INVALID_ADDRESS;
1374
1375 switch (m_value.GetValueType()) {
1377 return LLDB_INVALID_ADDRESS;
1379 if (scalar_is_load_address) {
1380 if (address_type)
1381 *address_type = eAddressTypeLoad;
1383 }
1384 break;
1385
1388 if (address_type)
1389 *address_type = m_value.GetValueAddressType();
1391 } break;
1393 if (address_type)
1394 *address_type = m_value.GetValueAddressType();
1395 return LLDB_INVALID_ADDRESS;
1396 } break;
1397 }
1398 if (address_type)
1399 *address_type = eAddressTypeInvalid;
1400 return LLDB_INVALID_ADDRESS;
1401}
1402
1404 addr_t address = LLDB_INVALID_ADDRESS;
1405 if (address_type)
1406 *address_type = eAddressTypeInvalid;
1407
1408 if (!UpdateValueIfNeeded(false))
1409 return address;
1410
1411 switch (m_value.GetValueType()) {
1413 return LLDB_INVALID_ADDRESS;
1416 break;
1417
1421 lldb::offset_t data_offset = 0;
1422 address = m_data.GetAddress(&data_offset);
1423 } break;
1424 }
1425
1426 if (address_type)
1427 *address_type = GetAddressTypeOfChildren();
1428
1429 return address;
1430}
1431
1432bool ValueObject::SetValueFromCString(const char *value_str, Status &error) {
1433 error.Clear();
1434 // Make sure our value is up to date first so that our location and location
1435 // type is valid.
1436 if (!UpdateValueIfNeeded(false)) {
1437 error.SetErrorString("unable to read value");
1438 return false;
1439 }
1440
1441 uint64_t count = 0;
1442 const Encoding encoding = GetCompilerType().GetEncoding(count);
1443
1444 const size_t byte_size = GetByteSize().value_or(0);
1445
1446 Value::ValueType value_type = m_value.GetValueType();
1447
1448 if (value_type == Value::ValueType::Scalar) {
1449 // If the value is already a scalar, then let the scalar change itself:
1450 m_value.GetScalar().SetValueFromCString(value_str, encoding, byte_size);
1451 } else if (byte_size <= 16) {
1452 // If the value fits in a scalar, then make a new scalar and again let the
1453 // scalar code do the conversion, then figure out where to put the new
1454 // value.
1455 Scalar new_scalar;
1456 error = new_scalar.SetValueFromCString(value_str, encoding, byte_size);
1457 if (error.Success()) {
1458 switch (value_type) {
1460 // If it is a load address, then the scalar value is the storage
1461 // location of the data, and we have to shove this value down to that
1462 // load location.
1464 Process *process = exe_ctx.GetProcessPtr();
1465 if (process) {
1466 addr_t target_addr =
1468 size_t bytes_written = process->WriteScalarToMemory(
1469 target_addr, new_scalar, byte_size, error);
1470 if (!error.Success())
1471 return false;
1472 if (bytes_written != byte_size) {
1473 error.SetErrorString("unable to write value to memory");
1474 return false;
1475 }
1476 }
1477 } break;
1479 // If it is a host address, then we stuff the scalar as a DataBuffer
1480 // into the Value's data.
1481 DataExtractor new_data;
1482 new_data.SetByteOrder(m_data.GetByteOrder());
1483
1484 DataBufferSP buffer_sp(new DataBufferHeap(byte_size, 0));
1485 m_data.SetData(buffer_sp, 0);
1486 bool success = new_scalar.GetData(new_data);
1487 if (success) {
1488 new_data.CopyByteOrderedData(
1489 0, byte_size, const_cast<uint8_t *>(m_data.GetDataStart()),
1490 byte_size, m_data.GetByteOrder());
1491 }
1492 m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
1493
1494 } break;
1496 error.SetErrorString("invalid location");
1497 return false;
1500 break;
1501 }
1502 } else {
1503 return false;
1504 }
1505 } else {
1506 // We don't support setting things bigger than a scalar at present.
1507 error.SetErrorString("unable to write aggregate data type");
1508 return false;
1509 }
1510
1511 // If we have reached this point, then we have successfully changed the
1512 // value.
1514 return true;
1515}
1516
1518 decl.Clear();
1519 return false;
1520}
1521
1523 ValueObject *valobj) {
1524 m_synthetic_children[key] = valobj;
1525}
1526
1528 ValueObjectSP synthetic_child_sp;
1529 std::map<ConstString, ValueObject *>::const_iterator pos =
1530 m_synthetic_children.find(key);
1531 if (pos != m_synthetic_children.end())
1532 synthetic_child_sp = pos->second->GetSP();
1533 return synthetic_child_sp;
1534}
1535
1538 Process *process = exe_ctx.GetProcessPtr();
1539 if (process)
1540 return process->IsPossibleDynamicValue(*this);
1541 else
1542 return GetCompilerType().IsPossibleDynamicType(nullptr, true, true);
1543}
1544
1546 Process *process(GetProcessSP().get());
1547 if (!process)
1548 return false;
1549
1550 // We trust that the compiler did the right thing and marked runtime support
1551 // values as artificial.
1552 if (!GetVariable() || !GetVariable()->IsArtificial())
1553 return false;
1554
1555 if (auto *runtime = process->GetLanguageRuntime(GetVariable()->GetLanguage()))
1556 if (runtime->IsAllowedRuntimeValue(GetName()))
1557 return false;
1558
1559 return true;
1560}
1561
1564 return language->IsNilReference(*this);
1565 }
1566 return false;
1567}
1568
1571 return language->IsUninitializedReference(*this);
1572 }
1573 return false;
1574}
1575
1576// This allows you to create an array member using and index that doesn't not
1577// fall in the normal bounds of the array. Many times structure can be defined
1578// as: struct Collection {
1579// uint32_t item_count;
1580// Item item_array[0];
1581// };
1582// The size of the "item_array" is 1, but many times in practice there are more
1583// items in "item_array".
1584
1586 bool can_create) {
1587 ValueObjectSP synthetic_child_sp;
1588 if (IsPointerType() || IsArrayType()) {
1589 std::string index_str = llvm::formatv("[{0}]", index);
1590 ConstString index_const_str(index_str);
1591 // Check if we have already created a synthetic array member in this valid
1592 // object. If we have we will re-use it.
1593 synthetic_child_sp = GetSyntheticChild(index_const_str);
1594 if (!synthetic_child_sp) {
1595 ValueObject *synthetic_child;
1596 // We haven't made a synthetic array member for INDEX yet, so lets make
1597 // one and cache it for any future reference.
1598 synthetic_child = CreateChildAtIndex(0, true, index);
1599
1600 // Cache the value if we got one back...
1601 if (synthetic_child) {
1602 AddSyntheticChild(index_const_str, synthetic_child);
1603 synthetic_child_sp = synthetic_child->GetSP();
1604 synthetic_child_sp->SetName(ConstString(index_str));
1605 synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
1606 }
1607 }
1608 }
1609 return synthetic_child_sp;
1610}
1611
1613 bool can_create) {
1614 ValueObjectSP synthetic_child_sp;
1615 if (IsScalarType()) {
1616 std::string index_str = llvm::formatv("[{0}-{1}]", from, to);
1617 ConstString index_const_str(index_str);
1618 // Check if we have already created a synthetic array member in this valid
1619 // object. If we have we will re-use it.
1620 synthetic_child_sp = GetSyntheticChild(index_const_str);
1621 if (!synthetic_child_sp) {
1622 uint32_t bit_field_size = to - from + 1;
1623 uint32_t bit_field_offset = from;
1624 if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
1625 bit_field_offset =
1626 GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
1627 // We haven't made a synthetic array member for INDEX yet, so lets make
1628 // one and cache it for any future reference.
1629 ValueObjectChild *synthetic_child = new ValueObjectChild(
1630 *this, GetCompilerType(), index_const_str, GetByteSize().value_or(0),
1631 0, bit_field_size, bit_field_offset, false, false,
1633
1634 // Cache the value if we got one back...
1635 if (synthetic_child) {
1636 AddSyntheticChild(index_const_str, synthetic_child);
1637 synthetic_child_sp = synthetic_child->GetSP();
1638 synthetic_child_sp->SetName(ConstString(index_str));
1639 synthetic_child_sp->m_flags.m_is_bitfield_for_scalar = true;
1640 }
1641 }
1642 }
1643 return synthetic_child_sp;
1644}
1645
1647 uint32_t offset, const CompilerType &type, bool can_create,
1648 ConstString name_const_str) {
1649
1650 ValueObjectSP synthetic_child_sp;
1651
1652 if (name_const_str.IsEmpty()) {
1653 name_const_str.SetString("@" + std::to_string(offset));
1654 }
1655
1656 // Check if we have already created a synthetic array member in this valid
1657 // object. If we have we will re-use it.
1658 synthetic_child_sp = GetSyntheticChild(name_const_str);
1659
1660 if (synthetic_child_sp.get())
1661 return synthetic_child_sp;
1662
1663 if (!can_create)
1664 return {};
1665
1667 std::optional<uint64_t> size =
1669 if (!size)
1670 return {};
1671 ValueObjectChild *synthetic_child =
1672 new ValueObjectChild(*this, type, name_const_str, *size, offset, 0, 0,
1673 false, false, eAddressTypeInvalid, 0);
1674 if (synthetic_child) {
1675 AddSyntheticChild(name_const_str, synthetic_child);
1676 synthetic_child_sp = synthetic_child->GetSP();
1677 synthetic_child_sp->SetName(name_const_str);
1678 synthetic_child_sp->m_flags.m_is_child_at_offset = true;
1679 }
1680 return synthetic_child_sp;
1681}
1682
1684 const CompilerType &type,
1685 bool can_create,
1686 ConstString name_const_str) {
1687 ValueObjectSP synthetic_child_sp;
1688
1689 if (name_const_str.IsEmpty()) {
1690 char name_str[128];
1691 snprintf(name_str, sizeof(name_str), "base%s@%i",
1692 type.GetTypeName().AsCString("<unknown>"), offset);
1693 name_const_str.SetCString(name_str);
1694 }
1695
1696 // Check if we have already created a synthetic array member in this valid
1697 // object. If we have we will re-use it.
1698 synthetic_child_sp = GetSyntheticChild(name_const_str);
1699
1700 if (synthetic_child_sp.get())
1701 return synthetic_child_sp;
1702
1703 if (!can_create)
1704 return {};
1705
1706 const bool is_base_class = true;
1707
1709 std::optional<uint64_t> size =
1711 if (!size)
1712 return {};
1713 ValueObjectChild *synthetic_child =
1714 new ValueObjectChild(*this, type, name_const_str, *size, offset, 0, 0,
1715 is_base_class, false, eAddressTypeInvalid, 0);
1716 if (synthetic_child) {
1717 AddSyntheticChild(name_const_str, synthetic_child);
1718 synthetic_child_sp = synthetic_child->GetSP();
1719 synthetic_child_sp->SetName(name_const_str);
1720 }
1721 return synthetic_child_sp;
1722}
1723
1724// your expression path needs to have a leading . or -> (unless it somehow
1725// "looks like" an array, in which case it has a leading [ symbol). while the [
1726// is meaningful and should be shown to the user, . and -> are just parser
1727// design, but by no means added information for the user.. strip them off
1728static const char *SkipLeadingExpressionPathSeparators(const char *expression) {
1729 if (!expression || !expression[0])
1730 return expression;
1731 if (expression[0] == '.')
1732 return expression + 1;
1733 if (expression[0] == '-' && expression[1] == '>')
1734 return expression + 2;
1735 return expression;
1736}
1737
1740 bool can_create) {
1741 ValueObjectSP synthetic_child_sp;
1742 ConstString name_const_string(expression);
1743 // Check if we have already created a synthetic array member in this valid
1744 // object. If we have we will re-use it.
1745 synthetic_child_sp = GetSyntheticChild(name_const_string);
1746 if (!synthetic_child_sp) {
1747 // We haven't made a synthetic array member for expression yet, so lets
1748 // make one and cache it for any future reference.
1749 synthetic_child_sp = GetValueForExpressionPath(
1750 expression, nullptr, nullptr,
1751 GetValueForExpressionPathOptions().SetSyntheticChildrenTraversal(
1753 None));
1754
1755 // Cache the value if we got one back...
1756 if (synthetic_child_sp.get()) {
1757 // FIXME: this causes a "real" child to end up with its name changed to
1758 // the contents of expression
1759 AddSyntheticChild(name_const_string, synthetic_child_sp.get());
1760 synthetic_child_sp->SetName(
1762 }
1763 }
1764 return synthetic_child_sp;
1765}
1766
1768 TargetSP target_sp(GetTargetSP());
1769 if (target_sp && !target_sp->GetEnableSyntheticValue()) {
1770 m_synthetic_value = nullptr;
1771 return;
1772 }
1773
1775
1777 return;
1778
1779 if (m_synthetic_children_sp.get() == nullptr)
1780 return;
1781
1782 if (current_synth_sp == m_synthetic_children_sp && m_synthetic_value)
1783 return;
1784
1786}
1787
1789 if (use_dynamic == eNoDynamicValues)
1790 return;
1791
1792 if (!m_dynamic_value && !IsDynamic()) {
1794 Process *process = exe_ctx.GetProcessPtr();
1795 if (process && process->IsPossibleDynamicValue(*this)) {
1797 m_dynamic_value = new ValueObjectDynamicValue(*this, use_dynamic);
1798 }
1799 }
1800}
1801
1803 if (use_dynamic == eNoDynamicValues)
1804 return ValueObjectSP();
1805
1806 if (!IsDynamic() && m_dynamic_value == nullptr) {
1807 CalculateDynamicValue(use_dynamic);
1808 }
1810 return m_dynamic_value->GetSP();
1811 else
1812 return ValueObjectSP();
1813}
1814
1817
1819 return m_synthetic_value->GetSP();
1820 else
1821 return ValueObjectSP();
1822}
1823
1826
1827 if (m_synthetic_children_sp.get() == nullptr)
1828 return false;
1829
1831
1832 return m_synthetic_value != nullptr;
1833}
1834
1836 if (GetParent()) {
1837 if (GetParent()->IsBaseClass())
1838 return GetParent()->GetNonBaseClassParent();
1839 else
1840 return GetParent();
1841 }
1842 return nullptr;
1843}
1844
1845bool ValueObject::IsBaseClass(uint32_t &depth) {
1846 if (!IsBaseClass()) {
1847 depth = 0;
1848 return false;
1849 }
1850 if (GetParent()) {
1851 GetParent()->IsBaseClass(depth);
1852 depth = depth + 1;
1853 return true;
1854 }
1855 // TODO: a base of no parent? weird..
1856 depth = 1;
1857 return true;
1858}
1859
1861 GetExpressionPathFormat epformat) {
1862 // synthetic children do not actually "exist" as part of the hierarchy, and
1863 // sometimes they are consed up in ways that don't make sense from an
1864 // underlying language/API standpoint. So, use a special code path here to
1865 // return something that can hopefully be used in expression
1868
1871 s.Printf("((%s)0x%" PRIx64 ")", GetTypeName().AsCString("void"),
1873 return;
1874 } else {
1875 uint64_t load_addr =
1877 if (load_addr != LLDB_INVALID_ADDRESS) {
1878 s.Printf("(*( (%s *)0x%" PRIx64 "))", GetTypeName().AsCString("void"),
1879 load_addr);
1880 return;
1881 }
1882 }
1883 }
1884
1885 if (CanProvideValue()) {
1886 s.Printf("((%s)%s)", GetTypeName().AsCString("void"),
1888 return;
1889 }
1890
1891 return;
1892 }
1893
1894 const bool is_deref_of_parent = IsDereferenceOfParent();
1895
1896 if (is_deref_of_parent &&
1898 // this is the original format of GetExpressionPath() producing code like
1899 // *(a_ptr).memberName, which is entirely fine, until you put this into
1900 // StackFrame::GetValueForVariableExpressionPath() which prefers to see
1901 // a_ptr->memberName. the eHonorPointers mode is meant to produce strings
1902 // in this latter format
1903 s.PutCString("*(");
1904 }
1905
1906 ValueObject *parent = GetParent();
1907
1908 if (parent)
1909 parent->GetExpressionPath(s, epformat);
1910
1911 // if we are a deref_of_parent just because we are synthetic array members
1912 // made up to allow ptr[%d] syntax to work in variable printing, then add our
1913 // name ([%d]) to the expression path
1917
1918 if (!IsBaseClass()) {
1919 if (!is_deref_of_parent) {
1920 ValueObject *non_base_class_parent = GetNonBaseClassParent();
1921 if (non_base_class_parent &&
1922 !non_base_class_parent->GetName().IsEmpty()) {
1923 CompilerType non_base_class_parent_compiler_type =
1924 non_base_class_parent->GetCompilerType();
1925 if (non_base_class_parent_compiler_type) {
1926 if (parent && parent->IsDereferenceOfParent() &&
1928 s.PutCString("->");
1929 } else {
1930 const uint32_t non_base_class_parent_type_info =
1931 non_base_class_parent_compiler_type.GetTypeInfo();
1932
1933 if (non_base_class_parent_type_info & eTypeIsPointer) {
1934 s.PutCString("->");
1935 } else if ((non_base_class_parent_type_info & eTypeHasChildren) &&
1936 !(non_base_class_parent_type_info & eTypeIsArray)) {
1937 s.PutChar('.');
1938 }
1939 }
1940 }
1941 }
1942
1943 const char *name = GetName().GetCString();
1944 if (name)
1945 s.PutCString(name);
1946 }
1947 }
1948
1949 if (is_deref_of_parent &&
1951 s.PutChar(')');
1952 }
1953}
1954
1956 llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop,
1957 ExpressionPathEndResultType *final_value_type,
1958 const GetValueForExpressionPathOptions &options,
1959 ExpressionPathAftermath *final_task_on_target) {
1960
1961 ExpressionPathScanEndReason dummy_reason_to_stop =
1963 ExpressionPathEndResultType dummy_final_value_type =
1965 ExpressionPathAftermath dummy_final_task_on_target =
1967
1969 expression, reason_to_stop ? reason_to_stop : &dummy_reason_to_stop,
1970 final_value_type ? final_value_type : &dummy_final_value_type, options,
1971 final_task_on_target ? final_task_on_target
1972 : &dummy_final_task_on_target);
1973
1974 if (!final_task_on_target ||
1975 *final_task_on_target == ValueObject::eExpressionPathAftermathNothing)
1976 return ret_val;
1977
1978 if (ret_val.get() &&
1979 ((final_value_type ? *final_value_type : dummy_final_value_type) ==
1980 eExpressionPathEndResultTypePlain)) // I can only deref and takeaddress
1981 // of plain objects
1982 {
1983 if ((final_task_on_target ? *final_task_on_target
1984 : dummy_final_task_on_target) ==
1986 Status error;
1987 ValueObjectSP final_value = ret_val->Dereference(error);
1988 if (error.Fail() || !final_value.get()) {
1989 if (reason_to_stop)
1990 *reason_to_stop =
1992 if (final_value_type)
1994 return ValueObjectSP();
1995 } else {
1996 if (final_task_on_target)
1997 *final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
1998 return final_value;
1999 }
2000 }
2001 if (*final_task_on_target ==
2003 Status error;
2004 ValueObjectSP final_value = ret_val->AddressOf(error);
2005 if (error.Fail() || !final_value.get()) {
2006 if (reason_to_stop)
2007 *reason_to_stop =
2009 if (final_value_type)
2011 return ValueObjectSP();
2012 } else {
2013 if (final_task_on_target)
2014 *final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
2015 return final_value;
2016 }
2017 }
2018 }
2019 return ret_val; // final_task_on_target will still have its original value, so
2020 // you know I did not do it
2021}
2022
2024 llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop,
2025 ExpressionPathEndResultType *final_result,
2026 const GetValueForExpressionPathOptions &options,
2027 ExpressionPathAftermath *what_next) {
2028 ValueObjectSP root = GetSP();
2029
2030 if (!root)
2031 return nullptr;
2032
2033 llvm::StringRef remainder = expression;
2034
2035 while (true) {
2036 llvm::StringRef temp_expression = remainder;
2037
2038 CompilerType root_compiler_type = root->GetCompilerType();
2039 CompilerType pointee_compiler_type;
2040 Flags pointee_compiler_type_info;
2041
2042 Flags root_compiler_type_info(
2043 root_compiler_type.GetTypeInfo(&pointee_compiler_type));
2044 if (pointee_compiler_type)
2045 pointee_compiler_type_info.Reset(pointee_compiler_type.GetTypeInfo());
2046
2047 if (temp_expression.empty()) {
2049 return root;
2050 }
2051
2052 switch (temp_expression.front()) {
2053 case '-': {
2054 temp_expression = temp_expression.drop_front();
2055 if (options.m_check_dot_vs_arrow_syntax &&
2056 root_compiler_type_info.Test(eTypeIsPointer)) // if you are trying to
2057 // use -> on a
2058 // non-pointer and I
2059 // must catch the error
2060 {
2061 *reason_to_stop =
2064 return ValueObjectSP();
2065 }
2066 if (root_compiler_type_info.Test(eTypeIsObjC) && // if yo are trying to
2067 // extract an ObjC IVar
2068 // when this is forbidden
2069 root_compiler_type_info.Test(eTypeIsPointer) &&
2070 options.m_no_fragile_ivar) {
2071 *reason_to_stop =
2074 return ValueObjectSP();
2075 }
2076 if (!temp_expression.starts_with(">")) {
2077 *reason_to_stop =
2080 return ValueObjectSP();
2081 }
2082 }
2083 [[fallthrough]];
2084 case '.': // or fallthrough from ->
2085 {
2086 if (options.m_check_dot_vs_arrow_syntax &&
2087 temp_expression.front() == '.' &&
2088 root_compiler_type_info.Test(eTypeIsPointer)) // if you are trying to
2089 // use . on a pointer
2090 // and I must catch the
2091 // error
2092 {
2093 *reason_to_stop =
2096 return nullptr;
2097 }
2098 temp_expression = temp_expression.drop_front(); // skip . or >
2099
2100 size_t next_sep_pos = temp_expression.find_first_of("-.[", 1);
2101 if (next_sep_pos == llvm::StringRef::npos) // if no other separator just
2102 // expand this last layer
2103 {
2104 llvm::StringRef child_name = temp_expression;
2105 ValueObjectSP child_valobj_sp =
2106 root->GetChildMemberWithName(child_name);
2107
2108 if (child_valobj_sp.get()) // we know we are done, so just return
2109 {
2110 *reason_to_stop =
2113 return child_valobj_sp;
2114 } else {
2115 switch (options.m_synthetic_children_traversal) {
2117 None:
2118 break;
2121 if (root->IsSynthetic()) {
2122 child_valobj_sp = root->GetNonSyntheticValue();
2123 if (child_valobj_sp.get())
2124 child_valobj_sp =
2125 child_valobj_sp->GetChildMemberWithName(child_name);
2126 }
2127 break;
2130 if (!root->IsSynthetic()) {
2131 child_valobj_sp = root->GetSyntheticValue();
2132 if (child_valobj_sp.get())
2133 child_valobj_sp =
2134 child_valobj_sp->GetChildMemberWithName(child_name);
2135 }
2136 break;
2138 Both:
2139 if (root->IsSynthetic()) {
2140 child_valobj_sp = root->GetNonSyntheticValue();
2141 if (child_valobj_sp.get())
2142 child_valobj_sp =
2143 child_valobj_sp->GetChildMemberWithName(child_name);
2144 } else {
2145 child_valobj_sp = root->GetSyntheticValue();
2146 if (child_valobj_sp.get())
2147 child_valobj_sp =
2148 child_valobj_sp->GetChildMemberWithName(child_name);
2149 }
2150 break;
2151 }
2152 }
2153
2154 // if we are here and options.m_no_synthetic_children is true,
2155 // child_valobj_sp is going to be a NULL SP, so we hit the "else"
2156 // branch, and return an error
2157 if (child_valobj_sp.get()) // if it worked, just return
2158 {
2159 *reason_to_stop =
2162 return child_valobj_sp;
2163 } else {
2164 *reason_to_stop =
2167 return nullptr;
2168 }
2169 } else // other layers do expand
2170 {
2171 llvm::StringRef next_separator = temp_expression.substr(next_sep_pos);
2172 llvm::StringRef child_name = temp_expression.slice(0, next_sep_pos);
2173
2174 ValueObjectSP child_valobj_sp =
2175 root->GetChildMemberWithName(child_name);
2176 if (child_valobj_sp.get()) // store the new root and move on
2177 {
2178 root = child_valobj_sp;
2179 remainder = next_separator;
2181 continue;
2182 } else {
2183 switch (options.m_synthetic_children_traversal) {
2185 None:
2186 break;
2189 if (root->IsSynthetic()) {
2190 child_valobj_sp = root->GetNonSyntheticValue();
2191 if (child_valobj_sp.get())
2192 child_valobj_sp =
2193 child_valobj_sp->GetChildMemberWithName(child_name);
2194 }
2195 break;
2198 if (!root->IsSynthetic()) {
2199 child_valobj_sp = root->GetSyntheticValue();
2200 if (child_valobj_sp.get())
2201 child_valobj_sp =
2202 child_valobj_sp->GetChildMemberWithName(child_name);
2203 }
2204 break;
2206 Both:
2207 if (root->IsSynthetic()) {
2208 child_valobj_sp = root->GetNonSyntheticValue();
2209 if (child_valobj_sp.get())
2210 child_valobj_sp =
2211 child_valobj_sp->GetChildMemberWithName(child_name);
2212 } else {
2213 child_valobj_sp = root->GetSyntheticValue();
2214 if (child_valobj_sp.get())
2215 child_valobj_sp =
2216 child_valobj_sp->GetChildMemberWithName(child_name);
2217 }
2218 break;
2219 }
2220 }
2221
2222 // if we are here and options.m_no_synthetic_children is true,
2223 // child_valobj_sp is going to be a NULL SP, so we hit the "else"
2224 // branch, and return an error
2225 if (child_valobj_sp.get()) // if it worked, move on
2226 {
2227 root = child_valobj_sp;
2228 remainder = next_separator;
2230 continue;
2231 } else {
2232 *reason_to_stop =
2235 return nullptr;
2236 }
2237 }
2238 break;
2239 }
2240 case '[': {
2241 if (!root_compiler_type_info.Test(eTypeIsArray) &&
2242 !root_compiler_type_info.Test(eTypeIsPointer) &&
2243 !root_compiler_type_info.Test(
2244 eTypeIsVector)) // if this is not a T[] nor a T*
2245 {
2246 if (!root_compiler_type_info.Test(
2247 eTypeIsScalar)) // if this is not even a scalar...
2248 {
2249 if (options.m_synthetic_children_traversal ==
2251 None) // ...only chance left is synthetic
2252 {
2253 *reason_to_stop =
2256 return ValueObjectSP();
2257 }
2258 } else if (!options.m_allow_bitfields_syntax) // if this is a scalar,
2259 // check that we can
2260 // expand bitfields
2261 {
2262 *reason_to_stop =
2265 return ValueObjectSP();
2266 }
2267 }
2268 if (temp_expression[1] ==
2269 ']') // if this is an unbounded range it only works for arrays
2270 {
2271 if (!root_compiler_type_info.Test(eTypeIsArray)) {
2272 *reason_to_stop =
2275 return nullptr;
2276 } else // even if something follows, we cannot expand unbounded ranges,
2277 // just let the caller do it
2278 {
2279 *reason_to_stop =
2281 *final_result =
2283 return root;
2284 }
2285 }
2286
2287 size_t close_bracket_position = temp_expression.find(']', 1);
2288 if (close_bracket_position ==
2289 llvm::StringRef::npos) // if there is no ], this is a syntax error
2290 {
2291 *reason_to_stop =
2294 return nullptr;
2295 }
2296
2297 llvm::StringRef bracket_expr =
2298 temp_expression.slice(1, close_bracket_position);
2299
2300 // If this was an empty expression it would have been caught by the if
2301 // above.
2302 assert(!bracket_expr.empty());
2303
2304 if (!bracket_expr.contains('-')) {
2305 // if no separator, this is of the form [N]. Note that this cannot be
2306 // an unbounded range of the form [], because that case was handled
2307 // above with an unconditional return.
2308 unsigned long index = 0;
2309 if (bracket_expr.getAsInteger(0, index)) {
2310 *reason_to_stop =
2313 return nullptr;
2314 }
2315
2316 // from here on we do have a valid index
2317 if (root_compiler_type_info.Test(eTypeIsArray)) {
2318 ValueObjectSP child_valobj_sp = root->GetChildAtIndex(index);
2319 if (!child_valobj_sp)
2320 child_valobj_sp = root->GetSyntheticArrayMember(index, true);
2321 if (!child_valobj_sp)
2322 if (root->HasSyntheticValue() &&
2323 root->GetSyntheticValue()->GetNumChildren() > index)
2324 child_valobj_sp =
2325 root->GetSyntheticValue()->GetChildAtIndex(index);
2326 if (child_valobj_sp) {
2327 root = child_valobj_sp;
2328 remainder =
2329 temp_expression.substr(close_bracket_position + 1); // skip ]
2331 continue;
2332 } else {
2333 *reason_to_stop =
2336 return nullptr;
2337 }
2338 } else if (root_compiler_type_info.Test(eTypeIsPointer)) {
2339 if (*what_next ==
2340 ValueObject::
2341 eExpressionPathAftermathDereference && // if this is a
2342 // ptr-to-scalar, I
2343 // am accessing it
2344 // by index and I
2345 // would have
2346 // deref'ed anyway,
2347 // then do it now
2348 // and use this as
2349 // a bitfield
2350 pointee_compiler_type_info.Test(eTypeIsScalar)) {
2351 Status error;
2352 root = root->Dereference(error);
2353 if (error.Fail() || !root) {
2354 *reason_to_stop =
2357 return nullptr;
2358 } else {
2360 continue;
2361 }
2362 } else {
2363 if (root->GetCompilerType().GetMinimumLanguage() ==
2365 pointee_compiler_type_info.AllClear(eTypeIsPointer) &&
2366 root->HasSyntheticValue() &&
2369 SyntheticChildrenTraversal::ToSynthetic ||
2372 SyntheticChildrenTraversal::Both)) {
2373 root = root->GetSyntheticValue()->GetChildAtIndex(index);
2374 } else
2375 root = root->GetSyntheticArrayMember(index, true);
2376 if (!root) {
2377 *reason_to_stop =
2380 return nullptr;
2381 } else {
2382 remainder =
2383 temp_expression.substr(close_bracket_position + 1); // skip ]
2385 continue;
2386 }
2387 }
2388 } else if (root_compiler_type_info.Test(eTypeIsScalar)) {
2389 root = root->GetSyntheticBitFieldChild(index, index, true);
2390 if (!root) {
2391 *reason_to_stop =
2394 return nullptr;
2395 } else // we do not know how to expand members of bitfields, so we
2396 // just return and let the caller do any further processing
2397 {
2398 *reason_to_stop = ValueObject::
2401 return root;
2402 }
2403 } else if (root_compiler_type_info.Test(eTypeIsVector)) {
2404 root = root->GetChildAtIndex(index);
2405 if (!root) {
2406 *reason_to_stop =
2409 return ValueObjectSP();
2410 } else {
2411 remainder =
2412 temp_expression.substr(close_bracket_position + 1); // skip ]
2414 continue;
2415 }
2416 } else if (options.m_synthetic_children_traversal ==
2418 SyntheticChildrenTraversal::ToSynthetic ||
2421 SyntheticChildrenTraversal::Both) {
2422 if (root->HasSyntheticValue())
2423 root = root->GetSyntheticValue();
2424 else if (!root->IsSynthetic()) {
2425 *reason_to_stop =
2428 return nullptr;
2429 }
2430 // if we are here, then root itself is a synthetic VO.. should be
2431 // good to go
2432
2433 if (!root) {
2434 *reason_to_stop =
2437 return nullptr;
2438 }
2439 root = root->GetChildAtIndex(index);
2440 if (!root) {
2441 *reason_to_stop =
2444 return nullptr;
2445 } else {
2446 remainder =
2447 temp_expression.substr(close_bracket_position + 1); // skip ]
2449 continue;
2450 }
2451 } else {
2452 *reason_to_stop =
2455 return nullptr;
2456 }
2457 } else {
2458 // we have a low and a high index
2459 llvm::StringRef sleft, sright;
2460 unsigned long low_index, high_index;
2461 std::tie(sleft, sright) = bracket_expr.split('-');
2462 if (sleft.getAsInteger(0, low_index) ||
2463 sright.getAsInteger(0, high_index)) {
2464 *reason_to_stop =
2467 return nullptr;
2468 }
2469
2470 if (low_index > high_index) // swap indices if required
2471 std::swap(low_index, high_index);
2472
2473 if (root_compiler_type_info.Test(
2474 eTypeIsScalar)) // expansion only works for scalars
2475 {
2476 root = root->GetSyntheticBitFieldChild(low_index, high_index, true);
2477 if (!root) {
2478 *reason_to_stop =
2481 return nullptr;
2482 } else {
2483 *reason_to_stop = ValueObject::
2486 return root;
2487 }
2488 } else if (root_compiler_type_info.Test(
2489 eTypeIsPointer) && // if this is a ptr-to-scalar, I am
2490 // accessing it by index and I would
2491 // have deref'ed anyway, then do it
2492 // now and use this as a bitfield
2493 *what_next ==
2495 pointee_compiler_type_info.Test(eTypeIsScalar)) {
2496 Status error;
2497 root = root->Dereference(error);
2498 if (error.Fail() || !root) {
2499 *reason_to_stop =
2502 return nullptr;
2503 } else {
2505 continue;
2506 }
2507 } else {
2508 *reason_to_stop =
2511 return root;
2512 }
2513 }
2514 break;
2515 }
2516 default: // some non-separator is in the way
2517 {
2518 *reason_to_stop =
2521 return nullptr;
2522 }
2523 }
2524 }
2525}
2526
2528
2530 ValueObjectPrinter printer(*this, &s, options);
2531 printer.PrintValueObject();
2532}
2533
2535 ValueObjectSP valobj_sp;
2536
2537 if (UpdateValueIfNeeded(false) && m_error.Success()) {
2539
2540 DataExtractor data;
2543
2544 if (IsBitfield()) {
2546 m_error = v.GetValueAsData(&exe_ctx, data, GetModule().get());
2547 } else
2548 m_error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
2549
2551 exe_ctx.GetBestExecutionContextScope(), GetCompilerType(), name, data,
2552 GetAddressOf());
2553 }
2554
2555 if (!valobj_sp) {
2559 }
2560 return valobj_sp;
2561}
2562
2564 lldb::DynamicValueType dynValue, bool synthValue) {
2565 ValueObjectSP result_sp;
2566 switch (dynValue) {
2569 if (!IsDynamic())
2570 result_sp = GetDynamicValue(dynValue);
2571 } break;
2573 if (IsDynamic())
2574 result_sp = GetStaticValue();
2575 } break;
2576 }
2577 if (!result_sp)
2578 result_sp = GetSP();
2579 assert(result_sp);
2580
2581 bool is_synthetic = result_sp->IsSynthetic();
2582 if (synthValue && !is_synthetic) {
2583 if (auto synth_sp = result_sp->GetSyntheticValue())
2584 return synth_sp;
2585 }
2586 if (!synthValue && is_synthetic) {
2587 if (auto non_synth_sp = result_sp->GetNonSyntheticValue())
2588 return non_synth_sp;
2589 }
2590
2591 return result_sp;
2592}
2593
2595 if (m_deref_valobj)
2596 return m_deref_valobj->GetSP();
2597
2598 const bool is_pointer_or_reference_type = IsPointerOrReferenceType();
2599 if (is_pointer_or_reference_type) {
2600 bool omit_empty_base_classes = true;
2601 bool ignore_array_bounds = false;
2602
2603 std::string child_name_str;
2604 uint32_t child_byte_size = 0;
2605 int32_t child_byte_offset = 0;
2606 uint32_t child_bitfield_bit_size = 0;
2607 uint32_t child_bitfield_bit_offset = 0;
2608 bool child_is_base_class = false;
2609 bool child_is_deref_of_parent = false;
2610 const bool transparent_pointers = false;
2611 CompilerType compiler_type = GetCompilerType();
2612 CompilerType child_compiler_type;
2613 uint64_t language_flags = 0;
2614
2616
2617 child_compiler_type = compiler_type.GetChildCompilerTypeAtIndex(
2618 &exe_ctx, 0, transparent_pointers, omit_empty_base_classes,
2619 ignore_array_bounds, child_name_str, child_byte_size, child_byte_offset,
2620 child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
2621 child_is_deref_of_parent, this, language_flags);
2622 if (child_compiler_type && child_byte_size) {
2623 ConstString child_name;
2624 if (!child_name_str.empty())
2625 child_name.SetCString(child_name_str.c_str());
2626
2628 *this, child_compiler_type, child_name, child_byte_size,
2629 child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
2630 child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
2631 language_flags);
2632 }
2633
2634 // In case of incomplete child compiler type, use the pointee type and try
2635 // to recreate a new ValueObjectChild using it.
2636 if (!m_deref_valobj) {
2637 // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g.
2638 // `std::vector<int> &`). Remove ObjC restriction once that's resolved.
2641 child_compiler_type = compiler_type.GetPointeeType();
2642
2643 if (child_compiler_type) {
2644 ConstString child_name;
2645 if (!child_name_str.empty())
2646 child_name.SetCString(child_name_str.c_str());
2647
2649 *this, child_compiler_type, child_name, child_byte_size,
2650 child_byte_offset, child_bitfield_bit_size,
2651 child_bitfield_bit_offset, child_is_base_class,
2652 child_is_deref_of_parent, eAddressTypeInvalid, language_flags);
2653 }
2654 }
2655 }
2656
2657 } else if (HasSyntheticValue()) {
2659 GetSyntheticValue()->GetChildMemberWithName("$$dereference$$").get();
2660 } else if (IsSynthetic()) {
2661 m_deref_valobj = GetChildMemberWithName("$$dereference$$").get();
2662 }
2663
2664 if (m_deref_valobj) {
2665 error.Clear();
2666 return m_deref_valobj->GetSP();
2667 } else {
2668 StreamString strm;
2669 GetExpressionPath(strm);
2670
2671 if (is_pointer_or_reference_type)
2672 error.SetErrorStringWithFormat("dereference failed: (%s) %s",
2673 GetTypeName().AsCString("<invalid type>"),
2674 strm.GetData());
2675 else
2676 error.SetErrorStringWithFormat("not a pointer or reference type: (%s) %s",
2677 GetTypeName().AsCString("<invalid type>"),
2678 strm.GetData());
2679 return ValueObjectSP();
2680 }
2681}
2682
2685 return m_addr_of_valobj_sp;
2686
2687 AddressType address_type = eAddressTypeInvalid;
2688 const bool scalar_is_load_address = false;
2689 addr_t addr = GetAddressOf(scalar_is_load_address, &address_type);
2690 error.Clear();
2691 if (addr != LLDB_INVALID_ADDRESS && address_type != eAddressTypeHost) {
2692 switch (address_type) {
2693 case eAddressTypeInvalid: {
2694 StreamString expr_path_strm;
2695 GetExpressionPath(expr_path_strm);
2696 error.SetErrorStringWithFormat("'%s' is not in memory",
2697 expr_path_strm.GetData());
2698 } break;
2699
2700 case eAddressTypeFile:
2701 case eAddressTypeLoad: {
2702 CompilerType compiler_type = GetCompilerType();
2703 if (compiler_type) {
2704 std::string name(1, '&');
2705 name.append(m_name.AsCString(""));
2709 compiler_type.GetPointerType(), ConstString(name.c_str()), addr,
2711 }
2712 } break;
2713 default:
2714 break;
2715 }
2716 } else {
2717 StreamString expr_path_strm;
2718 GetExpressionPath(expr_path_strm);
2719 error.SetErrorStringWithFormat("'%s' doesn't have a valid address",
2720 expr_path_strm.GetData());
2721 }
2722
2723 return m_addr_of_valobj_sp;
2724}
2725
2727 return ValueObjectCast::Create(*this, GetName(), compiler_type);
2728}
2729
2731 // Only allow casts if the original type is equal or larger than the cast
2732 // type. We don't know how to fetch more data for all the ConstResult types,
2733 // so we can't guarantee this will work:
2734 Status error;
2735 CompilerType my_type = GetCompilerType();
2736
2737 ExecutionContextScope *exe_scope
2740 if (compiler_type.GetByteSize(exe_scope)
2741 <= GetCompilerType().GetByteSize(exe_scope)) {
2742 return DoCast(compiler_type);
2743 }
2744 error.SetErrorString("Can only cast to a type that is equal to or smaller "
2745 "than the orignal type.");
2746
2748 ExecutionContext(GetExecutionContextRef()).GetBestExecutionContextScope(),
2749 error);
2750}
2751
2753 return ValueObjectCast::Create(*this, new_name, GetCompilerType());
2754}
2755
2757 CompilerType &compiler_type) {
2758 ValueObjectSP valobj_sp;
2759 AddressType address_type;
2760 addr_t ptr_value = GetPointerValue(&address_type);
2761
2762 if (ptr_value != LLDB_INVALID_ADDRESS) {
2763 Address ptr_addr(ptr_value);
2765 valobj_sp = ValueObjectMemory::Create(
2766 exe_ctx.GetBestExecutionContextScope(), name, ptr_addr, compiler_type);
2767 }
2768 return valobj_sp;
2769}
2770
2772 ValueObjectSP valobj_sp;
2773 AddressType address_type;
2774 addr_t ptr_value = GetPointerValue(&address_type);
2775
2776 if (ptr_value != LLDB_INVALID_ADDRESS) {
2777 Address ptr_addr(ptr_value);
2779 valobj_sp = ValueObjectMemory::Create(
2780 exe_ctx.GetBestExecutionContextScope(), name, ptr_addr, type_sp);
2781 }
2782 return valobj_sp;
2783}
2784
2785ValueObject::EvaluationPoint::EvaluationPoint() : m_mod_id(), m_exe_ctx_ref() {}
2786
2788 bool use_selected)
2789 : m_mod_id(), m_exe_ctx_ref() {
2790 ExecutionContext exe_ctx(exe_scope);
2791 TargetSP target_sp(exe_ctx.GetTargetSP());
2792 if (target_sp) {
2793 m_exe_ctx_ref.SetTargetSP(target_sp);
2794 ProcessSP process_sp(exe_ctx.GetProcessSP());
2795 if (!process_sp)
2796 process_sp = target_sp->GetProcessSP();
2797
2798 if (process_sp) {
2799 m_mod_id = process_sp->GetModID();
2800 m_exe_ctx_ref.SetProcessSP(process_sp);
2801
2802 ThreadSP thread_sp(exe_ctx.GetThreadSP());
2803
2804 if (!thread_sp) {
2805 if (use_selected)
2806 thread_sp = process_sp->GetThreadList().GetSelectedThread();
2807 }
2808
2809 if (thread_sp) {
2810 m_exe_ctx_ref.SetThreadSP(thread_sp);
2811
2812 StackFrameSP frame_sp(exe_ctx.GetFrameSP());
2813 if (!frame_sp) {
2814 if (use_selected)
2815 frame_sp = thread_sp->GetSelectedFrame(DoNoSelectMostRelevantFrame);
2816 }
2817 if (frame_sp)
2818 m_exe_ctx_ref.SetFrameSP(frame_sp);
2819 }
2820 }
2821 }
2822}
2823
2826 : m_mod_id(), m_exe_ctx_ref(rhs.m_exe_ctx_ref) {}
2827
2829
2830// This function checks the EvaluationPoint against the current process state.
2831// If the current state matches the evaluation point, or the evaluation point
2832// is already invalid, then we return false, meaning "no change". If the
2833// current state is different, we update our state, and return true meaning
2834// "yes, change". If we did see a change, we also set m_needs_update to true,
2835// so future calls to NeedsUpdate will return true. exe_scope will be set to
2836// the current execution context scope.
2837
2839 bool accept_invalid_exe_ctx) {
2840 // Start with the target, if it is NULL, then we're obviously not going to
2841 // get any further:
2842 const bool thread_and_frame_only_if_stopped = true;
2843 ExecutionContext exe_ctx(
2844 m_exe_ctx_ref.Lock(thread_and_frame_only_if_stopped));
2845
2846 if (exe_ctx.GetTargetPtr() == nullptr)
2847 return false;
2848
2849 // If we don't have a process nothing can change.
2850 Process *process = exe_ctx.GetProcessPtr();
2851 if (process == nullptr)
2852 return false;
2853
2854 // If our stop id is the current stop ID, nothing has changed:
2855 ProcessModID current_mod_id = process->GetModID();
2856
2857 // If the current stop id is 0, either we haven't run yet, or the process
2858 // state has been cleared. In either case, we aren't going to be able to sync
2859 // with the process state.
2860 if (current_mod_id.GetStopID() == 0)
2861 return false;
2862
2863 bool changed = false;
2864 const bool was_valid = m_mod_id.IsValid();
2865 if (was_valid) {
2866 if (m_mod_id == current_mod_id) {
2867 // Everything is already up to date in this object, no need to update the
2868 // execution context scope.
2869 changed = false;
2870 } else {
2871 m_mod_id = current_mod_id;
2872 m_needs_update = true;
2873 changed = true;
2874 }
2875 }
2876
2877 // Now re-look up the thread and frame in case the underlying objects have
2878 // gone away & been recreated. That way we'll be sure to return a valid
2879 // exe_scope. If we used to have a thread or a frame but can't find it
2880 // anymore, then mark ourselves as invalid.
2881
2882 if (!accept_invalid_exe_ctx) {
2883 if (m_exe_ctx_ref.HasThreadRef()) {
2884 ThreadSP thread_sp(m_exe_ctx_ref.GetThreadSP());
2885 if (thread_sp) {
2886 if (m_exe_ctx_ref.HasFrameRef()) {
2887 StackFrameSP frame_sp(m_exe_ctx_ref.GetFrameSP());
2888 if (!frame_sp) {
2889 // We used to have a frame, but now it is gone
2890 SetInvalid();
2891 changed = was_valid;
2892 }
2893 }
2894 } else {
2895 // We used to have a thread, but now it is gone
2896 SetInvalid();
2897 changed = was_valid;
2898 }
2899 }
2900 }
2901
2902 return changed;
2903}
2904
2906 ProcessSP process_sp(m_exe_ctx_ref.GetProcessSP());
2907 if (process_sp)
2908 m_mod_id = process_sp->GetModID();
2909 m_needs_update = false;
2910}
2911
2912void ValueObject::ClearUserVisibleData(uint32_t clear_mask) {
2913 if ((clear_mask & eClearUserVisibleDataItemsValue) ==
2915 m_value_str.clear();
2916
2917 if ((clear_mask & eClearUserVisibleDataItemsLocation) ==
2919 m_location_str.clear();
2920
2921 if ((clear_mask & eClearUserVisibleDataItemsSummary) ==
2923 m_summary_str.clear();
2924
2925 if ((clear_mask & eClearUserVisibleDataItemsDescription) ==
2927 m_object_desc_str.clear();
2928
2932 m_synthetic_value = nullptr;
2933 }
2934}
2935
2937 if (m_parent) {
2940 }
2941 return nullptr;
2942}
2943
2946 llvm::StringRef expression,
2947 const ExecutionContext &exe_ctx) {
2948 return CreateValueObjectFromExpression(name, expression, exe_ctx,
2950}
2951
2953 llvm::StringRef name, llvm::StringRef expression,
2954 const ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options) {
2955 lldb::ValueObjectSP retval_sp;
2956 lldb::TargetSP target_sp(exe_ctx.GetTargetSP());
2957 if (!target_sp)
2958 return retval_sp;
2959 if (expression.empty())
2960 return retval_sp;
2961 target_sp->EvaluateExpression(expression, exe_ctx.GetFrameSP().get(),
2962 retval_sp, options);
2963 if (retval_sp && !name.empty())
2964 retval_sp->SetName(ConstString(name));
2965 return retval_sp;
2966}
2967
2969 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
2970 CompilerType type) {
2971 if (type) {
2972 CompilerType pointer_type(type.GetPointerType());
2973 if (pointer_type) {
2974 lldb::DataBufferSP buffer(
2975 new lldb_private::DataBufferHeap(&address, sizeof(lldb::addr_t)));
2977 exe_ctx.GetBestExecutionContextScope(), pointer_type,
2978 ConstString(name), buffer, exe_ctx.GetByteOrder(),
2979 exe_ctx.GetAddressByteSize()));
2980 if (ptr_result_valobj_sp) {
2981 ptr_result_valobj_sp->GetValue().SetValueType(
2983 Status err;
2984 ptr_result_valobj_sp = ptr_result_valobj_sp->Dereference(err);
2985 if (ptr_result_valobj_sp && !name.empty())
2986 ptr_result_valobj_sp->SetName(ConstString(name));
2987 }
2988 return ptr_result_valobj_sp;
2989 }
2990 }
2991 return lldb::ValueObjectSP();
2992}
2993
2995 llvm::StringRef name, const DataExtractor &data,
2996 const ExecutionContext &exe_ctx, CompilerType type) {
2997 lldb::ValueObjectSP new_value_sp;
2998 new_value_sp = ValueObjectConstResult::Create(
2999 exe_ctx.GetBestExecutionContextScope(), type, ConstString(name), data,
3001 new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
3002 if (new_value_sp && !name.empty())
3003 new_value_sp->SetName(ConstString(name));
3004 return new_value_sp;
3005}
3006
3008 ValueObject *root(GetRoot());
3009 if (root != this)
3010 return root->GetModule();
3011 return lldb::ModuleSP();
3012}
3013
3015 if (m_root)
3016 return m_root;
3017 return (m_root = FollowParentChain([](ValueObject *vo) -> bool {
3018 return (vo->m_parent != nullptr);
3019 }));
3020}
3021
3024 ValueObject *vo = this;
3025 while (vo) {
3026 if (!f(vo))
3027 break;
3028 vo = vo->m_parent;
3029 }
3030 return vo;
3031}
3032
3035 ValueObject *root(GetRoot());
3036 if (root != this)
3037 return root->GetAddressTypeOfChildren();
3038 }
3040}
3041
3043 ValueObject *with_dv_info = this;
3044 while (with_dv_info) {
3045 if (with_dv_info->HasDynamicValueTypeInfo())
3046 return with_dv_info->GetDynamicValueTypeImpl();
3047 with_dv_info = with_dv_info->m_parent;
3048 }
3050}
3051
3053 const ValueObject *with_fmt_info = this;
3054 while (with_fmt_info) {
3055 if (with_fmt_info->m_format != lldb::eFormatDefault)
3056 return with_fmt_info->m_format;
3057 with_fmt_info = with_fmt_info->m_parent;
3058 }
3059 return m_format;
3060}
3061
3065 if (GetRoot()) {
3066 if (GetRoot() == this) {
3067 if (StackFrameSP frame_sp = GetFrameSP()) {
3068 const SymbolContext &sc(
3069 frame_sp->GetSymbolContext(eSymbolContextCompUnit));
3070 if (CompileUnit *cu = sc.comp_unit)
3071 type = cu->GetLanguage();
3072 }
3073 } else {
3075 }
3076 }
3077 }
3078 return (m_preferred_display_language = type); // only compute it once
3079}
3080
3084}
3085
3087 // we need to support invalid types as providers of values because some bare-
3088 // board debugging scenarios have no notion of types, but still manage to
3089 // have raw numeric values for things like registers. sigh.
3091 return (!type.IsValid()) || (0 != (type.GetTypeInfo() & eTypeHasValue));
3092}
3093
3094
3095
3097 if (!UpdateValueIfNeeded())
3098 return nullptr;
3099
3100 TargetSP target_sp(GetTargetSP());
3101 if (!target_sp)
3102 return nullptr;
3103
3104 PersistentExpressionState *persistent_state =
3105 target_sp->GetPersistentExpressionStateForLanguage(
3107
3108 if (!persistent_state)
3109 return nullptr;
3110
3111 ConstString name = persistent_state->GetNextPersistentVariableName();
3112
3113 ValueObjectSP const_result_sp =
3114 ValueObjectConstResult::Create(target_sp.get(), GetValue(), name);
3115
3116 ExpressionVariableSP persistent_var_sp =
3117 persistent_state->CreatePersistentVariable(const_result_sp);
3118 persistent_var_sp->m_live_sp = persistent_var_sp->m_frozen_sp;
3119 persistent_var_sp->m_flags |= ExpressionVariable::EVIsProgramReference;
3120
3121 return persistent_var_sp->GetValueObject();
3122}
3123
3125 return ValueObjectVTable::Create(*this);
3126}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition: Log.h:349
static user_id_t g_value_obj_uid
Definition: ValueObject.cpp:79
static bool CopyStringDataToBufferSP(const StreamString &source, lldb::WritableDataBufferSP &destination)
static const char * SkipLeadingExpressionPathSeparators(const char *expression)
A section + offset based address class.
Definition: Address.h:62
An architecture specification class.
Definition: ArchSpec.h:31
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:691
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition: ArchSpec.cpp:738
void ManageObject(T *new_object)
Definition: SharedCluster.h:33
A class that describes a compilation unit.
Definition: CompileUnit.h:41
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
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
bool IsPossibleDynamicType(CompilerType *target_type, bool check_cplusplus, bool check_objc) const
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
lldb::Encoding GetEncoding(uint64_t &count) 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.
ConstString GetTypeName(bool BaseOnly=false) const
uint32_t GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const
Lookup a child given a name.
lldb::Format GetFormat() const
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
A uniqued constant string class.
Definition: ConstString.h:40
void SetCString(const char *cstr)
Set the C string value.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:188
bool IsEmpty() const
Test for empty string.
Definition: ConstString.h:302
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:197
void SetString(llvm::StringRef s)
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:214
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.
An data extractor class.
Definition: DataExtractor.h:48
const uint8_t * PeekData(lldb::offset_t offset, lldb::offset_t length) const
Peek at a bytes at offset.
void SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
uint64_t GetAddress(lldb::offset_t *offset_ptr) const
Extract an address from *offset_ptr.
void Checksum(llvm::SmallVectorImpl< uint8_t > &dest, uint64_t max_data=0)
const uint8_t * GetDataStart() const
Get the data start pointer.
lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
uint32_t GetAddressByteSize() const
Get the current address size.
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
void SetAddressByteSize(uint32_t addr_size)
Set the address byte size.
lldb::offset_t CopyByteOrderedData(lldb::offset_t src_offset, lldb::offset_t src_len, void *dst, lldb::offset_t dst_len, lldb::ByteOrder dst_byte_order) const
Copy dst_len bytes from *offset_ptr and ensure the copied data is treated as a value that can be swap...
const char * PeekCStr(lldb::offset_t offset) const
Peek at a C string at offset.
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)
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
void Clear()
Clear the object's state.
Definition: Declaration.h:57
void SetThreadSP(const lldb::ThreadSP &thread_sp)
Set accessor that creates a weak reference to the thread referenced in thread_sp.
void SetFrameSP(const lldb::StackFrameSP &frame_sp)
Set accessor that creates a weak reference to the frame referenced in frame_sp.
void SetTargetSP(const lldb::TargetSP &target_sp)
Set accessor that creates a weak reference to the target referenced in target_sp.
void SetProcessSP(const lldb::ProcessSP &process_sp)
Set accessor that creates a weak reference to the process referenced in process_sp.
"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.
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.
A class to manage flags.
Definition: Flags.h:22
bool AllClear(ValueType mask) const
Test if all bits in mask are clear.
Definition: Flags.h:103
void Reset(ValueType flags)
Set accessor for all flags.
Definition: Flags.h:52
bool Test(ValueType bit) const
Test a single flag bit.
Definition: Flags.h:96
bool AnySet(ValueType mask) const
Test one or more flags.
Definition: Flags.h:90
static lldb::Format GetSingleItemFormat(lldb::Format vector_format)
static Language * FindPlugin(lldb::LanguageType language)
Definition: Language.cpp:53
static bool LanguageIsCFamily(lldb::LanguageType language)
Equivalent to LanguageIsC||LanguageIsObjC||LanguageIsCPlusPlus.
Definition: Language.cpp:305
static bool LanguageIsObjC(lldb::LanguageType language)
Definition: Language.cpp:283
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
Definition: Process.h:248
bool IsValid() const
Definition: Process.h:266
A plug-in interface definition class for debugging a process.
Definition: Process.h:340
ProcessModID GetModID() const
Get the Modification ID of the process.
Definition: Process.h:1457
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition: Process.cpp:1938
bool IsPossibleDynamicValue(ValueObject &in_value)
Definition: Process.cpp:1550
LanguageRuntime * GetLanguageRuntime(lldb::LanguageType language)
Definition: Process.cpp:1522
size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error)
Write memory to a process.
Definition: Process.cpp:2137
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.
Definition: Process.cpp:2219
Status SetValueFromData(const DataExtractor &data, lldb::Encoding encoding, size_t byte_size)
Definition: Scalar.cpp:702
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition: Scalar.cpp:335
bool GetData(DataExtractor &data, size_t limit_byte_size=UINT32_MAX) const
Definition: Scalar.cpp:85
long long SLongLong(long long fail_value=0) const
Definition: Scalar.cpp:331
bool ExtractBitfield(uint32_t bit_size, uint32_t bit_offset)
Definition: Scalar.cpp:799
Status SetValueFromCString(const char *s, lldb::Encoding encoding, size_t byte_size)
Definition: Scalar.cpp:631
bool IsValid() const
Definition: Scalar.h:106
An error handling class.
Definition: Status.h:44
void Clear()
Clear the object state.
Definition: Status.cpp:167
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:233
bool Success() const
Test for success condition.
Definition: Status.cpp:279
const char * GetData() const
Definition: StreamString.h:43
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:65
size_t PutChar(char ch)
Definition: Stream.cpp:131
"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.
Definition: SymbolContext.h:34
CompileUnit * comp_unit
The CompileUnit for a given query.
uint32_t GetMaximumSizeOfStringSummary() const
Definition: Target.cpp:4619
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)
Definition: Target.cpp:1833
virtual bool FormatObject(ValueObject *valobj, std::string &dest) const =0
virtual bool FormatObject(ValueObject *valobj, std::string &dest, const TypeSummaryOptions &options)=0
lldb::LanguageType GetLanguage() const
Definition: TypeSummary.cpp:31
TypeSummaryOptions & SetLanguage(lldb::LanguageType)
Definition: TypeSummary.cpp:37
static lldb::ValueObjectSP Create(ValueObject &parent, ConstString name, const CompilerType &cast_type)
A child of another ValueObject.
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
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)
static lldb::ValueObjectSP Create(ValueObject &parent)
ValueObject * GetChildAtIndex(size_t idx)
Definition: ValueObject.h:794
void SetChildAtIndex(size_t idx, ValueObject *valobj)
Definition: ValueObject.h:800
bool SyncWithProcessState(bool accept_invalid_exe_ctx)
AddressType m_address_type_of_ptr_or_ref_children
Definition: ValueObject.h:885
void SetValueIsValid(bool valid)
Definition: ValueObject.h:969
EvaluationPoint m_update_point
Stores both the stop id and the full context at which this value was last updated.
Definition: ValueObject.h:836
lldb::TypeSummaryImplSP GetSummaryFormat()
Definition: ValueObject.h:706
llvm::SmallVector< uint8_t, 16 > m_value_checksum
Definition: ValueObject.h:887
virtual uint32_t GetBitfieldBitSize()
Definition: ValueObject.h:424
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.
Definition: ValueObject.h:857
virtual bool IsInScope()
Definition: ValueObject.h:420
lldb::ValueObjectSP Cast(const CompilerType &compiler_type)
const EvaluationPoint & GetUpdatePoint() const
Definition: ValueObject.h:326
void AddSyntheticChild(ConstString key, ValueObject *valobj)
virtual uint64_t GetData(DataExtractor &data, Status &error)
uint32_t m_last_format_mgr_revision
Definition: ValueObject.h:880
friend class ValueObjectSynthetic
Definition: ValueObject.h:924
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
Definition: ValueObject.h:872
virtual lldb::DynamicValueType GetDynamicValueTypeImpl()
Definition: ValueObject.h:945
lldb::addr_t GetPointerValue(AddressType *address_type=nullptr)
virtual bool GetIsConstant() const
Definition: ValueObject.h:682
size_t GetNumChildren(uint32_t max=UINT32_MAX)
virtual bool MightHaveChildren()
Find out if a ValueObject might have children.
static lldb::ValueObjectSP CreateValueObjectFromExpression(llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx)
virtual bool IsDereferenceOfParent()
Definition: ValueObject.h:402
CompilerType GetCompilerType()
Definition: ValueObject.h:352
void SetValueFormat(lldb::TypeFormatImplSP format)
Definition: ValueObject.h:716
virtual void CalculateSyntheticValue()
void SetPreferredDisplayLanguage(lldb::LanguageType lt)
Definition: ValueObject.h:702
struct lldb_private::ValueObject::Bitflags m_flags
ValueObject(ExecutionContextScope *exe_scope, ValueObjectManager &manager, AddressType child_ptr_or_ref_addr_type=eAddressTypeLoad)
Use this constructor to create a "root variable object".
Definition: ValueObject.cpp:93
virtual size_t CalculateNumChildren(uint32_t max=UINT32_MAX)=0
Should only be called by ValueObject::GetNumChildren().
std::string m_summary_str
Cached summary string that will get cleared if/when the value is updated.
Definition: ValueObject.h:852
virtual lldb::ValueObjectSP DoCast(const CompilerType &compiler_type)
lldb::ValueObjectSP GetSP()
Definition: ValueObject.h:539
ChildrenManager m_children
Definition: ValueObject.h:867
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.
Definition: ValueObject.h:844
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....
Definition: ValueObject.h:865
lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to, bool can_create)
lldb::ProcessSP GetProcessSP() const
Definition: ValueObject.h:338
lldb::ValueObjectSP GetSyntheticChild(ConstString key) const
@ eExpressionPathScanEndReasonArrowInsteadOfDot
-> used when . should be used.
Definition: ValueObject.h:135
@ eExpressionPathScanEndReasonDereferencingFailed
Impossible to apply * operator.
Definition: ValueObject.h:151
@ eExpressionPathScanEndReasonNoSuchChild
Child element not found.
Definition: ValueObject.h:127
@ eExpressionPathScanEndReasonDotInsteadOfArrow
. used when -> should be used.
Definition: ValueObject.h:133
@ eExpressionPathScanEndReasonEndOfString
Out of data to parse.
Definition: ValueObject.h:125
@ eExpressionPathScanEndReasonBitfieldRangeOperatorMet
[] is good for bitfields, but I cannot parse after it.
Definition: ValueObject.h:145
@ eExpressionPathScanEndReasonRangeOperatorNotAllowed
[] not allowed by options.
Definition: ValueObject.h:139
@ eExpressionPathScanEndReasonEmptyRangeNotAllowed
[] only allowed for arrays.
Definition: ValueObject.h:131
@ eExpressionPathScanEndReasonRangeOperatorInvalid
[] not valid on objects other than scalars, pointers or arrays.
Definition: ValueObject.h:141
@ eExpressionPathScanEndReasonUnexpectedSymbol
Something is malformed in he expression.
Definition: ValueObject.h:147
@ eExpressionPathScanEndReasonArrayRangeOperatorMet
[] is good for arrays, but I cannot parse it.
Definition: ValueObject.h:143
@ eExpressionPathScanEndReasonSyntheticValueMissing
getting the synthetic children failed.
Definition: ValueObject.h:155
@ eExpressionPathScanEndReasonTakingAddressFailed
Impossible to apply & operator.
Definition: ValueObject.h:149
@ eExpressionPathScanEndReasonFragileIVarNotAllowed
ObjC ivar expansion not allowed.
Definition: ValueObject.h:137
virtual bool UpdateValue()=0
lldb::Format GetFormat() const
virtual lldb::VariableSP GetVariable()
Definition: ValueObject.h:774
@ eExpressionPathAftermathNothing
Just return it.
Definition: ValueObject.h:175
@ eExpressionPathAftermathDereference
Dereference the target.
Definition: ValueObject.h:177
@ eExpressionPathAftermathTakeAddress
Take target's address.
Definition: ValueObject.h:179
virtual std::optional< uint64_t > GetByteSize()=0
virtual size_t GetIndexOfChildWithName(llvm::StringRef name)
ValueObject * GetNonBaseClassParent()
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)
DataExtractor m_data
A data extractor that can be used to extract the value.
Definition: ValueObject.h:840
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)
virtual bool IsDynamic()
Definition: ValueObject.h:627
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
virtual void GetExpressionPath(Stream &s, GetExpressionPathFormat=eGetExpressionPathFormatDereferencePointers)
virtual bool HasSyntheticValue()
lldb::StackFrameSP GetFrameSP() const
Definition: ValueObject.h:346
friend class ValueObjectChild
Definition: ValueObject.h:920
lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef< llvm::StringRef > names)
void SetSummaryFormat(lldb::TypeSummaryImplSP format)
Definition: ValueObject.h:711
virtual bool IsRuntimeSupportValue()
virtual ConstString GetTypeName()
Definition: ValueObject.h:365
DataExtractor & GetDataExtractor()
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
void SetValueDidChange(bool value_changed)
Definition: ValueObject.h:965
void SetNumChildren(size_t num_children)
ValueObject * m_root
The root of the hierarchy for this ValueObject (or nullptr if never calculated).
Definition: ValueObject.h:832
bool GetValueIsValid() const
Definition: ValueObject.h:529
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)
virtual lldb::ValueObjectSP AddressOf(Status &error)
lldb::DynamicValueType GetDynamicValueType()
lldb::LanguageType m_preferred_display_language
Definition: ValueObject.h:889
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr)
Definition: ValueObject.h:378
lldb::LanguageType GetObjectRuntimeLanguage()
Definition: ValueObject.h:373
virtual lldb::ValueObjectSP CreateConstantValue(ConstString name)
virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address=true, AddressType *address_type=nullptr)
virtual bool IsLogicalTrue(Status &error)
lldb::Format m_last_format
Definition: ValueObject.h:879
virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create=true)
virtual SymbolContextScope * GetSymbolContextScope()
virtual bool HasDynamicValueTypeInfo()
Definition: ValueObject.h:949
ValueObject * m_synthetic_value
Definition: ValueObject.h:871
ValueObject * m_parent
The parent value object, or nullptr if this has no parent.
Definition: ValueObject.h:829
virtual bool IsBaseClass()
Definition: ValueObject.h:398
virtual bool GetDeclaration(Declaration &decl)
virtual lldb::ValueObjectSP Clone(ConstString new_name)
Creates a copy of the ValueObject with a new name and setting the current ValueObject as its parent.
lldb::ValueObjectSP GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue, bool synthValue)
virtual ValueObject * CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index)
Should only be called by ValueObject::GetChildAtIndex().
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...
Definition: ValueObject.h:876
std::pair< size_t, bool > ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, bool honor_array)
bool UpdateValueIfNeeded(bool update_format=true)
AddressType GetAddressTypeOfChildren()
const Status & GetError()
lldb::TypeFormatImplSP m_type_format_sp
Definition: ValueObject.h:882
lldb::TargetSP GetTargetSP() const
Definition: ValueObject.h:334
@ eExpressionPathEndResultTypePlain
Anything but...
Definition: ValueObject.h:161
@ eExpressionPathEndResultTypeBoundedRange
A range [low-high].
Definition: ValueObject.h:165
@ eExpressionPathEndResultTypeBitfield
A bitfield.
Definition: ValueObject.h:163
@ eExpressionPathEndResultTypeUnboundedRange
A range [].
Definition: ValueObject.h:167
virtual lldb::ValueObjectSP Dereference(Status &error)
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type)
void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType)
virtual const char * GetValueAsCString()
bool HasSpecialPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display, lldb::Format custom_format)
virtual const char * GetLocationAsCString()
Definition: ValueObject.h:492
ConstString GetName() const
Definition: ValueObject.h:463
std::string m_location_str
Cached location string that will get cleared if/when the value is updated.
Definition: ValueObject.h:850
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()
Definition: ValueObject.h:574
lldb::ValueObjectSP Persist()
std::string m_object_desc_str
Cached result of the "object printer".
Definition: ValueObject.h:855
virtual ValueObject * GetParent()
Definition: ValueObject.h:742
virtual CompilerType MaybeCalculateCompleteType()
lldb::SyntheticChildrenSP m_synthetic_children_sp
Definition: ValueObject.h:883
const char * GetObjectDescription()
virtual uint32_t GetBitfieldBitOffset()
Definition: ValueObject.h:426
std::string m_old_value_str
Cached old value string from the last time the value was gotten.
Definition: ValueObject.h:848
lldb::ValueObjectSP GetSyntheticExpressionPathChild(const char *expression, bool can_create)
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)
@ eValueObjectRepresentationStyleLanguageSpecific
Definition: ValueObject.h:115
std::string m_value_str
Cached value string that will get cleared if/when the value is updated.
Definition: ValueObject.h:846
lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create)
virtual bool ResolveValue(Scalar &scalar)
void SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp)
Definition: ValueObject.h:726
ConstString m_name
The name of this object.
Definition: ValueObject.h:838
const char * GetLocationAsCStringImpl(const Value &value, const DataExtractor &data)
virtual void SetFormat(lldb::Format format)
Definition: ValueObject.h:694
ValueObject * m_dynamic_value
Definition: ValueObject.h:870
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()
Definition: ValueObject.h:582
std::map< ConstString, ValueObject * > m_synthetic_children
Definition: ValueObject.h:868
const ExecutionContextRef & GetExecutionContextRef() const
Definition: ValueObject.h:330
virtual bool CanProvideValue()
const Value & GetValue() const
Definition: ValueObject.h:481
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)
const Scalar & GetScalar() const
Definition: Value.h:112
Status GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, Module *module)
Definition: Value.cpp:315
RegisterInfo * GetRegisterInfo() const
Definition: Value.cpp:140
ValueType
Type that describes Value::m_value.
Definition: Value.h:41
@ 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
Definition: Value.cpp:109
Scalar & ResolveValue(ExecutionContext *exe_ctx, Module *module=nullptr)
Definition: Value.cpp:577
@ RegisterInfo
RegisterInfo * (can be a scalar or a vector register).
ContextType GetContextType() const
Definition: Value.h:87
AddressType GetValueAddressType() const
Definition: Value.cpp:111
const CompilerType & GetCompilerType()
Definition: Value.cpp:239
uint8_t * GetBytes()
Get a pointer to the data.
Definition: DataBuffer.h:108
static bool ReadBufferAndDumpToStream(const ReadBufferAndDumpToStreamOptions &options)
#define UINT64_MAX
Definition: lldb-defines.h:23
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
#define UINT32_MAX
Definition: lldb-defines.h:19
@ DoNoSelectMostRelevantFrame
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:314
@ 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.
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:412
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
Definition: lldb-forward.h:463
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:438
std::shared_ptr< lldb_private::TypeFormatImpl > TypeFormatImplSP
Definition: lldb-forward.h:460
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:472
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
Definition: lldb-forward.h:343
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...
@ eFormatVectorOfChar
@ eFormatVectorOfUInt64
@ eFormatVectorOfSInt64
@ eFormatComplex
Floating point complex type.
@ eFormatBytesWithASCII
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatUnicode16
@ eFormatVectorOfUInt128
@ eFormatVectorOfUInt8
@ eFormatComplexFloat
@ eFormatVectorOfFloat32
@ eFormatVectorOfSInt32
@ eFormatUnicode32
@ eFormatVectorOfSInt8
@ eFormatVectorOfUInt16
@ eFormatHexUppercase
@ eFormatVectorOfFloat64
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
@ eFormatVectorOfSInt16
@ eFormatVectorOfUInt32
uint64_t offset_t
Definition: lldb-types.h:83
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeObjC
Objective-C.
std::shared_ptr< lldb_private::Type > TypeSP
Definition: lldb-forward.h:449
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:381
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eByteOrderInvalid
std::shared_ptr< lldb_private::SyntheticChildren > SyntheticChildrenSP
Definition: lldb-forward.h:433
uint64_t user_id_t
Definition: lldb-types.h:80
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
Definition: lldb-forward.h:328
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
Definition: lldb-forward.h:329
uint64_t addr_t
Definition: lldb-types.h:79
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:436
@ eDynamicDontRunTarget
@ eDynamicCanRunTarget
@ eNoDynamicValues
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:365
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.