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