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(uint32_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 < GetNumChildrenIgnoringErrors()) {
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
443llvm::Expected<uint32_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
455 auto num_children_or_err = CalculateNumChildren();
456 if (num_children_or_err)
457 SetNumChildren(*num_children_or_err);
458 else
459 return num_children_or_err;
460 }
462}
463
465 auto value_or_err = GetNumChildren(max);
466 if (value_or_err)
467 return *value_or_err;
468 LLDB_LOG_ERRORV(GetLog(LLDBLog::DataFormatters), value_or_err.takeError(),
469 "{0}");
470 return 0;
471}
472
474 bool has_children = false;
475 const uint32_t type_info = GetTypeInfo();
476 if (type_info) {
477 if (type_info & (eTypeHasChildren | eTypeIsPointer | eTypeIsReference))
478 has_children = true;
479 } else {
480 has_children = GetNumChildrenIgnoringErrors() > 0;
481 }
482 return has_children;
483}
484
485// Should only be called by ValueObject::GetNumChildren()
486void ValueObject::SetNumChildren(uint32_t num_children) {
488 m_children.SetChildrenCount(num_children);
489}
490
492 bool synthetic_array_member,
493 int32_t synthetic_index) {
494 ValueObject *valobj = nullptr;
495
496 bool omit_empty_base_classes = true;
497 bool ignore_array_bounds = synthetic_array_member;
498 std::string child_name_str;
499 uint32_t child_byte_size = 0;
500 int32_t child_byte_offset = 0;
501 uint32_t child_bitfield_bit_size = 0;
502 uint32_t child_bitfield_bit_offset = 0;
503 bool child_is_base_class = false;
504 bool child_is_deref_of_parent = false;
505 uint64_t language_flags = 0;
506
507 const bool transparent_pointers = !synthetic_array_member;
508 CompilerType child_compiler_type;
509
511
512 child_compiler_type = GetCompilerType().GetChildCompilerTypeAtIndex(
513 &exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
514 ignore_array_bounds, child_name_str, child_byte_size, child_byte_offset,
515 child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
516 child_is_deref_of_parent, this, language_flags);
517 if (child_compiler_type) {
518 if (synthetic_index)
519 child_byte_offset += child_byte_size * synthetic_index;
520
521 ConstString child_name;
522 if (!child_name_str.empty())
523 child_name.SetCString(child_name_str.c_str());
524
525 valobj = new ValueObjectChild(
526 *this, child_compiler_type, child_name, child_byte_size,
527 child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
528 child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
529 language_flags);
530 }
531
532 // In case of an incomplete type, try to use the ValueObject's
533 // synthetic value to create the child ValueObject.
534 if (!valobj && synthetic_array_member) {
535 if (ValueObjectSP synth_valobj_sp = GetSyntheticValue()) {
536 valobj = synth_valobj_sp
537 ->GetChildAtIndex(synthetic_index, synthetic_array_member)
538 .get();
539 }
540 }
541
542 return valobj;
543}
544
546 std::string &destination,
547 lldb::LanguageType lang) {
548 return GetSummaryAsCString(summary_ptr, destination,
549 TypeSummaryOptions().SetLanguage(lang));
550}
551
553 std::string &destination,
554 const TypeSummaryOptions &options) {
555 destination.clear();
556
557 // If we have a forcefully completed type, don't try and show a summary from
558 // a valid summary string or function because the type is not complete and
559 // no member variables or member functions will be available.
560 if (GetCompilerType().IsForcefullyCompleted()) {
561 destination = "<incomplete type>";
562 return true;
563 }
564
565 // ideally we would like to bail out if passing NULL, but if we do so we end
566 // up not providing the summary for function pointers anymore
567 if (/*summary_ptr == NULL ||*/ m_flags.m_is_getting_summary)
568 return false;
569
571
572 TypeSummaryOptions actual_options(options);
573
574 if (actual_options.GetLanguage() == lldb::eLanguageTypeUnknown)
576
577 // this is a hot path in code and we prefer to avoid setting this string all
578 // too often also clearing out other information that we might care to see in
579 // a crash log. might be useful in very specific situations though.
580 /*Host::SetCrashDescriptionWithFormat("Trying to fetch a summary for %s %s.
581 Summary provider's description is %s",
582 GetTypeName().GetCString(),
583 GetName().GetCString(),
584 summary_ptr->GetDescription().c_str());*/
585
586 if (UpdateValueIfNeeded(false) && summary_ptr) {
587 if (HasSyntheticValue())
588 m_synthetic_value->UpdateValueIfNeeded(); // the summary might depend on
589 // the synthetic children being
590 // up-to-date (e.g. ${svar%#})
591 summary_ptr->FormatObject(this, destination, actual_options);
592 }
594 return !destination.empty();
595}
596
598 if (UpdateValueIfNeeded(true) && m_summary_str.empty()) {
599 TypeSummaryOptions summary_options;
600 summary_options.SetLanguage(lang);
602 summary_options);
603 }
604 if (m_summary_str.empty())
605 return nullptr;
606 return m_summary_str.c_str();
607}
608
609bool ValueObject::GetSummaryAsCString(std::string &destination,
610 const TypeSummaryOptions &options) {
611 return GetSummaryAsCString(GetSummaryFormat().get(), destination, options);
612}
613
614bool ValueObject::IsCStringContainer(bool check_pointer) {
615 CompilerType pointee_or_element_compiler_type;
616 const Flags type_flags(GetTypeInfo(&pointee_or_element_compiler_type));
617 bool is_char_arr_ptr(type_flags.AnySet(eTypeIsArray | eTypeIsPointer) &&
618 pointee_or_element_compiler_type.IsCharType());
619 if (!is_char_arr_ptr)
620 return false;
621 if (!check_pointer)
622 return true;
623 if (type_flags.Test(eTypeIsArray))
624 return true;
625 addr_t cstr_address = LLDB_INVALID_ADDRESS;
626 AddressType cstr_address_type = eAddressTypeInvalid;
627 cstr_address = GetPointerValue(&cstr_address_type);
628 return (cstr_address != LLDB_INVALID_ADDRESS);
629}
630
631size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,
632 uint32_t item_count) {
633 CompilerType pointee_or_element_compiler_type;
634 const uint32_t type_info = GetTypeInfo(&pointee_or_element_compiler_type);
635 const bool is_pointer_type = type_info & eTypeIsPointer;
636 const bool is_array_type = type_info & eTypeIsArray;
637 if (!(is_pointer_type || is_array_type))
638 return 0;
639
640 if (item_count == 0)
641 return 0;
642
644
645 std::optional<uint64_t> item_type_size =
646 pointee_or_element_compiler_type.GetByteSize(
648 if (!item_type_size)
649 return 0;
650 const uint64_t bytes = item_count * *item_type_size;
651 const uint64_t offset = item_idx * *item_type_size;
652
653 if (item_idx == 0 && item_count == 1) // simply a deref
654 {
655 if (is_pointer_type) {
657 ValueObjectSP pointee_sp = Dereference(error);
658 if (error.Fail() || pointee_sp.get() == nullptr)
659 return 0;
660 return pointee_sp->GetData(data, error);
661 } else {
662 ValueObjectSP child_sp = GetChildAtIndex(0);
663 if (child_sp.get() == nullptr)
664 return 0;
666 return child_sp->GetData(data, error);
667 }
668 return true;
669 } else /* (items > 1) */
670 {
672 lldb_private::DataBufferHeap *heap_buf_ptr = nullptr;
673 lldb::DataBufferSP data_sp(heap_buf_ptr =
675
676 AddressType addr_type;
677 lldb::addr_t addr = is_pointer_type ? GetPointerValue(&addr_type)
678 : GetAddressOf(true, &addr_type);
679
680 switch (addr_type) {
681 case eAddressTypeFile: {
682 ModuleSP module_sp(GetModule());
683 if (module_sp) {
684 addr = addr + offset;
685 Address so_addr;
686 module_sp->ResolveFileAddress(addr, so_addr);
688 Target *target = exe_ctx.GetTargetPtr();
689 if (target) {
690 heap_buf_ptr->SetByteSize(bytes);
691 size_t bytes_read = target->ReadMemory(
692 so_addr, heap_buf_ptr->GetBytes(), bytes, error, true);
693 if (error.Success()) {
694 data.SetData(data_sp);
695 return bytes_read;
696 }
697 }
698 }
699 } break;
700 case eAddressTypeLoad: {
702 Process *process = exe_ctx.GetProcessPtr();
703 if (process) {
704 heap_buf_ptr->SetByteSize(bytes);
705 size_t bytes_read = process->ReadMemory(
706 addr + offset, heap_buf_ptr->GetBytes(), bytes, error);
707 if (error.Success() || bytes_read > 0) {
708 data.SetData(data_sp);
709 return bytes_read;
710 }
711 }
712 } break;
713 case eAddressTypeHost: {
714 auto max_bytes =
716 if (max_bytes && *max_bytes > offset) {
717 size_t bytes_read = std::min<uint64_t>(*max_bytes - offset, bytes);
719 if (addr == 0 || addr == LLDB_INVALID_ADDRESS)
720 break;
721 heap_buf_ptr->CopyData((uint8_t *)(addr + offset), bytes_read);
722 data.SetData(data_sp);
723 return bytes_read;
724 }
725 } break;
727 break;
728 }
729 }
730 return 0;
731}
732
734 UpdateValueIfNeeded(false);
736 error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
737 if (error.Fail()) {
738 if (m_data.GetByteSize()) {
739 data = m_data;
740 error.Clear();
741 return data.GetByteSize();
742 } else {
743 return 0;
744 }
745 }
748 return data.GetByteSize();
749}
750
752 error.Clear();
753 // Make sure our value is up to date first so that our location and location
754 // type is valid.
755 if (!UpdateValueIfNeeded(false)) {
756 error.SetErrorString("unable to read value");
757 return false;
758 }
759
760 uint64_t count = 0;
761 const Encoding encoding = GetCompilerType().GetEncoding(count);
762
763 const size_t byte_size = GetByteSize().value_or(0);
764
766
767 switch (value_type) {
769 error.SetErrorString("invalid location");
770 return false;
772 Status set_error =
773 m_value.GetScalar().SetValueFromData(data, encoding, byte_size);
774
775 if (!set_error.Success()) {
776 error.SetErrorStringWithFormat("unable to set scalar value: %s",
777 set_error.AsCString());
778 return false;
779 }
780 } break;
782 // If it is a load address, then the scalar value is the storage location
783 // of the data, and we have to shove this value down to that load location.
785 Process *process = exe_ctx.GetProcessPtr();
786 if (process) {
788 size_t bytes_written = process->WriteMemory(
789 target_addr, data.GetDataStart(), byte_size, error);
790 if (!error.Success())
791 return false;
792 if (bytes_written != byte_size) {
793 error.SetErrorString("unable to write value to memory");
794 return false;
795 }
796 }
797 } break;
799 // If it is a host address, then we stuff the scalar as a DataBuffer into
800 // the Value's data.
801 DataBufferSP buffer_sp(new DataBufferHeap(byte_size, 0));
802 m_data.SetData(buffer_sp, 0);
803 data.CopyByteOrderedData(0, byte_size,
804 const_cast<uint8_t *>(m_data.GetDataStart()),
805 byte_size, m_data.GetByteOrder());
806 m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
807 } break;
809 break;
810 }
811
812 // If we have reached this point, then we have successfully changed the
813 // value.
815 return true;
816}
817
818static bool CopyStringDataToBufferSP(const StreamString &source,
819 lldb::WritableDataBufferSP &destination) {
820 llvm::StringRef src = source.GetString();
821 src = src.rtrim('\0');
822 destination = std::make_shared<DataBufferHeap>(src.size(), 0);
823 memcpy(destination->GetBytes(), src.data(), src.size());
824 return true;
825}
826
827std::pair<size_t, bool>
829 Status &error, bool honor_array) {
830 bool was_capped = false;
831 StreamString s;
833 Target *target = exe_ctx.GetTargetPtr();
834
835 if (!target) {
836 s << "<no target to read from>";
837 error.SetErrorString("no target to read from");
838 CopyStringDataToBufferSP(s, buffer_sp);
839 return {0, was_capped};
840 }
841
842 const auto max_length = target->GetMaximumSizeOfStringSummary();
843
844 size_t bytes_read = 0;
845 size_t total_bytes_read = 0;
846
847 CompilerType compiler_type = GetCompilerType();
848 CompilerType elem_or_pointee_compiler_type;
849 const Flags type_flags(GetTypeInfo(&elem_or_pointee_compiler_type));
850 if (type_flags.AnySet(eTypeIsArray | eTypeIsPointer) &&
851 elem_or_pointee_compiler_type.IsCharType()) {
852 addr_t cstr_address = LLDB_INVALID_ADDRESS;
853 AddressType cstr_address_type = eAddressTypeInvalid;
854
855 size_t cstr_len = 0;
856 bool capped_data = false;
857 const bool is_array = type_flags.Test(eTypeIsArray);
858 if (is_array) {
859 // We have an array
860 uint64_t array_size = 0;
861 if (compiler_type.IsArrayType(nullptr, &array_size)) {
862 cstr_len = array_size;
863 if (cstr_len > max_length) {
864 capped_data = true;
865 cstr_len = max_length;
866 }
867 }
868 cstr_address = GetAddressOf(true, &cstr_address_type);
869 } else {
870 // We have a pointer
871 cstr_address = GetPointerValue(&cstr_address_type);
872 }
873
874 if (cstr_address == 0 || cstr_address == LLDB_INVALID_ADDRESS) {
875 if (cstr_address_type == eAddressTypeHost && is_array) {
876 const char *cstr = GetDataExtractor().PeekCStr(0);
877 if (cstr == nullptr) {
878 s << "<invalid address>";
879 error.SetErrorString("invalid address");
880 CopyStringDataToBufferSP(s, buffer_sp);
881 return {0, was_capped};
882 }
883 s << llvm::StringRef(cstr, cstr_len);
884 CopyStringDataToBufferSP(s, buffer_sp);
885 return {cstr_len, was_capped};
886 } else {
887 s << "<invalid address>";
888 error.SetErrorString("invalid address");
889 CopyStringDataToBufferSP(s, buffer_sp);
890 return {0, was_capped};
891 }
892 }
893
894 Address cstr_so_addr(cstr_address);
895 DataExtractor data;
896 if (cstr_len > 0 && honor_array) {
897 // I am using GetPointeeData() here to abstract the fact that some
898 // ValueObjects are actually frozen pointers in the host but the pointed-
899 // to data lives in the debuggee, and GetPointeeData() automatically
900 // takes care of this
901 GetPointeeData(data, 0, cstr_len);
902
903 if ((bytes_read = data.GetByteSize()) > 0) {
904 total_bytes_read = bytes_read;
905 for (size_t offset = 0; offset < bytes_read; offset++)
906 s.Printf("%c", *data.PeekData(offset, 1));
907 if (capped_data)
908 was_capped = true;
909 }
910 } else {
911 cstr_len = max_length;
912 const size_t k_max_buf_size = 64;
913
914 size_t offset = 0;
915
916 int cstr_len_displayed = -1;
917 bool capped_cstr = false;
918 // I am using GetPointeeData() here to abstract the fact that some
919 // ValueObjects are actually frozen pointers in the host but the pointed-
920 // to data lives in the debuggee, and GetPointeeData() automatically
921 // takes care of this
922 while ((bytes_read = GetPointeeData(data, offset, k_max_buf_size)) > 0) {
923 total_bytes_read += bytes_read;
924 const char *cstr = data.PeekCStr(0);
925 size_t len = strnlen(cstr, k_max_buf_size);
926 if (cstr_len_displayed < 0)
927 cstr_len_displayed = len;
928
929 if (len == 0)
930 break;
931 cstr_len_displayed += len;
932 if (len > bytes_read)
933 len = bytes_read;
934 if (len > cstr_len)
935 len = cstr_len;
936
937 for (size_t offset = 0; offset < bytes_read; offset++)
938 s.Printf("%c", *data.PeekData(offset, 1));
939
940 if (len < k_max_buf_size)
941 break;
942
943 if (len >= cstr_len) {
944 capped_cstr = true;
945 break;
946 }
947
948 cstr_len -= len;
949 offset += len;
950 }
951
952 if (cstr_len_displayed >= 0) {
953 if (capped_cstr)
954 was_capped = true;
955 }
956 }
957 } else {
958 error.SetErrorString("not a string object");
959 s << "<not a string object>";
960 }
961 CopyStringDataToBufferSP(s, buffer_sp);
962 return {total_bytes_read, was_capped};
963}
964
966 if (!UpdateValueIfNeeded(true))
967 return nullptr;
968
969 // Return cached value.
970 if (!m_object_desc_str.empty())
971 return m_object_desc_str.c_str();
972
974 Process *process = exe_ctx.GetProcessPtr();
975 if (!process)
976 return nullptr;
977
978 // Returns the object description produced by one language runtime.
979 auto get_object_description = [&](LanguageType language) -> const char * {
980 if (LanguageRuntime *runtime = process->GetLanguageRuntime(language)) {
981 StreamString s;
982 if (runtime->GetObjectDescription(s, *this)) {
983 m_object_desc_str.append(std::string(s.GetString()));
984 return m_object_desc_str.c_str();
985 }
986 }
987 return nullptr;
988 };
989
990 // Try the native language runtime first.
991 LanguageType native_language = GetObjectRuntimeLanguage();
992 if (const char *desc = get_object_description(native_language))
993 return desc;
994
995 // Try the Objective-C language runtime. This fallback is necessary
996 // for Objective-C++ and mixed Objective-C / C++ programs.
997 if (Language::LanguageIsCFamily(native_language))
998 return get_object_description(eLanguageTypeObjC);
999 return nullptr;
1000}
1001
1003 std::string &destination) {
1004 if (UpdateValueIfNeeded(false))
1005 return format.FormatObject(this, destination);
1006 else
1007 return false;
1008}
1009
1011 std::string &destination) {
1012 return GetValueAsCString(TypeFormatImpl_Format(format), destination);
1013}
1014
1016 if (UpdateValueIfNeeded(true)) {
1017 lldb::TypeFormatImplSP format_sp;
1018 lldb::Format my_format = GetFormat();
1019 if (my_format == lldb::eFormatDefault) {
1020 if (m_type_format_sp)
1021 format_sp = m_type_format_sp;
1022 else {
1024 my_format = eFormatUnsigned;
1025 else {
1027 const RegisterInfo *reg_info = m_value.GetRegisterInfo();
1028 if (reg_info)
1029 my_format = reg_info->format;
1030 } else {
1031 my_format = GetValue().GetCompilerType().GetFormat();
1032 }
1033 }
1034 }
1035 }
1036 if (my_format != m_last_format || m_value_str.empty()) {
1037 m_last_format = my_format;
1038 if (!format_sp)
1039 format_sp = std::make_shared<TypeFormatImpl_Format>(my_format);
1040 if (GetValueAsCString(*format_sp.get(), m_value_str)) {
1042 // The value was gotten successfully, so we consider the value as
1043 // changed if the value string differs
1045 }
1046 }
1047 }
1048 }
1049 if (m_value_str.empty())
1050 return nullptr;
1051 return m_value_str.c_str();
1052}
1053
1054// if > 8bytes, 0 is returned. this method should mostly be used to read
1055// address values out of pointers
1056uint64_t ValueObject::GetValueAsUnsigned(uint64_t fail_value, bool *success) {
1057 // If our byte size is zero this is an aggregate type that has children
1058 if (CanProvideValue()) {
1059 Scalar scalar;
1060 if (ResolveValue(scalar)) {
1061 if (success)
1062 *success = true;
1063 scalar.MakeUnsigned();
1064 return scalar.ULongLong(fail_value);
1065 }
1066 // fallthrough, otherwise...
1067 }
1068
1069 if (success)
1070 *success = false;
1071 return fail_value;
1072}
1073
1074int64_t ValueObject::GetValueAsSigned(int64_t fail_value, bool *success) {
1075 // If our byte size is zero this is an aggregate type that has children
1076 if (CanProvideValue()) {
1077 Scalar scalar;
1078 if (ResolveValue(scalar)) {
1079 if (success)
1080 *success = true;
1081 scalar.MakeSigned();
1082 return scalar.SLongLong(fail_value);
1083 }
1084 // fallthrough, otherwise...
1085 }
1086
1087 if (success)
1088 *success = false;
1089 return fail_value;
1090}
1091
1092// if any more "special cases" are added to
1093// ValueObject::DumpPrintableRepresentation() please keep this call up to date
1094// by returning true for your new special cases. We will eventually move to
1095// checking this call result before trying to display special cases
1097 ValueObjectRepresentationStyle val_obj_display, Format custom_format) {
1098 Flags flags(GetTypeInfo());
1099 if (flags.AnySet(eTypeIsArray | eTypeIsPointer) &&
1101 if (IsCStringContainer(true) &&
1102 (custom_format == eFormatCString || custom_format == eFormatCharArray ||
1103 custom_format == eFormatChar || custom_format == eFormatVectorOfChar))
1104 return true;
1105
1106 if (flags.Test(eTypeIsArray)) {
1107 if ((custom_format == eFormatBytes) ||
1108 (custom_format == eFormatBytesWithASCII))
1109 return true;
1110
1111 if ((custom_format == eFormatVectorOfChar) ||
1112 (custom_format == eFormatVectorOfFloat32) ||
1113 (custom_format == eFormatVectorOfFloat64) ||
1114 (custom_format == eFormatVectorOfSInt16) ||
1115 (custom_format == eFormatVectorOfSInt32) ||
1116 (custom_format == eFormatVectorOfSInt64) ||
1117 (custom_format == eFormatVectorOfSInt8) ||
1118 (custom_format == eFormatVectorOfUInt128) ||
1119 (custom_format == eFormatVectorOfUInt16) ||
1120 (custom_format == eFormatVectorOfUInt32) ||
1121 (custom_format == eFormatVectorOfUInt64) ||
1122 (custom_format == eFormatVectorOfUInt8))
1123 return true;
1124 }
1125 }
1126 return false;
1127}
1128
1130 Stream &s, ValueObjectRepresentationStyle val_obj_display,
1131 Format custom_format, PrintableRepresentationSpecialCases special,
1132 bool do_dump_error) {
1133
1134 // If the ValueObject has an error, we might end up dumping the type, which
1135 // is useful, but if we don't even have a type, then don't examine the object
1136 // further as that's not meaningful, only the error is.
1137 if (m_error.Fail() && !GetCompilerType().IsValid()) {
1138 if (do_dump_error)
1139 s.Printf("<%s>", m_error.AsCString());
1140 return false;
1141 }
1142
1143 Flags flags(GetTypeInfo());
1144
1145 bool allow_special =
1147 const bool only_special = false;
1148
1149 if (allow_special) {
1150 if (flags.AnySet(eTypeIsArray | eTypeIsPointer) &&
1152 // when being asked to get a printable display an array or pointer type
1153 // directly, try to "do the right thing"
1154
1155 if (IsCStringContainer(true) &&
1156 (custom_format == eFormatCString ||
1157 custom_format == eFormatCharArray || custom_format == eFormatChar ||
1158 custom_format ==
1159 eFormatVectorOfChar)) // print char[] & char* directly
1160 {
1161 Status error;
1163 std::pair<size_t, bool> read_string =
1164 ReadPointedString(buffer_sp, error,
1165 (custom_format == eFormatVectorOfChar) ||
1166 (custom_format == eFormatCharArray));
1167 lldb_private::formatters::StringPrinter::
1168 ReadBufferAndDumpToStreamOptions options(*this);
1169 options.SetData(DataExtractor(
1170 buffer_sp, lldb::eByteOrderInvalid,
1171 8)); // none of this matters for a string - pass some defaults
1172 options.SetStream(&s);
1173 options.SetPrefixToken(nullptr);
1174 options.SetQuote('"');
1175 options.SetSourceSize(buffer_sp->GetByteSize());
1176 options.SetIsTruncated(read_string.second);
1177 options.SetBinaryZeroIsTerminator(custom_format != eFormatVectorOfChar);
1179 lldb_private::formatters::StringPrinter::StringElementType::ASCII>(
1180 options);
1181 return !error.Fail();
1182 }
1183
1184 if (custom_format == eFormatEnum)
1185 return false;
1186
1187 // this only works for arrays, because I have no way to know when the
1188 // pointed memory ends, and no special \0 end of data marker
1189 if (flags.Test(eTypeIsArray)) {
1190 if ((custom_format == eFormatBytes) ||
1191 (custom_format == eFormatBytesWithASCII)) {
1192 const size_t count = GetNumChildrenIgnoringErrors();
1193
1194 s << '[';
1195 for (size_t low = 0; low < count; low++) {
1196
1197 if (low)
1198 s << ',';
1199
1200 ValueObjectSP child = GetChildAtIndex(low);
1201 if (!child.get()) {
1202 s << "<invalid child>";
1203 continue;
1204 }
1205 child->DumpPrintableRepresentation(
1207 custom_format);
1208 }
1209
1210 s << ']';
1211
1212 return true;
1213 }
1214
1215 if ((custom_format == eFormatVectorOfChar) ||
1216 (custom_format == eFormatVectorOfFloat32) ||
1217 (custom_format == eFormatVectorOfFloat64) ||
1218 (custom_format == eFormatVectorOfSInt16) ||
1219 (custom_format == eFormatVectorOfSInt32) ||
1220 (custom_format == eFormatVectorOfSInt64) ||
1221 (custom_format == eFormatVectorOfSInt8) ||
1222 (custom_format == eFormatVectorOfUInt128) ||
1223 (custom_format == eFormatVectorOfUInt16) ||
1224 (custom_format == eFormatVectorOfUInt32) ||
1225 (custom_format == eFormatVectorOfUInt64) ||
1226 (custom_format == eFormatVectorOfUInt8)) // arrays of bytes, bytes
1227 // with ASCII or any vector
1228 // format should be printed
1229 // directly
1230 {
1231 const size_t count = GetNumChildrenIgnoringErrors();
1232
1233 Format format = FormatManager::GetSingleItemFormat(custom_format);
1234
1235 s << '[';
1236 for (size_t low = 0; low < count; low++) {
1237
1238 if (low)
1239 s << ',';
1240
1241 ValueObjectSP child = GetChildAtIndex(low);
1242 if (!child.get()) {
1243 s << "<invalid child>";
1244 continue;
1245 }
1246 child->DumpPrintableRepresentation(
1248 }
1249
1250 s << ']';
1251
1252 return true;
1253 }
1254 }
1255
1256 if ((custom_format == eFormatBoolean) ||
1257 (custom_format == eFormatBinary) || (custom_format == eFormatChar) ||
1258 (custom_format == eFormatCharPrintable) ||
1259 (custom_format == eFormatComplexFloat) ||
1260 (custom_format == eFormatDecimal) || (custom_format == eFormatHex) ||
1261 (custom_format == eFormatHexUppercase) ||
1262 (custom_format == eFormatFloat) || (custom_format == eFormatOctal) ||
1263 (custom_format == eFormatOSType) ||
1264 (custom_format == eFormatUnicode16) ||
1265 (custom_format == eFormatUnicode32) ||
1266 (custom_format == eFormatUnsigned) ||
1267 (custom_format == eFormatPointer) ||
1268 (custom_format == eFormatComplexInteger) ||
1269 (custom_format == eFormatComplex) ||
1270 (custom_format == eFormatDefault)) // use the [] operator
1271 return false;
1272 }
1273 }
1274
1275 if (only_special)
1276 return false;
1277
1278 bool var_success = false;
1279
1280 {
1281 llvm::StringRef str;
1282
1283 // this is a local stream that we are using to ensure that the data pointed
1284 // to by cstr survives long enough for us to copy it to its destination -
1285 // it is necessary to have this temporary storage area for cases where our
1286 // desired output is not backed by some other longer-term storage
1287 StreamString strm;
1288
1289 if (custom_format != eFormatInvalid)
1290 SetFormat(custom_format);
1291
1292 switch (val_obj_display) {
1294 str = GetValueAsCString();
1295 break;
1296
1298 str = GetSummaryAsCString();
1299 break;
1300
1302 str = GetObjectDescription();
1303 break;
1304
1306 str = GetLocationAsCString();
1307 break;
1308
1310 strm.Printf("%" PRIu64 "", (uint64_t)GetNumChildrenIgnoringErrors());
1311 str = strm.GetString();
1312 break;
1313
1315 str = GetTypeName().GetStringRef();
1316 break;
1317
1319 str = GetName().GetStringRef();
1320 break;
1321
1323 GetExpressionPath(strm);
1324 str = strm.GetString();
1325 break;
1326 }
1327
1328 // If the requested display style produced no output, try falling back to
1329 // alternative presentations.
1330 if (str.empty()) {
1331 if (val_obj_display == eValueObjectRepresentationStyleValue)
1332 str = GetSummaryAsCString();
1333 else if (val_obj_display == eValueObjectRepresentationStyleSummary) {
1334 if (!CanProvideValue()) {
1335 strm.Printf("%s @ %s", GetTypeName().AsCString(),
1337 str = strm.GetString();
1338 } else
1339 str = GetValueAsCString();
1340 }
1341 }
1342
1343 if (!str.empty())
1344 s << str;
1345 else {
1346 // We checked for errors at the start, but do it again here in case
1347 // realizing the value for dumping produced an error.
1348 if (m_error.Fail()) {
1349 if (do_dump_error)
1350 s.Printf("<%s>", m_error.AsCString());
1351 else
1352 return false;
1353 } else if (val_obj_display == eValueObjectRepresentationStyleSummary)
1354 s.PutCString("<no summary available>");
1355 else if (val_obj_display == eValueObjectRepresentationStyleValue)
1356 s.PutCString("<no value available>");
1357 else if (val_obj_display ==
1359 s.PutCString("<not a valid Objective-C object>"); // edit this if we
1360 // have other runtimes
1361 // that support a
1362 // description
1363 else
1364 s.PutCString("<no printable representation>");
1365 }
1366
1367 // we should only return false here if we could not do *anything* even if
1368 // we have an error message as output, that's a success from our callers'
1369 // perspective, so return true
1370 var_success = true;
1371
1372 if (custom_format != eFormatInvalid)
1374 }
1375
1376 return var_success;
1377}
1378
1379addr_t ValueObject::GetAddressOf(bool scalar_is_load_address,
1380 AddressType *address_type) {
1381 // Can't take address of a bitfield
1382 if (IsBitfield())
1383 return LLDB_INVALID_ADDRESS;
1384
1385 if (!UpdateValueIfNeeded(false))
1386 return LLDB_INVALID_ADDRESS;
1387
1388 switch (m_value.GetValueType()) {
1390 return LLDB_INVALID_ADDRESS;
1392 if (scalar_is_load_address) {
1393 if (address_type)
1394 *address_type = eAddressTypeLoad;
1396 }
1397 break;
1398
1401 if (address_type)
1402 *address_type = m_value.GetValueAddressType();
1404 } break;
1406 if (address_type)
1407 *address_type = m_value.GetValueAddressType();
1408 return LLDB_INVALID_ADDRESS;
1409 } break;
1410 }
1411 if (address_type)
1412 *address_type = eAddressTypeInvalid;
1413 return LLDB_INVALID_ADDRESS;
1414}
1415
1417 addr_t address = LLDB_INVALID_ADDRESS;
1418 if (address_type)
1419 *address_type = eAddressTypeInvalid;
1420
1421 if (!UpdateValueIfNeeded(false))
1422 return address;
1423
1424 switch (m_value.GetValueType()) {
1426 return LLDB_INVALID_ADDRESS;
1429 break;
1430
1434 lldb::offset_t data_offset = 0;
1435 address = m_data.GetAddress(&data_offset);
1436 } break;
1437 }
1438
1439 if (address_type)
1440 *address_type = GetAddressTypeOfChildren();
1441
1442 return address;
1443}
1444
1445bool ValueObject::SetValueFromCString(const char *value_str, Status &error) {
1446 error.Clear();
1447 // Make sure our value is up to date first so that our location and location
1448 // type is valid.
1449 if (!UpdateValueIfNeeded(false)) {
1450 error.SetErrorString("unable to read value");
1451 return false;
1452 }
1453
1454 uint64_t count = 0;
1455 const Encoding encoding = GetCompilerType().GetEncoding(count);
1456
1457 const size_t byte_size = GetByteSize().value_or(0);
1458
1459 Value::ValueType value_type = m_value.GetValueType();
1460
1461 if (value_type == Value::ValueType::Scalar) {
1462 // If the value is already a scalar, then let the scalar change itself:
1463 m_value.GetScalar().SetValueFromCString(value_str, encoding, byte_size);
1464 } else if (byte_size <= 16) {
1465 // If the value fits in a scalar, then make a new scalar and again let the
1466 // scalar code do the conversion, then figure out where to put the new
1467 // value.
1468 Scalar new_scalar;
1469 error = new_scalar.SetValueFromCString(value_str, encoding, byte_size);
1470 if (error.Success()) {
1471 switch (value_type) {
1473 // If it is a load address, then the scalar value is the storage
1474 // location of the data, and we have to shove this value down to that
1475 // load location.
1477 Process *process = exe_ctx.GetProcessPtr();
1478 if (process) {
1479 addr_t target_addr =
1481 size_t bytes_written = process->WriteScalarToMemory(
1482 target_addr, new_scalar, byte_size, error);
1483 if (!error.Success())
1484 return false;
1485 if (bytes_written != byte_size) {
1486 error.SetErrorString("unable to write value to memory");
1487 return false;
1488 }
1489 }
1490 } break;
1492 // If it is a host address, then we stuff the scalar as a DataBuffer
1493 // into the Value's data.
1494 DataExtractor new_data;
1495 new_data.SetByteOrder(m_data.GetByteOrder());
1496
1497 DataBufferSP buffer_sp(new DataBufferHeap(byte_size, 0));
1498 m_data.SetData(buffer_sp, 0);
1499 bool success = new_scalar.GetData(new_data);
1500 if (success) {
1501 new_data.CopyByteOrderedData(
1502 0, byte_size, const_cast<uint8_t *>(m_data.GetDataStart()),
1503 byte_size, m_data.GetByteOrder());
1504 }
1505 m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
1506
1507 } break;
1509 error.SetErrorString("invalid location");
1510 return false;
1513 break;
1514 }
1515 } else {
1516 return false;
1517 }
1518 } else {
1519 // We don't support setting things bigger than a scalar at present.
1520 error.SetErrorString("unable to write aggregate data type");
1521 return false;
1522 }
1523
1524 // If we have reached this point, then we have successfully changed the
1525 // value.
1527 return true;
1528}
1529
1531 decl.Clear();
1532 return false;
1533}
1534
1536 ValueObject *valobj) {
1537 m_synthetic_children[key] = valobj;
1538}
1539
1541 ValueObjectSP synthetic_child_sp;
1542 std::map<ConstString, ValueObject *>::const_iterator pos =
1543 m_synthetic_children.find(key);
1544 if (pos != m_synthetic_children.end())
1545 synthetic_child_sp = pos->second->GetSP();
1546 return synthetic_child_sp;
1547}
1548
1551 Process *process = exe_ctx.GetProcessPtr();
1552 if (process)
1553 return process->IsPossibleDynamicValue(*this);
1554 else
1555 return GetCompilerType().IsPossibleDynamicType(nullptr, true, true);
1556}
1557
1559 Process *process(GetProcessSP().get());
1560 if (!process)
1561 return false;
1562
1563 // We trust that the compiler did the right thing and marked runtime support
1564 // values as artificial.
1565 if (!GetVariable() || !GetVariable()->IsArtificial())
1566 return false;
1567
1568 if (auto *runtime = process->GetLanguageRuntime(GetVariable()->GetLanguage()))
1569 if (runtime->IsAllowedRuntimeValue(GetName()))
1570 return false;
1571
1572 return true;
1573}
1574
1577 return language->IsNilReference(*this);
1578 }
1579 return false;
1580}
1581
1584 return language->IsUninitializedReference(*this);
1585 }
1586 return false;
1587}
1588
1589// This allows you to create an array member using and index that doesn't not
1590// fall in the normal bounds of the array. Many times structure can be defined
1591// as: struct Collection {
1592// uint32_t item_count;
1593// Item item_array[0];
1594// };
1595// The size of the "item_array" is 1, but many times in practice there are more
1596// items in "item_array".
1597
1599 bool can_create) {
1600 ValueObjectSP synthetic_child_sp;
1601 if (IsPointerType() || IsArrayType()) {
1602 std::string index_str = llvm::formatv("[{0}]", index);
1603 ConstString index_const_str(index_str);
1604 // Check if we have already created a synthetic array member in this valid
1605 // object. If we have we will re-use it.
1606 synthetic_child_sp = GetSyntheticChild(index_const_str);
1607 if (!synthetic_child_sp) {
1608 ValueObject *synthetic_child;
1609 // We haven't made a synthetic array member for INDEX yet, so lets make
1610 // one and cache it for any future reference.
1611 synthetic_child = CreateChildAtIndex(0, true, index);
1612
1613 // Cache the value if we got one back...
1614 if (synthetic_child) {
1615 AddSyntheticChild(index_const_str, synthetic_child);
1616 synthetic_child_sp = synthetic_child->GetSP();
1617 synthetic_child_sp->SetName(ConstString(index_str));
1618 synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
1619 }
1620 }
1621 }
1622 return synthetic_child_sp;
1623}
1624
1626 bool can_create) {
1627 ValueObjectSP synthetic_child_sp;
1628 if (IsScalarType()) {
1629 std::string index_str = llvm::formatv("[{0}-{1}]", from, to);
1630 ConstString index_const_str(index_str);
1631 // Check if we have already created a synthetic array member in this valid
1632 // object. If we have we will re-use it.
1633 synthetic_child_sp = GetSyntheticChild(index_const_str);
1634 if (!synthetic_child_sp) {
1635 uint32_t bit_field_size = to - from + 1;
1636 uint32_t bit_field_offset = from;
1637 if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
1638 bit_field_offset =
1639 GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
1640 // We haven't made a synthetic array member for INDEX yet, so lets make
1641 // one and cache it for any future reference.
1642 ValueObjectChild *synthetic_child = new ValueObjectChild(
1643 *this, GetCompilerType(), index_const_str, GetByteSize().value_or(0),
1644 0, bit_field_size, bit_field_offset, false, false,
1646
1647 // Cache the value if we got one back...
1648 if (synthetic_child) {
1649 AddSyntheticChild(index_const_str, synthetic_child);
1650 synthetic_child_sp = synthetic_child->GetSP();
1651 synthetic_child_sp->SetName(ConstString(index_str));
1652 synthetic_child_sp->m_flags.m_is_bitfield_for_scalar = true;
1653 }
1654 }
1655 }
1656 return synthetic_child_sp;
1657}
1658
1660 uint32_t offset, const CompilerType &type, bool can_create,
1661 ConstString name_const_str) {
1662
1663 ValueObjectSP synthetic_child_sp;
1664
1665 if (name_const_str.IsEmpty()) {
1666 name_const_str.SetString("@" + std::to_string(offset));
1667 }
1668
1669 // Check if we have already created a synthetic array member in this valid
1670 // object. If we have we will re-use it.
1671 synthetic_child_sp = GetSyntheticChild(name_const_str);
1672
1673 if (synthetic_child_sp.get())
1674 return synthetic_child_sp;
1675
1676 if (!can_create)
1677 return {};
1678
1680 std::optional<uint64_t> size =
1682 if (!size)
1683 return {};
1684 ValueObjectChild *synthetic_child =
1685 new ValueObjectChild(*this, type, name_const_str, *size, offset, 0, 0,
1686 false, false, eAddressTypeInvalid, 0);
1687 if (synthetic_child) {
1688 AddSyntheticChild(name_const_str, synthetic_child);
1689 synthetic_child_sp = synthetic_child->GetSP();
1690 synthetic_child_sp->SetName(name_const_str);
1691 synthetic_child_sp->m_flags.m_is_child_at_offset = true;
1692 }
1693 return synthetic_child_sp;
1694}
1695
1697 const CompilerType &type,
1698 bool can_create,
1699 ConstString name_const_str) {
1700 ValueObjectSP synthetic_child_sp;
1701
1702 if (name_const_str.IsEmpty()) {
1703 char name_str[128];
1704 snprintf(name_str, sizeof(name_str), "base%s@%i",
1705 type.GetTypeName().AsCString("<unknown>"), offset);
1706 name_const_str.SetCString(name_str);
1707 }
1708
1709 // Check if we have already created a synthetic array member in this valid
1710 // object. If we have we will re-use it.
1711 synthetic_child_sp = GetSyntheticChild(name_const_str);
1712
1713 if (synthetic_child_sp.get())
1714 return synthetic_child_sp;
1715
1716 if (!can_create)
1717 return {};
1718
1719 const bool is_base_class = true;
1720
1722 std::optional<uint64_t> size =
1724 if (!size)
1725 return {};
1726 ValueObjectChild *synthetic_child =
1727 new ValueObjectChild(*this, type, name_const_str, *size, offset, 0, 0,
1728 is_base_class, false, eAddressTypeInvalid, 0);
1729 if (synthetic_child) {
1730 AddSyntheticChild(name_const_str, synthetic_child);
1731 synthetic_child_sp = synthetic_child->GetSP();
1732 synthetic_child_sp->SetName(name_const_str);
1733 }
1734 return synthetic_child_sp;
1735}
1736
1737// your expression path needs to have a leading . or -> (unless it somehow
1738// "looks like" an array, in which case it has a leading [ symbol). while the [
1739// is meaningful and should be shown to the user, . and -> are just parser
1740// design, but by no means added information for the user.. strip them off
1741static const char *SkipLeadingExpressionPathSeparators(const char *expression) {
1742 if (!expression || !expression[0])
1743 return expression;
1744 if (expression[0] == '.')
1745 return expression + 1;
1746 if (expression[0] == '-' && expression[1] == '>')
1747 return expression + 2;
1748 return expression;
1749}
1750
1753 bool can_create) {
1754 ValueObjectSP synthetic_child_sp;
1755 ConstString name_const_string(expression);
1756 // Check if we have already created a synthetic array member in this valid
1757 // object. If we have we will re-use it.
1758 synthetic_child_sp = GetSyntheticChild(name_const_string);
1759 if (!synthetic_child_sp) {
1760 // We haven't made a synthetic array member for expression yet, so lets
1761 // make one and cache it for any future reference.
1762 synthetic_child_sp = GetValueForExpressionPath(
1763 expression, nullptr, nullptr,
1764 GetValueForExpressionPathOptions().SetSyntheticChildrenTraversal(
1766 None));
1767
1768 // Cache the value if we got one back...
1769 if (synthetic_child_sp.get()) {
1770 // FIXME: this causes a "real" child to end up with its name changed to
1771 // the contents of expression
1772 AddSyntheticChild(name_const_string, synthetic_child_sp.get());
1773 synthetic_child_sp->SetName(
1775 }
1776 }
1777 return synthetic_child_sp;
1778}
1779
1781 TargetSP target_sp(GetTargetSP());
1782 if (target_sp && !target_sp->GetEnableSyntheticValue()) {
1783 m_synthetic_value = nullptr;
1784 return;
1785 }
1786
1788
1790 return;
1791
1792 if (m_synthetic_children_sp.get() == nullptr)
1793 return;
1794
1795 if (current_synth_sp == m_synthetic_children_sp && m_synthetic_value)
1796 return;
1797
1799}
1800
1802 if (use_dynamic == eNoDynamicValues)
1803 return;
1804
1805 if (!m_dynamic_value && !IsDynamic()) {
1807 Process *process = exe_ctx.GetProcessPtr();
1808 if (process && process->IsPossibleDynamicValue(*this)) {
1810 m_dynamic_value = new ValueObjectDynamicValue(*this, use_dynamic);
1811 }
1812 }
1813}
1814
1816 if (use_dynamic == eNoDynamicValues)
1817 return ValueObjectSP();
1818
1819 if (!IsDynamic() && m_dynamic_value == nullptr) {
1820 CalculateDynamicValue(use_dynamic);
1821 }
1823 return m_dynamic_value->GetSP();
1824 else
1825 return ValueObjectSP();
1826}
1827
1830
1832 return m_synthetic_value->GetSP();
1833 else
1834 return ValueObjectSP();
1835}
1836
1839
1840 if (m_synthetic_children_sp.get() == nullptr)
1841 return false;
1842
1844
1845 return m_synthetic_value != nullptr;
1846}
1847
1849 if (GetParent()) {
1850 if (GetParent()->IsBaseClass())
1851 return GetParent()->GetNonBaseClassParent();
1852 else
1853 return GetParent();
1854 }
1855 return nullptr;
1856}
1857
1858bool ValueObject::IsBaseClass(uint32_t &depth) {
1859 if (!IsBaseClass()) {
1860 depth = 0;
1861 return false;
1862 }
1863 if (GetParent()) {
1864 GetParent()->IsBaseClass(depth);
1865 depth = depth + 1;
1866 return true;
1867 }
1868 // TODO: a base of no parent? weird..
1869 depth = 1;
1870 return true;
1871}
1872
1874 GetExpressionPathFormat epformat) {
1875 // synthetic children do not actually "exist" as part of the hierarchy, and
1876 // sometimes they are consed up in ways that don't make sense from an
1877 // underlying language/API standpoint. So, use a special code path here to
1878 // return something that can hopefully be used in expression
1881
1884 s.Printf("((%s)0x%" PRIx64 ")", GetTypeName().AsCString("void"),
1886 return;
1887 } else {
1888 uint64_t load_addr =
1890 if (load_addr != LLDB_INVALID_ADDRESS) {
1891 s.Printf("(*( (%s *)0x%" PRIx64 "))", GetTypeName().AsCString("void"),
1892 load_addr);
1893 return;
1894 }
1895 }
1896 }
1897
1898 if (CanProvideValue()) {
1899 s.Printf("((%s)%s)", GetTypeName().AsCString("void"),
1901 return;
1902 }
1903
1904 return;
1905 }
1906
1907 const bool is_deref_of_parent = IsDereferenceOfParent();
1908
1909 if (is_deref_of_parent &&
1911 // this is the original format of GetExpressionPath() producing code like
1912 // *(a_ptr).memberName, which is entirely fine, until you put this into
1913 // StackFrame::GetValueForVariableExpressionPath() which prefers to see
1914 // a_ptr->memberName. the eHonorPointers mode is meant to produce strings
1915 // in this latter format
1916 s.PutCString("*(");
1917 }
1918
1919 ValueObject *parent = GetParent();
1920
1921 if (parent)
1922 parent->GetExpressionPath(s, epformat);
1923
1924 // if we are a deref_of_parent just because we are synthetic array members
1925 // made up to allow ptr[%d] syntax to work in variable printing, then add our
1926 // name ([%d]) to the expression path
1930
1931 if (!IsBaseClass()) {
1932 if (!is_deref_of_parent) {
1933 ValueObject *non_base_class_parent = GetNonBaseClassParent();
1934 if (non_base_class_parent &&
1935 !non_base_class_parent->GetName().IsEmpty()) {
1936 CompilerType non_base_class_parent_compiler_type =
1937 non_base_class_parent->GetCompilerType();
1938 if (non_base_class_parent_compiler_type) {
1939 if (parent && parent->IsDereferenceOfParent() &&
1941 s.PutCString("->");
1942 } else {
1943 const uint32_t non_base_class_parent_type_info =
1944 non_base_class_parent_compiler_type.GetTypeInfo();
1945
1946 if (non_base_class_parent_type_info & eTypeIsPointer) {
1947 s.PutCString("->");
1948 } else if ((non_base_class_parent_type_info & eTypeHasChildren) &&
1949 !(non_base_class_parent_type_info & eTypeIsArray)) {
1950 s.PutChar('.');
1951 }
1952 }
1953 }
1954 }
1955
1956 const char *name = GetName().GetCString();
1957 if (name)
1958 s.PutCString(name);
1959 }
1960 }
1961
1962 if (is_deref_of_parent &&
1964 s.PutChar(')');
1965 }
1966}
1967
1969 llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop,
1970 ExpressionPathEndResultType *final_value_type,
1971 const GetValueForExpressionPathOptions &options,
1972 ExpressionPathAftermath *final_task_on_target) {
1973
1974 ExpressionPathScanEndReason dummy_reason_to_stop =
1976 ExpressionPathEndResultType dummy_final_value_type =
1978 ExpressionPathAftermath dummy_final_task_on_target =
1980
1982 expression, reason_to_stop ? reason_to_stop : &dummy_reason_to_stop,
1983 final_value_type ? final_value_type : &dummy_final_value_type, options,
1984 final_task_on_target ? final_task_on_target
1985 : &dummy_final_task_on_target);
1986
1987 if (!final_task_on_target ||
1988 *final_task_on_target == ValueObject::eExpressionPathAftermathNothing)
1989 return ret_val;
1990
1991 if (ret_val.get() &&
1992 ((final_value_type ? *final_value_type : dummy_final_value_type) ==
1993 eExpressionPathEndResultTypePlain)) // I can only deref and takeaddress
1994 // of plain objects
1995 {
1996 if ((final_task_on_target ? *final_task_on_target
1997 : dummy_final_task_on_target) ==
1999 Status error;
2000 ValueObjectSP final_value = ret_val->Dereference(error);
2001 if (error.Fail() || !final_value.get()) {
2002 if (reason_to_stop)
2003 *reason_to_stop =
2005 if (final_value_type)
2007 return ValueObjectSP();
2008 } else {
2009 if (final_task_on_target)
2010 *final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
2011 return final_value;
2012 }
2013 }
2014 if (*final_task_on_target ==
2016 Status error;
2017 ValueObjectSP final_value = ret_val->AddressOf(error);
2018 if (error.Fail() || !final_value.get()) {
2019 if (reason_to_stop)
2020 *reason_to_stop =
2022 if (final_value_type)
2024 return ValueObjectSP();
2025 } else {
2026 if (final_task_on_target)
2027 *final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
2028 return final_value;
2029 }
2030 }
2031 }
2032 return ret_val; // final_task_on_target will still have its original value, so
2033 // you know I did not do it
2034}
2035
2037 llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop,
2038 ExpressionPathEndResultType *final_result,
2039 const GetValueForExpressionPathOptions &options,
2040 ExpressionPathAftermath *what_next) {
2041 ValueObjectSP root = GetSP();
2042
2043 if (!root)
2044 return nullptr;
2045
2046 llvm::StringRef remainder = expression;
2047
2048 while (true) {
2049 llvm::StringRef temp_expression = remainder;
2050
2051 CompilerType root_compiler_type = root->GetCompilerType();
2052 CompilerType pointee_compiler_type;
2053 Flags pointee_compiler_type_info;
2054
2055 Flags root_compiler_type_info(
2056 root_compiler_type.GetTypeInfo(&pointee_compiler_type));
2057 if (pointee_compiler_type)
2058 pointee_compiler_type_info.Reset(pointee_compiler_type.GetTypeInfo());
2059
2060 if (temp_expression.empty()) {
2062 return root;
2063 }
2064
2065 switch (temp_expression.front()) {
2066 case '-': {
2067 temp_expression = temp_expression.drop_front();
2068 if (options.m_check_dot_vs_arrow_syntax &&
2069 root_compiler_type_info.Test(eTypeIsPointer)) // if you are trying to
2070 // use -> on a
2071 // non-pointer and I
2072 // must catch the error
2073 {
2074 *reason_to_stop =
2077 return ValueObjectSP();
2078 }
2079 if (root_compiler_type_info.Test(eTypeIsObjC) && // if yo are trying to
2080 // extract an ObjC IVar
2081 // when this is forbidden
2082 root_compiler_type_info.Test(eTypeIsPointer) &&
2083 options.m_no_fragile_ivar) {
2084 *reason_to_stop =
2087 return ValueObjectSP();
2088 }
2089 if (!temp_expression.starts_with(">")) {
2090 *reason_to_stop =
2093 return ValueObjectSP();
2094 }
2095 }
2096 [[fallthrough]];
2097 case '.': // or fallthrough from ->
2098 {
2099 if (options.m_check_dot_vs_arrow_syntax &&
2100 temp_expression.front() == '.' &&
2101 root_compiler_type_info.Test(eTypeIsPointer)) // if you are trying to
2102 // use . on a pointer
2103 // and I must catch the
2104 // error
2105 {
2106 *reason_to_stop =
2109 return nullptr;
2110 }
2111 temp_expression = temp_expression.drop_front(); // skip . or >
2112
2113 size_t next_sep_pos = temp_expression.find_first_of("-.[", 1);
2114 if (next_sep_pos == llvm::StringRef::npos) // if no other separator just
2115 // expand this last layer
2116 {
2117 llvm::StringRef child_name = temp_expression;
2118 ValueObjectSP child_valobj_sp =
2119 root->GetChildMemberWithName(child_name);
2120
2121 if (child_valobj_sp.get()) // we know we are done, so just return
2122 {
2123 *reason_to_stop =
2126 return child_valobj_sp;
2127 } else {
2128 switch (options.m_synthetic_children_traversal) {
2130 None:
2131 break;
2134 if (root->IsSynthetic()) {
2135 child_valobj_sp = root->GetNonSyntheticValue();
2136 if (child_valobj_sp.get())
2137 child_valobj_sp =
2138 child_valobj_sp->GetChildMemberWithName(child_name);
2139 }
2140 break;
2143 if (!root->IsSynthetic()) {
2144 child_valobj_sp = root->GetSyntheticValue();
2145 if (child_valobj_sp.get())
2146 child_valobj_sp =
2147 child_valobj_sp->GetChildMemberWithName(child_name);
2148 }
2149 break;
2151 Both:
2152 if (root->IsSynthetic()) {
2153 child_valobj_sp = root->GetNonSyntheticValue();
2154 if (child_valobj_sp.get())
2155 child_valobj_sp =
2156 child_valobj_sp->GetChildMemberWithName(child_name);
2157 } else {
2158 child_valobj_sp = root->GetSyntheticValue();
2159 if (child_valobj_sp.get())
2160 child_valobj_sp =
2161 child_valobj_sp->GetChildMemberWithName(child_name);
2162 }
2163 break;
2164 }
2165 }
2166
2167 // if we are here and options.m_no_synthetic_children is true,
2168 // child_valobj_sp is going to be a NULL SP, so we hit the "else"
2169 // branch, and return an error
2170 if (child_valobj_sp.get()) // if it worked, just return
2171 {
2172 *reason_to_stop =
2175 return child_valobj_sp;
2176 } else {
2177 *reason_to_stop =
2180 return nullptr;
2181 }
2182 } else // other layers do expand
2183 {
2184 llvm::StringRef next_separator = temp_expression.substr(next_sep_pos);
2185 llvm::StringRef child_name = temp_expression.slice(0, next_sep_pos);
2186
2187 ValueObjectSP child_valobj_sp =
2188 root->GetChildMemberWithName(child_name);
2189 if (child_valobj_sp.get()) // store the new root and move on
2190 {
2191 root = child_valobj_sp;
2192 remainder = next_separator;
2194 continue;
2195 } else {
2196 switch (options.m_synthetic_children_traversal) {
2198 None:
2199 break;
2202 if (root->IsSynthetic()) {
2203 child_valobj_sp = root->GetNonSyntheticValue();
2204 if (child_valobj_sp.get())
2205 child_valobj_sp =
2206 child_valobj_sp->GetChildMemberWithName(child_name);
2207 }
2208 break;
2211 if (!root->IsSynthetic()) {
2212 child_valobj_sp = root->GetSyntheticValue();
2213 if (child_valobj_sp.get())
2214 child_valobj_sp =
2215 child_valobj_sp->GetChildMemberWithName(child_name);
2216 }
2217 break;
2219 Both:
2220 if (root->IsSynthetic()) {
2221 child_valobj_sp = root->GetNonSyntheticValue();
2222 if (child_valobj_sp.get())
2223 child_valobj_sp =
2224 child_valobj_sp->GetChildMemberWithName(child_name);
2225 } else {
2226 child_valobj_sp = root->GetSyntheticValue();
2227 if (child_valobj_sp.get())
2228 child_valobj_sp =
2229 child_valobj_sp->GetChildMemberWithName(child_name);
2230 }
2231 break;
2232 }
2233 }
2234
2235 // if we are here and options.m_no_synthetic_children is true,
2236 // child_valobj_sp is going to be a NULL SP, so we hit the "else"
2237 // branch, and return an error
2238 if (child_valobj_sp.get()) // if it worked, move on
2239 {
2240 root = child_valobj_sp;
2241 remainder = next_separator;
2243 continue;
2244 } else {
2245 *reason_to_stop =
2248 return nullptr;
2249 }
2250 }
2251 break;
2252 }
2253 case '[': {
2254 if (!root_compiler_type_info.Test(eTypeIsArray) &&
2255 !root_compiler_type_info.Test(eTypeIsPointer) &&
2256 !root_compiler_type_info.Test(
2257 eTypeIsVector)) // if this is not a T[] nor a T*
2258 {
2259 if (!root_compiler_type_info.Test(
2260 eTypeIsScalar)) // if this is not even a scalar...
2261 {
2262 if (options.m_synthetic_children_traversal ==
2264 None) // ...only chance left is synthetic
2265 {
2266 *reason_to_stop =
2269 return ValueObjectSP();
2270 }
2271 } else if (!options.m_allow_bitfields_syntax) // if this is a scalar,
2272 // check that we can
2273 // expand bitfields
2274 {
2275 *reason_to_stop =
2278 return ValueObjectSP();
2279 }
2280 }
2281 if (temp_expression[1] ==
2282 ']') // if this is an unbounded range it only works for arrays
2283 {
2284 if (!root_compiler_type_info.Test(eTypeIsArray)) {
2285 *reason_to_stop =
2288 return nullptr;
2289 } else // even if something follows, we cannot expand unbounded ranges,
2290 // just let the caller do it
2291 {
2292 *reason_to_stop =
2294 *final_result =
2296 return root;
2297 }
2298 }
2299
2300 size_t close_bracket_position = temp_expression.find(']', 1);
2301 if (close_bracket_position ==
2302 llvm::StringRef::npos) // if there is no ], this is a syntax error
2303 {
2304 *reason_to_stop =
2307 return nullptr;
2308 }
2309
2310 llvm::StringRef bracket_expr =
2311 temp_expression.slice(1, close_bracket_position);
2312
2313 // If this was an empty expression it would have been caught by the if
2314 // above.
2315 assert(!bracket_expr.empty());
2316
2317 if (!bracket_expr.contains('-')) {
2318 // if no separator, this is of the form [N]. Note that this cannot be
2319 // an unbounded range of the form [], because that case was handled
2320 // above with an unconditional return.
2321 unsigned long index = 0;
2322 if (bracket_expr.getAsInteger(0, index)) {
2323 *reason_to_stop =
2326 return nullptr;
2327 }
2328
2329 // from here on we do have a valid index
2330 if (root_compiler_type_info.Test(eTypeIsArray)) {
2331 ValueObjectSP child_valobj_sp = root->GetChildAtIndex(index);
2332 if (!child_valobj_sp)
2333 child_valobj_sp = root->GetSyntheticArrayMember(index, true);
2334 if (!child_valobj_sp)
2335 if (root->HasSyntheticValue() &&
2336 llvm::expectedToStdOptional(
2337 root->GetSyntheticValue()->GetNumChildren())
2338 .value_or(0) > index)
2339 child_valobj_sp =
2340 root->GetSyntheticValue()->GetChildAtIndex(index);
2341 if (child_valobj_sp) {
2342 root = child_valobj_sp;
2343 remainder =
2344 temp_expression.substr(close_bracket_position + 1); // skip ]
2346 continue;
2347 } else {
2348 *reason_to_stop =
2351 return nullptr;
2352 }
2353 } else if (root_compiler_type_info.Test(eTypeIsPointer)) {
2354 if (*what_next ==
2355 ValueObject::
2356 eExpressionPathAftermathDereference && // if this is a
2357 // ptr-to-scalar, I
2358 // am accessing it
2359 // by index and I
2360 // would have
2361 // deref'ed anyway,
2362 // then do it now
2363 // and use this as
2364 // a bitfield
2365 pointee_compiler_type_info.Test(eTypeIsScalar)) {
2366 Status error;
2367 root = root->Dereference(error);
2368 if (error.Fail() || !root) {
2369 *reason_to_stop =
2372 return nullptr;
2373 } else {
2375 continue;
2376 }
2377 } else {
2378 if (root->GetCompilerType().GetMinimumLanguage() ==
2380 pointee_compiler_type_info.AllClear(eTypeIsPointer) &&
2381 root->HasSyntheticValue() &&
2384 SyntheticChildrenTraversal::ToSynthetic ||
2387 SyntheticChildrenTraversal::Both)) {
2388 root = root->GetSyntheticValue()->GetChildAtIndex(index);
2389 } else
2390 root = root->GetSyntheticArrayMember(index, true);
2391 if (!root) {
2392 *reason_to_stop =
2395 return nullptr;
2396 } else {
2397 remainder =
2398 temp_expression.substr(close_bracket_position + 1); // skip ]
2400 continue;
2401 }
2402 }
2403 } else if (root_compiler_type_info.Test(eTypeIsScalar)) {
2404 root = root->GetSyntheticBitFieldChild(index, index, true);
2405 if (!root) {
2406 *reason_to_stop =
2409 return nullptr;
2410 } else // we do not know how to expand members of bitfields, so we
2411 // just return and let the caller do any further processing
2412 {
2413 *reason_to_stop = ValueObject::
2416 return root;
2417 }
2418 } else if (root_compiler_type_info.Test(eTypeIsVector)) {
2419 root = root->GetChildAtIndex(index);
2420 if (!root) {
2421 *reason_to_stop =
2424 return ValueObjectSP();
2425 } else {
2426 remainder =
2427 temp_expression.substr(close_bracket_position + 1); // skip ]
2429 continue;
2430 }
2431 } else if (options.m_synthetic_children_traversal ==
2433 SyntheticChildrenTraversal::ToSynthetic ||
2436 SyntheticChildrenTraversal::Both) {
2437 if (root->HasSyntheticValue())
2438 root = root->GetSyntheticValue();
2439 else if (!root->IsSynthetic()) {
2440 *reason_to_stop =
2443 return nullptr;
2444 }
2445 // if we are here, then root itself is a synthetic VO.. should be
2446 // good to go
2447
2448 if (!root) {
2449 *reason_to_stop =
2452 return nullptr;
2453 }
2454 root = root->GetChildAtIndex(index);
2455 if (!root) {
2456 *reason_to_stop =
2459 return nullptr;
2460 } else {
2461 remainder =
2462 temp_expression.substr(close_bracket_position + 1); // skip ]
2464 continue;
2465 }
2466 } else {
2467 *reason_to_stop =
2470 return nullptr;
2471 }
2472 } else {
2473 // we have a low and a high index
2474 llvm::StringRef sleft, sright;
2475 unsigned long low_index, high_index;
2476 std::tie(sleft, sright) = bracket_expr.split('-');
2477 if (sleft.getAsInteger(0, low_index) ||
2478 sright.getAsInteger(0, high_index)) {
2479 *reason_to_stop =
2482 return nullptr;
2483 }
2484
2485 if (low_index > high_index) // swap indices if required
2486 std::swap(low_index, high_index);
2487
2488 if (root_compiler_type_info.Test(
2489 eTypeIsScalar)) // expansion only works for scalars
2490 {
2491 root = root->GetSyntheticBitFieldChild(low_index, high_index, true);
2492 if (!root) {
2493 *reason_to_stop =
2496 return nullptr;
2497 } else {
2498 *reason_to_stop = ValueObject::
2501 return root;
2502 }
2503 } else if (root_compiler_type_info.Test(
2504 eTypeIsPointer) && // if this is a ptr-to-scalar, I am
2505 // accessing it by index and I would
2506 // have deref'ed anyway, then do it
2507 // now and use this as a bitfield
2508 *what_next ==
2510 pointee_compiler_type_info.Test(eTypeIsScalar)) {
2511 Status error;
2512 root = root->Dereference(error);
2513 if (error.Fail() || !root) {
2514 *reason_to_stop =
2517 return nullptr;
2518 } else {
2520 continue;
2521 }
2522 } else {
2523 *reason_to_stop =
2526 return root;
2527 }
2528 }
2529 break;
2530 }
2531 default: // some non-separator is in the way
2532 {
2533 *reason_to_stop =
2536 return nullptr;
2537 }
2538 }
2539 }
2540}
2541
2543
2545 ValueObjectPrinter printer(*this, &s, options);
2546 printer.PrintValueObject();
2547}
2548
2550 ValueObjectSP valobj_sp;
2551
2552 if (UpdateValueIfNeeded(false) && m_error.Success()) {
2554
2555 DataExtractor data;
2558
2559 if (IsBitfield()) {
2561 m_error = v.GetValueAsData(&exe_ctx, data, GetModule().get());
2562 } else
2563 m_error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
2564
2566 exe_ctx.GetBestExecutionContextScope(), GetCompilerType(), name, data,
2567 GetAddressOf());
2568 }
2569
2570 if (!valobj_sp) {
2574 }
2575 return valobj_sp;
2576}
2577
2579 lldb::DynamicValueType dynValue, bool synthValue) {
2580 ValueObjectSP result_sp;
2581 switch (dynValue) {
2584 if (!IsDynamic())
2585 result_sp = GetDynamicValue(dynValue);
2586 } break;
2588 if (IsDynamic())
2589 result_sp = GetStaticValue();
2590 } break;
2591 }
2592 if (!result_sp)
2593 result_sp = GetSP();
2594 assert(result_sp);
2595
2596 bool is_synthetic = result_sp->IsSynthetic();
2597 if (synthValue && !is_synthetic) {
2598 if (auto synth_sp = result_sp->GetSyntheticValue())
2599 return synth_sp;
2600 }
2601 if (!synthValue && is_synthetic) {
2602 if (auto non_synth_sp = result_sp->GetNonSyntheticValue())
2603 return non_synth_sp;
2604 }
2605
2606 return result_sp;
2607}
2608
2610 if (m_deref_valobj)
2611 return m_deref_valobj->GetSP();
2612
2613 const bool is_pointer_or_reference_type = IsPointerOrReferenceType();
2614 if (is_pointer_or_reference_type) {
2615 bool omit_empty_base_classes = true;
2616 bool ignore_array_bounds = false;
2617
2618 std::string child_name_str;
2619 uint32_t child_byte_size = 0;
2620 int32_t child_byte_offset = 0;
2621 uint32_t child_bitfield_bit_size = 0;
2622 uint32_t child_bitfield_bit_offset = 0;
2623 bool child_is_base_class = false;
2624 bool child_is_deref_of_parent = false;
2625 const bool transparent_pointers = false;
2626 CompilerType compiler_type = GetCompilerType();
2627 CompilerType child_compiler_type;
2628 uint64_t language_flags = 0;
2629
2631
2632 child_compiler_type = compiler_type.GetChildCompilerTypeAtIndex(
2633 &exe_ctx, 0, transparent_pointers, omit_empty_base_classes,
2634 ignore_array_bounds, child_name_str, child_byte_size, child_byte_offset,
2635 child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
2636 child_is_deref_of_parent, this, language_flags);
2637 if (child_compiler_type && child_byte_size) {
2638 ConstString child_name;
2639 if (!child_name_str.empty())
2640 child_name.SetCString(child_name_str.c_str());
2641
2643 *this, child_compiler_type, child_name, child_byte_size,
2644 child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
2645 child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
2646 language_flags);
2647 }
2648
2649 // In case of incomplete child compiler type, use the pointee type and try
2650 // to recreate a new ValueObjectChild using it.
2651 if (!m_deref_valobj) {
2652 // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g.
2653 // `std::vector<int> &`). Remove ObjC restriction once that's resolved.
2656 child_compiler_type = compiler_type.GetPointeeType();
2657
2658 if (child_compiler_type) {
2659 ConstString child_name;
2660 if (!child_name_str.empty())
2661 child_name.SetCString(child_name_str.c_str());
2662
2664 *this, child_compiler_type, child_name, child_byte_size,
2665 child_byte_offset, child_bitfield_bit_size,
2666 child_bitfield_bit_offset, child_is_base_class,
2667 child_is_deref_of_parent, eAddressTypeInvalid, language_flags);
2668 }
2669 }
2670 }
2671
2672 } else if (HasSyntheticValue()) {
2674 GetSyntheticValue()->GetChildMemberWithName("$$dereference$$").get();
2675 } else if (IsSynthetic()) {
2676 m_deref_valobj = GetChildMemberWithName("$$dereference$$").get();
2677 }
2678
2679 if (m_deref_valobj) {
2680 error.Clear();
2681 return m_deref_valobj->GetSP();
2682 } else {
2683 StreamString strm;
2684 GetExpressionPath(strm);
2685
2686 if (is_pointer_or_reference_type)
2687 error.SetErrorStringWithFormat("dereference failed: (%s) %s",
2688 GetTypeName().AsCString("<invalid type>"),
2689 strm.GetData());
2690 else
2691 error.SetErrorStringWithFormat("not a pointer or reference type: (%s) %s",
2692 GetTypeName().AsCString("<invalid type>"),
2693 strm.GetData());
2694 return ValueObjectSP();
2695 }
2696}
2697
2700 return m_addr_of_valobj_sp;
2701
2702 AddressType address_type = eAddressTypeInvalid;
2703 const bool scalar_is_load_address = false;
2704 addr_t addr = GetAddressOf(scalar_is_load_address, &address_type);
2705 error.Clear();
2706 if (addr != LLDB_INVALID_ADDRESS && address_type != eAddressTypeHost) {
2707 switch (address_type) {
2708 case eAddressTypeInvalid: {
2709 StreamString expr_path_strm;
2710 GetExpressionPath(expr_path_strm);
2711 error.SetErrorStringWithFormat("'%s' is not in memory",
2712 expr_path_strm.GetData());
2713 } break;
2714
2715 case eAddressTypeFile:
2716 case eAddressTypeLoad: {
2717 CompilerType compiler_type = GetCompilerType();
2718 if (compiler_type) {
2719 std::string name(1, '&');
2720 name.append(m_name.AsCString(""));
2724 compiler_type.GetPointerType(), ConstString(name.c_str()), addr,
2726 }
2727 } break;
2728 default:
2729 break;
2730 }
2731 } else {
2732 StreamString expr_path_strm;
2733 GetExpressionPath(expr_path_strm);
2734 error.SetErrorStringWithFormat("'%s' doesn't have a valid address",
2735 expr_path_strm.GetData());
2736 }
2737
2738 return m_addr_of_valobj_sp;
2739}
2740
2742 return ValueObjectCast::Create(*this, GetName(), compiler_type);
2743}
2744
2746 // Only allow casts if the original type is equal or larger than the cast
2747 // type, unless we know this is a load address. Getting the size wrong for
2748 // a host side storage could leak lldb memory, so we absolutely want to
2749 // prevent that. We may not always get the right value, for instance if we
2750 // have an expression result value that's copied into a storage location in
2751 // the target may not have copied enough memory. I'm not trying to fix that
2752 // here, I'm just making Cast from a smaller to a larger possible in all the
2753 // cases where that doesn't risk making a Value out of random lldb memory.
2754 // You have to check the ValueObject's Value for the address types, since
2755 // ValueObjects that use live addresses will tell you they fetch data from the
2756 // live address, but once they are made, they actually don't.
2757 // FIXME: Can we make ValueObject's with a live address fetch "more data" from
2758 // the live address if it is still valid?
2759
2760 Status error;
2761 CompilerType my_type = GetCompilerType();
2762
2763 ExecutionContextScope *exe_scope
2766 if (compiler_type.GetByteSize(exe_scope)
2767 <= GetCompilerType().GetByteSize(exe_scope)
2769 return DoCast(compiler_type);
2770
2771 error.SetErrorString("Can only cast to a type that is equal to or smaller "
2772 "than the orignal type.");
2773
2775 ExecutionContext(GetExecutionContextRef()).GetBestExecutionContextScope(),
2776 error);
2777}
2778
2780 return ValueObjectCast::Create(*this, new_name, GetCompilerType());
2781}
2782
2784 CompilerType &compiler_type) {
2785 ValueObjectSP valobj_sp;
2786 AddressType address_type;
2787 addr_t ptr_value = GetPointerValue(&address_type);
2788
2789 if (ptr_value != LLDB_INVALID_ADDRESS) {
2790 Address ptr_addr(ptr_value);
2792 valobj_sp = ValueObjectMemory::Create(
2793 exe_ctx.GetBestExecutionContextScope(), name, ptr_addr, compiler_type);
2794 }
2795 return valobj_sp;
2796}
2797
2799 ValueObjectSP valobj_sp;
2800 AddressType address_type;
2801 addr_t ptr_value = GetPointerValue(&address_type);
2802
2803 if (ptr_value != LLDB_INVALID_ADDRESS) {
2804 Address ptr_addr(ptr_value);
2806 valobj_sp = ValueObjectMemory::Create(
2807 exe_ctx.GetBestExecutionContextScope(), name, ptr_addr, type_sp);
2808 }
2809 return valobj_sp;
2810}
2811
2812ValueObject::EvaluationPoint::EvaluationPoint() : m_mod_id(), m_exe_ctx_ref() {}
2813
2815 bool use_selected)
2816 : m_mod_id(), m_exe_ctx_ref() {
2817 ExecutionContext exe_ctx(exe_scope);
2818 TargetSP target_sp(exe_ctx.GetTargetSP());
2819 if (target_sp) {
2820 m_exe_ctx_ref.SetTargetSP(target_sp);
2821 ProcessSP process_sp(exe_ctx.GetProcessSP());
2822 if (!process_sp)
2823 process_sp = target_sp->GetProcessSP();
2824
2825 if (process_sp) {
2826 m_mod_id = process_sp->GetModID();
2827 m_exe_ctx_ref.SetProcessSP(process_sp);
2828
2829 ThreadSP thread_sp(exe_ctx.GetThreadSP());
2830
2831 if (!thread_sp) {
2832 if (use_selected)
2833 thread_sp = process_sp->GetThreadList().GetSelectedThread();
2834 }
2835
2836 if (thread_sp) {
2837 m_exe_ctx_ref.SetThreadSP(thread_sp);
2838
2839 StackFrameSP frame_sp(exe_ctx.GetFrameSP());
2840 if (!frame_sp) {
2841 if (use_selected)
2842 frame_sp = thread_sp->GetSelectedFrame(DoNoSelectMostRelevantFrame);
2843 }
2844 if (frame_sp)
2845 m_exe_ctx_ref.SetFrameSP(frame_sp);
2846 }
2847 }
2848 }
2849}
2850
2853 : m_mod_id(), m_exe_ctx_ref(rhs.m_exe_ctx_ref) {}
2854
2856
2857// This function checks the EvaluationPoint against the current process state.
2858// If the current state matches the evaluation point, or the evaluation point
2859// is already invalid, then we return false, meaning "no change". If the
2860// current state is different, we update our state, and return true meaning
2861// "yes, change". If we did see a change, we also set m_needs_update to true,
2862// so future calls to NeedsUpdate will return true. exe_scope will be set to
2863// the current execution context scope.
2864
2866 bool accept_invalid_exe_ctx) {
2867 // Start with the target, if it is NULL, then we're obviously not going to
2868 // get any further:
2869 const bool thread_and_frame_only_if_stopped = true;
2870 ExecutionContext exe_ctx(
2871 m_exe_ctx_ref.Lock(thread_and_frame_only_if_stopped));
2872
2873 if (exe_ctx.GetTargetPtr() == nullptr)
2874 return false;
2875
2876 // If we don't have a process nothing can change.
2877 Process *process = exe_ctx.GetProcessPtr();
2878 if (process == nullptr)
2879 return false;
2880
2881 // If our stop id is the current stop ID, nothing has changed:
2882 ProcessModID current_mod_id = process->GetModID();
2883
2884 // If the current stop id is 0, either we haven't run yet, or the process
2885 // state has been cleared. In either case, we aren't going to be able to sync
2886 // with the process state.
2887 if (current_mod_id.GetStopID() == 0)
2888 return false;
2889
2890 bool changed = false;
2891 const bool was_valid = m_mod_id.IsValid();
2892 if (was_valid) {
2893 if (m_mod_id == current_mod_id) {
2894 // Everything is already up to date in this object, no need to update the
2895 // execution context scope.
2896 changed = false;
2897 } else {
2898 m_mod_id = current_mod_id;
2899 m_needs_update = true;
2900 changed = true;
2901 }
2902 }
2903
2904 // Now re-look up the thread and frame in case the underlying objects have
2905 // gone away & been recreated. That way we'll be sure to return a valid
2906 // exe_scope. If we used to have a thread or a frame but can't find it
2907 // anymore, then mark ourselves as invalid.
2908
2909 if (!accept_invalid_exe_ctx) {
2910 if (m_exe_ctx_ref.HasThreadRef()) {
2911 ThreadSP thread_sp(m_exe_ctx_ref.GetThreadSP());
2912 if (thread_sp) {
2913 if (m_exe_ctx_ref.HasFrameRef()) {
2914 StackFrameSP frame_sp(m_exe_ctx_ref.GetFrameSP());
2915 if (!frame_sp) {
2916 // We used to have a frame, but now it is gone
2917 SetInvalid();
2918 changed = was_valid;
2919 }
2920 }
2921 } else {
2922 // We used to have a thread, but now it is gone
2923 SetInvalid();
2924 changed = was_valid;
2925 }
2926 }
2927 }
2928
2929 return changed;
2930}
2931
2933 ProcessSP process_sp(m_exe_ctx_ref.GetProcessSP());
2934 if (process_sp)
2935 m_mod_id = process_sp->GetModID();
2936 m_needs_update = false;
2937}
2938
2939void ValueObject::ClearUserVisibleData(uint32_t clear_mask) {
2940 if ((clear_mask & eClearUserVisibleDataItemsValue) ==
2942 m_value_str.clear();
2943
2944 if ((clear_mask & eClearUserVisibleDataItemsLocation) ==
2946 m_location_str.clear();
2947
2948 if ((clear_mask & eClearUserVisibleDataItemsSummary) ==
2950 m_summary_str.clear();
2951
2952 if ((clear_mask & eClearUserVisibleDataItemsDescription) ==
2954 m_object_desc_str.clear();
2955
2959 m_synthetic_value = nullptr;
2960 }
2961}
2962
2964 if (m_parent) {
2967 }
2968 return nullptr;
2969}
2970
2973 llvm::StringRef expression,
2974 const ExecutionContext &exe_ctx) {
2975 return CreateValueObjectFromExpression(name, expression, exe_ctx,
2977}
2978
2980 llvm::StringRef name, llvm::StringRef expression,
2981 const ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options) {
2982 lldb::ValueObjectSP retval_sp;
2983 lldb::TargetSP target_sp(exe_ctx.GetTargetSP());
2984 if (!target_sp)
2985 return retval_sp;
2986 if (expression.empty())
2987 return retval_sp;
2988 target_sp->EvaluateExpression(expression, exe_ctx.GetFrameSP().get(),
2989 retval_sp, options);
2990 if (retval_sp && !name.empty())
2991 retval_sp->SetName(ConstString(name));
2992 return retval_sp;
2993}
2994
2996 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
2997 CompilerType type) {
2998 if (type) {
2999 CompilerType pointer_type(type.GetPointerType());
3000 if (pointer_type) {
3001 lldb::DataBufferSP buffer(
3002 new lldb_private::DataBufferHeap(&address, sizeof(lldb::addr_t)));
3004 exe_ctx.GetBestExecutionContextScope(), pointer_type,
3005 ConstString(name), buffer, exe_ctx.GetByteOrder(),
3006 exe_ctx.GetAddressByteSize()));
3007 if (ptr_result_valobj_sp) {
3008 ptr_result_valobj_sp->GetValue().SetValueType(
3010 Status err;
3011 ptr_result_valobj_sp = ptr_result_valobj_sp->Dereference(err);
3012 if (ptr_result_valobj_sp && !name.empty())
3013 ptr_result_valobj_sp->SetName(ConstString(name));
3014 }
3015 return ptr_result_valobj_sp;
3016 }
3017 }
3018 return lldb::ValueObjectSP();
3019}
3020
3022 llvm::StringRef name, const DataExtractor &data,
3023 const ExecutionContext &exe_ctx, CompilerType type) {
3024 lldb::ValueObjectSP new_value_sp;
3025 new_value_sp = ValueObjectConstResult::Create(
3026 exe_ctx.GetBestExecutionContextScope(), type, ConstString(name), data,
3028 new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
3029 if (new_value_sp && !name.empty())
3030 new_value_sp->SetName(ConstString(name));
3031 return new_value_sp;
3032}
3033
3035 ValueObject *root(GetRoot());
3036 if (root != this)
3037 return root->GetModule();
3038 return lldb::ModuleSP();
3039}
3040
3042 if (m_root)
3043 return m_root;
3044 return (m_root = FollowParentChain([](ValueObject *vo) -> bool {
3045 return (vo->m_parent != nullptr);
3046 }));
3047}
3048
3051 ValueObject *vo = this;
3052 while (vo) {
3053 if (!f(vo))
3054 break;
3055 vo = vo->m_parent;
3056 }
3057 return vo;
3058}
3059
3062 ValueObject *root(GetRoot());
3063 if (root != this)
3064 return root->GetAddressTypeOfChildren();
3065 }
3067}
3068
3070 ValueObject *with_dv_info = this;
3071 while (with_dv_info) {
3072 if (with_dv_info->HasDynamicValueTypeInfo())
3073 return with_dv_info->GetDynamicValueTypeImpl();
3074 with_dv_info = with_dv_info->m_parent;
3075 }
3077}
3078
3080 const ValueObject *with_fmt_info = this;
3081 while (with_fmt_info) {
3082 if (with_fmt_info->m_format != lldb::eFormatDefault)
3083 return with_fmt_info->m_format;
3084 with_fmt_info = with_fmt_info->m_parent;
3085 }
3086 return m_format;
3087}
3088
3092 if (GetRoot()) {
3093 if (GetRoot() == this) {
3094 if (StackFrameSP frame_sp = GetFrameSP()) {
3095 const SymbolContext &sc(
3096 frame_sp->GetSymbolContext(eSymbolContextCompUnit));
3097 if (CompileUnit *cu = sc.comp_unit)
3098 type = cu->GetLanguage();
3099 }
3100 } else {
3102 }
3103 }
3104 }
3105 return (m_preferred_display_language = type); // only compute it once
3106}
3107
3111}
3112
3114 // we need to support invalid types as providers of values because some bare-
3115 // board debugging scenarios have no notion of types, but still manage to
3116 // have raw numeric values for things like registers. sigh.
3118 return (!type.IsValid()) || (0 != (type.GetTypeInfo() & eTypeHasValue));
3119}
3120
3121
3122
3124 if (!UpdateValueIfNeeded())
3125 return nullptr;
3126
3127 TargetSP target_sp(GetTargetSP());
3128 if (!target_sp)
3129 return nullptr;
3130
3131 PersistentExpressionState *persistent_state =
3132 target_sp->GetPersistentExpressionStateForLanguage(
3134
3135 if (!persistent_state)
3136 return nullptr;
3137
3138 ConstString name = persistent_state->GetNextPersistentVariableName();
3139
3140 ValueObjectSP const_result_sp =
3141 ValueObjectConstResult::Create(target_sp.get(), GetValue(), name);
3142
3143 ExpressionVariableSP persistent_var_sp =
3144 persistent_state->CreatePersistentVariable(const_result_sp);
3145 persistent_var_sp->m_live_sp = persistent_var_sp->m_frozen_sp;
3146 persistent_var_sp->m_flags |= ExpressionVariable::EVIsProgramReference;
3147
3148 return persistent_var_sp->GetValueObject();
3149}
3150
3152 return ValueObjectVTable::Create(*this);
3153}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG_ERRORV(log, error,...)
Definition: Log.h:379
#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:83
static bool LanguageIsCFamily(lldb::LanguageType language)
Equivalent to LanguageIsC||LanguageIsObjC||LanguageIsCPlusPlus.
Definition: Language.cpp:335
static bool LanguageIsObjC(lldb::LanguageType language)
Definition: Language.cpp:313
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:249
bool IsValid() const
Definition: Process.h:267
A plug-in interface definition class for debugging a process.
Definition: Process.h:341
ProcessModID GetModID() const
Get the Modification ID of the process.
Definition: Process.h:1472
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:1939
bool IsPossibleDynamicValue(ValueObject &in_value)
Definition: Process.cpp:1551
LanguageRuntime * GetLanguageRuntime(lldb::LanguageType language)
Definition: Process.cpp:1523
size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error)
Write memory to a process.
Definition: Process.cpp:2138
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:2220
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:4607
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:1828
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(uint32_t idx)
Definition: ValueObject.h:800
void SetChildAtIndex(size_t idx, ValueObject *valobj)
Definition: ValueObject.h:806
bool SyncWithProcessState(bool accept_invalid_exe_ctx)
AddressType m_address_type_of_ptr_or_ref_children
Definition: ValueObject.h:891
void SetValueIsValid(bool valid)
Definition: ValueObject.h:976
EvaluationPoint m_update_point
Stores both the stop id and the full context at which this value was last updated.
Definition: ValueObject.h:842
lldb::TypeSummaryImplSP GetSummaryFormat()
Definition: ValueObject.h:712
llvm::SmallVector< uint8_t, 16 > m_value_checksum
Definition: ValueObject.h:893
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:863
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:886
friend class ValueObjectSynthetic
Definition: ValueObject.h:930
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:878
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx, bool can_create=true)
virtual lldb::DynamicValueType GetDynamicValueTypeImpl()
Definition: ValueObject.h:951
lldb::addr_t GetPointerValue(AddressType *address_type=nullptr)
virtual bool GetIsConstant() const
Definition: ValueObject.h:688
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:722
virtual void CalculateSyntheticValue()
void SetPreferredDisplayLanguage(lldb::LanguageType lt)
Definition: ValueObject.h:708
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
std::string m_summary_str
Cached summary string that will get cleared if/when the value is updated.
Definition: ValueObject.h:858
virtual lldb::ValueObjectSP DoCast(const CompilerType &compiler_type)
lldb::ValueObjectSP GetSP()
Definition: ValueObject.h:545
ChildrenManager m_children
Definition: ValueObject.h:873
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:850
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:871
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:780
@ 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:846
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:633
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
llvm::Expected< uint32_t > GetNumChildren(uint32_t max=UINT32_MAX)
virtual void GetExpressionPath(Stream &s, GetExpressionPathFormat=eGetExpressionPathFormatDereferencePointers)
virtual bool HasSyntheticValue()
lldb::StackFrameSP GetFrameSP() const
Definition: ValueObject.h:346
friend class ValueObjectChild
Definition: ValueObject.h:926
lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef< llvm::StringRef > names)
void SetSummaryFormat(lldb::TypeSummaryImplSP format)
Definition: ValueObject.h:717
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:972
ValueObject * m_root
The root of the hierarchy for this ValueObject (or nullptr if never calculated).
Definition: ValueObject.h:838
bool GetValueIsValid() const
Definition: ValueObject.h:535
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:895
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr)
Definition: ValueObject.h:378
virtual llvm::Expected< uint32_t > CalculateNumChildren(uint32_t max=UINT32_MAX)=0
Should only be called by ValueObject::GetNumChildren().
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:885
virtual SymbolContextScope * GetSymbolContextScope()
virtual bool HasDynamicValueTypeInfo()
Definition: ValueObject.h:955
ValueObject * m_synthetic_value
Definition: ValueObject.h:877
void SetNumChildren(uint32_t num_children)
ValueObject * m_parent
The parent value object, or nullptr if this has no parent.
Definition: ValueObject.h:835
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:882
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:888
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:498
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:856
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:580
lldb::ValueObjectSP Persist()
std::string m_object_desc_str
Cached result of the "object printer".
Definition: ValueObject.h:861
virtual ValueObject * GetParent()
Definition: ValueObject.h:748
virtual CompilerType MaybeCalculateCompleteType()
lldb::SyntheticChildrenSP m_synthetic_children_sp
Definition: ValueObject.h:889
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:854
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:852
lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create)
virtual bool ResolveValue(Scalar &scalar)
void SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp)
Definition: ValueObject.h:732
ConstString m_name
The name of this object.
Definition: ValueObject.h:844
const char * GetLocationAsCStringImpl(const Value &value, const DataExtractor &data)
virtual void SetFormat(lldb::Format format)
Definition: ValueObject.h:700
ValueObject * m_dynamic_value
Definition: ValueObject.h:876
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:588
std::map< ConstString, ValueObject * > m_synthetic_children
Definition: ValueObject.h:874
const ExecutionContextRef & GetExecutionContextRef() const
Definition: ValueObject.h:330
uint32_t GetNumChildrenIgnoringErrors(uint32_t max=UINT32_MAX)
Like GetNumChildren but returns 0 on error.
virtual bool CanProvideValue()
const Value & GetValue() const
Definition: ValueObject.h:487
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.