LLDB  mainline
Materializer.cpp
Go to the documentation of this file.
1 //===-- Materializer.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 
14 #include "lldb/Symbol/Symbol.h"
15 #include "lldb/Symbol/Type.h"
16 #include "lldb/Symbol/Variable.h"
19 #include "lldb/Target/StackFrame.h"
20 #include "lldb/Target/Target.h"
21 #include "lldb/Target/Thread.h"
22 #include "lldb/Utility/LLDBLog.h"
23 #include "lldb/Utility/Log.h"
25 #include "lldb/lldb-forward.h"
26 
27 #include <memory>
28 
29 using namespace lldb_private;
30 
31 // FIXME: these should be retrieved from the target
32 // instead of being hard-coded. Currently we
33 // assume that persistent vars are materialized
34 // as references, and thus pick the size of a
35 // 64-bit pointer.
36 static constexpr uint32_t g_default_var_alignment = 8;
37 static constexpr uint32_t g_default_var_byte_size = 8;
38 
40  uint32_t size = entity.GetSize();
41  uint32_t alignment = entity.GetAlignment();
42 
43  uint32_t ret;
44 
45  if (m_current_offset == 0)
46  m_struct_alignment = alignment;
47 
48  if (m_current_offset % alignment)
49  m_current_offset += (alignment - (m_current_offset % alignment));
50 
51  ret = m_current_offset;
52 
53  m_current_offset += size;
54 
55  return ret;
56 }
57 
59 public:
60  EntityPersistentVariable(lldb::ExpressionVariableSP &persistent_variable_sp,
62  : Entity(), m_persistent_variable_sp(persistent_variable_sp),
63  m_delegate(delegate) {
64  // Hard-coding to maximum size of a pointer since persistent variables are
65  // materialized by reference
66  m_size = g_default_var_byte_size;
67  m_alignment = g_default_var_alignment;
68  }
69 
70  void MakeAllocation(IRMemoryMap &map, Status &err) {
72 
73  // Allocate a spare memory area to store the persistent variable's
74  // contents.
75 
76  Status allocate_error;
77  const bool zero_memory = false;
78 
79  lldb::addr_t mem = map.Malloc(
80  m_persistent_variable_sp->GetByteSize().value_or(0), 8,
81  lldb::ePermissionsReadable | lldb::ePermissionsWritable,
82  IRMemoryMap::eAllocationPolicyMirror, zero_memory, allocate_error);
83 
84  if (!allocate_error.Success()) {
86  "couldn't allocate a memory area to store %s: %s",
87  m_persistent_variable_sp->GetName().GetCString(),
88  allocate_error.AsCString());
89  return;
90  }
91 
92  LLDB_LOGF(log, "Allocated %s (0x%" PRIx64 ") successfully",
93  m_persistent_variable_sp->GetName().GetCString(), mem);
94 
95  // Put the location of the spare memory into the live data of the
96  // ValueObject.
97 
98  m_persistent_variable_sp->m_live_sp = ValueObjectConstResult::Create(
100  m_persistent_variable_sp->GetCompilerType(),
101  m_persistent_variable_sp->GetName(), mem, eAddressTypeLoad,
102  map.GetAddressByteSize());
103 
104  // Clear the flag if the variable will never be deallocated.
105 
106  if (m_persistent_variable_sp->m_flags &
108  Status leak_error;
109  map.Leak(mem, leak_error);
110  m_persistent_variable_sp->m_flags &=
111  ~ExpressionVariable::EVNeedsAllocation;
112  }
113 
114  // Write the contents of the variable to the area.
115 
116  Status write_error;
117 
118  map.WriteMemory(mem, m_persistent_variable_sp->GetValueBytes(),
119  m_persistent_variable_sp->GetByteSize().value_or(0),
120  write_error);
121 
122  if (!write_error.Success()) {
124  "couldn't write %s to the target: %s",
125  m_persistent_variable_sp->GetName().AsCString(),
126  write_error.AsCString());
127  return;
128  }
129  }
130 
132  Status deallocate_error;
133 
134  map.Free((lldb::addr_t)m_persistent_variable_sp->m_live_sp->GetValue()
135  .GetScalar()
136  .ULongLong(),
137  deallocate_error);
138 
139  m_persistent_variable_sp->m_live_sp.reset();
140 
141  if (!deallocate_error.Success()) {
143  "couldn't deallocate memory for %s: %s",
144  m_persistent_variable_sp->GetName().GetCString(),
145  deallocate_error.AsCString());
146  }
147  }
148 
149  void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
150  lldb::addr_t process_address, Status &err) override {
152 
153  const lldb::addr_t load_addr = process_address + m_offset;
154 
155  if (log) {
156  LLDB_LOGF(log,
157  "EntityPersistentVariable::Materialize [address = 0x%" PRIx64
158  ", m_name = %s, m_flags = 0x%hx]",
159  (uint64_t)load_addr,
160  m_persistent_variable_sp->GetName().AsCString(),
161  m_persistent_variable_sp->m_flags);
162  }
163 
164  if (m_persistent_variable_sp->m_flags &
166  MakeAllocation(map, err);
167  m_persistent_variable_sp->m_flags |=
169 
170  if (!err.Success())
171  return;
172  }
173 
174  if ((m_persistent_variable_sp->m_flags &
176  m_persistent_variable_sp->m_live_sp) ||
177  m_persistent_variable_sp->m_flags &
179  Status write_error;
180 
182  load_addr,
183  m_persistent_variable_sp->m_live_sp->GetValue().GetScalar(),
184  map.GetAddressByteSize(), write_error);
185 
186  if (!write_error.Success()) {
188  "couldn't write the location of %s to memory: %s",
189  m_persistent_variable_sp->GetName().AsCString(),
190  write_error.AsCString());
191  }
192  } else {
194  "no materialization happened for persistent variable %s",
195  m_persistent_variable_sp->GetName().AsCString());
196  return;
197  }
198  }
199 
200  void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
201  lldb::addr_t process_address, lldb::addr_t frame_top,
202  lldb::addr_t frame_bottom, Status &err) override {
204 
205  const lldb::addr_t load_addr = process_address + m_offset;
206 
207  if (log) {
208  LLDB_LOGF(log,
209  "EntityPersistentVariable::Dematerialize [address = 0x%" PRIx64
210  ", m_name = %s, m_flags = 0x%hx]",
211  (uint64_t)process_address + m_offset,
212  m_persistent_variable_sp->GetName().AsCString(),
213  m_persistent_variable_sp->m_flags);
214  }
215 
216  if (m_delegate) {
217  m_delegate->DidDematerialize(m_persistent_variable_sp);
218  }
219 
220  if ((m_persistent_variable_sp->m_flags &
222  (m_persistent_variable_sp->m_flags &
224  if (m_persistent_variable_sp->m_flags &
226  !m_persistent_variable_sp->m_live_sp) {
227  // If the reference comes from the program, then the
228  // ClangExpressionVariable's live variable data hasn't been set up yet.
229  // Do this now.
230 
231  lldb::addr_t location;
232  Status read_error;
233 
234  map.ReadPointerFromMemory(&location, load_addr, read_error);
235 
236  if (!read_error.Success()) {
238  "couldn't read the address of program-allocated variable %s: %s",
239  m_persistent_variable_sp->GetName().GetCString(),
240  read_error.AsCString());
241  return;
242  }
243 
244  m_persistent_variable_sp->m_live_sp = ValueObjectConstResult::Create(
246  m_persistent_variable_sp.get()->GetCompilerType(),
247  m_persistent_variable_sp->GetName(), location, eAddressTypeLoad,
248  m_persistent_variable_sp->GetByteSize().value_or(0));
249 
250  if (frame_top != LLDB_INVALID_ADDRESS &&
251  frame_bottom != LLDB_INVALID_ADDRESS && location >= frame_bottom &&
252  location <= frame_top) {
253  // If the variable is resident in the stack frame created by the
254  // expression, then it cannot be relied upon to stay around. We
255  // treat it as needing reallocation.
256  m_persistent_variable_sp->m_flags |=
258  m_persistent_variable_sp->m_flags |=
260  m_persistent_variable_sp->m_flags |=
262  m_persistent_variable_sp->m_flags &=
263  ~ExpressionVariable::EVIsProgramReference;
264  }
265  }
266 
267  lldb::addr_t mem = m_persistent_variable_sp->m_live_sp->GetValue()
268  .GetScalar()
269  .ULongLong();
270 
271  if (!m_persistent_variable_sp->m_live_sp) {
273  "couldn't find the memory area used to store %s",
274  m_persistent_variable_sp->GetName().GetCString());
275  return;
276  }
277 
278  if (m_persistent_variable_sp->m_live_sp->GetValue()
279  .GetValueAddressType() != eAddressTypeLoad) {
281  "the address of the memory area for %s is in an incorrect format",
282  m_persistent_variable_sp->GetName().GetCString());
283  return;
284  }
285 
286  if (m_persistent_variable_sp->m_flags &
288  m_persistent_variable_sp->m_flags &
290  LLDB_LOGF(log, "Dematerializing %s from 0x%" PRIx64 " (size = %llu)",
291  m_persistent_variable_sp->GetName().GetCString(),
292  (uint64_t)mem,
293  (unsigned long long)m_persistent_variable_sp->GetByteSize()
294  .value_or(0));
295 
296  // Read the contents of the spare memory area
297 
298  m_persistent_variable_sp->ValueUpdated();
299 
300  Status read_error;
301 
302  map.ReadMemory(m_persistent_variable_sp->GetValueBytes(), mem,
303  m_persistent_variable_sp->GetByteSize().value_or(0),
304  read_error);
305 
306  if (!read_error.Success()) {
308  "couldn't read the contents of %s from memory: %s",
309  m_persistent_variable_sp->GetName().GetCString(),
310  read_error.AsCString());
311  return;
312  }
313 
314  m_persistent_variable_sp->m_flags &=
315  ~ExpressionVariable::EVNeedsFreezeDry;
316  }
317  } else {
319  "no dematerialization happened for persistent variable %s",
320  m_persistent_variable_sp->GetName().AsCString());
321  return;
322  }
323 
324  lldb::ProcessSP process_sp =
326  if (!process_sp || !process_sp->CanJIT()) {
327  // Allocations are not persistent so persistent variables cannot stay
328  // materialized.
329 
330  m_persistent_variable_sp->m_flags |=
332 
333  DestroyAllocation(map, err);
334  if (!err.Success())
335  return;
336  } else if (m_persistent_variable_sp->m_flags &
338  !(m_persistent_variable_sp->m_flags &
340  DestroyAllocation(map, err);
341  if (!err.Success())
342  return;
343  }
344  }
345 
346  void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address,
347  Log *log) override {
348  StreamString dump_stream;
349 
350  Status err;
351 
352  const lldb::addr_t load_addr = process_address + m_offset;
353 
354  dump_stream.Printf("0x%" PRIx64 ": EntityPersistentVariable (%s)\n",
355  load_addr,
356  m_persistent_variable_sp->GetName().AsCString());
357 
358  {
359  dump_stream.Printf("Pointer:\n");
360 
361  DataBufferHeap data(m_size, 0);
362 
363  map.ReadMemory(data.GetBytes(), load_addr, m_size, err);
364 
365  if (!err.Success()) {
366  dump_stream.Printf(" <could not be read>\n");
367  } else {
368  DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
369  load_addr);
370 
371  dump_stream.PutChar('\n');
372  }
373  }
374 
375  {
376  dump_stream.Printf("Target:\n");
377 
378  lldb::addr_t target_address;
379 
380  map.ReadPointerFromMemory(&target_address, load_addr, err);
381 
382  if (!err.Success()) {
383  dump_stream.Printf(" <could not be read>\n");
384  } else {
385  DataBufferHeap data(m_persistent_variable_sp->GetByteSize().value_or(0),
386  0);
387 
388  map.ReadMemory(data.GetBytes(), target_address,
389  m_persistent_variable_sp->GetByteSize().value_or(0),
390  err);
391 
392  if (!err.Success()) {
393  dump_stream.Printf(" <could not be read>\n");
394  } else {
395  DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
396  target_address);
397 
398  dump_stream.PutChar('\n');
399  }
400  }
401  }
402 
403  log->PutString(dump_stream.GetString());
404  }
405 
406  void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override {}
407 
408 private:
409  lldb::ExpressionVariableSP m_persistent_variable_sp;
411 };
412 
414  lldb::ExpressionVariableSP &persistent_variable_sp,
415  PersistentVariableDelegate *delegate, Status &err) {
416  EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
417  *iter = std::make_unique<EntityPersistentVariable>(persistent_variable_sp,
418  delegate);
419  uint32_t ret = AddStructMember(**iter);
420  (*iter)->SetOffset(ret);
421  return ret;
422 }
423 
424 /// Base class for materialization of Variables and ValueObjects.
425 ///
426 /// Subclasses specify how to obtain the Value which is to be
427 /// materialized.
429 public:
430  virtual ~EntityVariableBase() = default;
431 
433  // Hard-coding to maximum size of a pointer since all variables are
434  // materialized by reference
435  m_size = g_default_var_byte_size;
436  m_alignment = g_default_var_alignment;
437  }
438 
439  void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
440  lldb::addr_t process_address, Status &err) override {
442 
443  const lldb::addr_t load_addr = process_address + m_offset;
444  if (log) {
445  LLDB_LOGF(log,
446  "EntityVariable::Materialize [address = 0x%" PRIx64
447  ", m_variable_sp = %s]",
448  (uint64_t)load_addr, GetName().GetCString());
449  }
450 
451  ExecutionContextScope *scope = frame_sp.get();
452 
453  if (!scope)
454  scope = map.GetBestExecutionContextScope();
455 
456  lldb::ValueObjectSP valobj_sp = SetupValueObject(scope);
457 
458  if (!valobj_sp) {
460  "couldn't get a value object for variable %s", GetName().AsCString());
461  return;
462  }
463 
464  Status valobj_error = valobj_sp->GetError();
465 
466  if (valobj_error.Fail()) {
467  err.SetErrorStringWithFormat("couldn't get the value of variable %s: %s",
468  GetName().AsCString(),
469  valobj_error.AsCString());
470  return;
471  }
472 
473  if (m_is_reference) {
474  DataExtractor valobj_extractor;
475  Status extract_error;
476  valobj_sp->GetData(valobj_extractor, extract_error);
477 
478  if (!extract_error.Success()) {
480  "couldn't read contents of reference variable %s: %s",
481  GetName().AsCString(), extract_error.AsCString());
482  return;
483  }
484 
485  lldb::offset_t offset = 0;
486  lldb::addr_t reference_addr = valobj_extractor.GetAddress(&offset);
487 
488  Status write_error;
489  map.WritePointerToMemory(load_addr, reference_addr, write_error);
490 
491  if (!write_error.Success()) {
492  err.SetErrorStringWithFormat("couldn't write the contents of reference "
493  "variable %s to memory: %s",
494  GetName().AsCString(),
495  write_error.AsCString());
496  return;
497  }
498  } else {
499  AddressType address_type = eAddressTypeInvalid;
500  const bool scalar_is_load_address = false;
501  lldb::addr_t addr_of_valobj =
502  valobj_sp->GetAddressOf(scalar_is_load_address, &address_type);
503  if (addr_of_valobj != LLDB_INVALID_ADDRESS) {
504  Status write_error;
505  map.WritePointerToMemory(load_addr, addr_of_valobj, write_error);
506 
507  if (!write_error.Success()) {
509  "couldn't write the address of variable %s to memory: %s",
510  GetName().AsCString(), write_error.AsCString());
511  return;
512  }
513  } else {
514  DataExtractor data;
515  Status extract_error;
516  valobj_sp->GetData(data, extract_error);
517  if (!extract_error.Success()) {
518  err.SetErrorStringWithFormat("couldn't get the value of %s: %s",
519  GetName().AsCString(),
520  extract_error.AsCString());
521  return;
522  }
523 
524  if (m_temporary_allocation != LLDB_INVALID_ADDRESS) {
526  "trying to create a temporary region for %s but one exists",
527  GetName().AsCString());
528  return;
529  }
530 
531  if (data.GetByteSize() < GetByteSize(scope)) {
532  if (data.GetByteSize() == 0 && !LocationExpressionIsValid()) {
533  err.SetErrorStringWithFormat("the variable '%s' has no location, "
534  "it may have been optimized out",
535  GetName().AsCString());
536  } else {
538  "size of variable %s (%" PRIu64
539  ") is larger than the ValueObject's size (%" PRIu64 ")",
540  GetName().AsCString(), GetByteSize(scope).value_or(0),
541  data.GetByteSize());
542  }
543  return;
544  }
545 
546  llvm::Optional<size_t> opt_bit_align = GetTypeBitAlign(scope);
547  if (!opt_bit_align) {
548  err.SetErrorStringWithFormat("can't get the type alignment for %s",
549  GetName().AsCString());
550  return;
551  }
552 
553  size_t byte_align = (*opt_bit_align + 7) / 8;
554 
555  Status alloc_error;
556  const bool zero_memory = false;
557 
558  m_temporary_allocation = map.Malloc(
559  data.GetByteSize(), byte_align,
560  lldb::ePermissionsReadable | lldb::ePermissionsWritable,
561  IRMemoryMap::eAllocationPolicyMirror, zero_memory, alloc_error);
562 
563  m_temporary_allocation_size = data.GetByteSize();
564 
565  m_original_data = std::make_shared<DataBufferHeap>(data.GetDataStart(),
566  data.GetByteSize());
567 
568  if (!alloc_error.Success()) {
570  "couldn't allocate a temporary region for %s: %s",
571  GetName().AsCString(), alloc_error.AsCString());
572  return;
573  }
574 
575  Status write_error;
576 
577  map.WriteMemory(m_temporary_allocation, data.GetDataStart(),
578  data.GetByteSize(), write_error);
579 
580  if (!write_error.Success()) {
582  "couldn't write to the temporary region for %s: %s",
583  GetName().AsCString(), write_error.AsCString());
584  return;
585  }
586 
587  Status pointer_write_error;
588 
589  map.WritePointerToMemory(load_addr, m_temporary_allocation,
590  pointer_write_error);
591 
592  if (!pointer_write_error.Success()) {
594  "couldn't write the address of the temporary region for %s: %s",
595  GetName().AsCString(), pointer_write_error.AsCString());
596  }
597  }
598  }
599  }
600 
601  void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
602  lldb::addr_t process_address, lldb::addr_t frame_top,
603  lldb::addr_t frame_bottom, Status &err) override {
605 
606  const lldb::addr_t load_addr = process_address + m_offset;
607  if (log) {
608  LLDB_LOGF(log,
609  "EntityVariable::Dematerialize [address = 0x%" PRIx64
610  ", m_variable_sp = %s]",
611  (uint64_t)load_addr, GetName().AsCString());
612  }
613 
614  if (m_temporary_allocation != LLDB_INVALID_ADDRESS) {
615  ExecutionContextScope *scope = frame_sp.get();
616 
617  if (!scope)
618  scope = map.GetBestExecutionContextScope();
619 
620  lldb::ValueObjectSP valobj_sp = SetupValueObject(scope);
621 
622  if (!valobj_sp) {
624  "couldn't get a value object for variable %s",
625  GetName().AsCString());
626  return;
627  }
628 
630 
631  Status extract_error;
632 
633  map.GetMemoryData(data, m_temporary_allocation,
634  valobj_sp->GetByteSize().value_or(0), extract_error);
635 
636  if (!extract_error.Success()) {
637  err.SetErrorStringWithFormat("couldn't get the data for variable %s",
638  GetName().AsCString());
639  return;
640  }
641 
642  bool actually_write = true;
643 
644  if (m_original_data) {
645  if ((data.GetByteSize() == m_original_data->GetByteSize()) &&
646  !memcmp(m_original_data->GetBytes(), data.GetDataStart(),
647  data.GetByteSize())) {
648  actually_write = false;
649  }
650  }
651 
652  Status set_error;
653 
654  if (actually_write) {
655  valobj_sp->SetData(data, set_error);
656 
657  if (!set_error.Success()) {
659  "couldn't write the new contents of %s back into the variable",
660  GetName().AsCString());
661  return;
662  }
663  }
664 
665  Status free_error;
666 
667  map.Free(m_temporary_allocation, free_error);
668 
669  if (!free_error.Success()) {
671  "couldn't free the temporary region for %s: %s",
672  GetName().AsCString(), free_error.AsCString());
673  return;
674  }
675 
676  m_original_data.reset();
677  m_temporary_allocation = LLDB_INVALID_ADDRESS;
678  m_temporary_allocation_size = 0;
679  }
680  }
681 
682  void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address,
683  Log *log) override {
684  StreamString dump_stream;
685 
686  const lldb::addr_t load_addr = process_address + m_offset;
687  dump_stream.Printf("0x%" PRIx64 ": EntityVariable\n", load_addr);
688 
689  Status err;
690 
692 
693  {
694  dump_stream.Printf("Pointer:\n");
695 
696  DataBufferHeap data(m_size, 0);
697 
698  map.ReadMemory(data.GetBytes(), load_addr, m_size, err);
699 
700  if (!err.Success()) {
701  dump_stream.Printf(" <could not be read>\n");
702  } else {
703  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
704  map.GetByteOrder(), map.GetAddressByteSize());
705 
706  DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
707  load_addr);
708 
709  lldb::offset_t offset = 0;
710 
711  ptr = extractor.GetAddress(&offset);
712 
713  dump_stream.PutChar('\n');
714  }
715  }
716 
717  if (m_temporary_allocation == LLDB_INVALID_ADDRESS) {
718  dump_stream.Printf("Points to process memory:\n");
719  } else {
720  dump_stream.Printf("Temporary allocation:\n");
721  }
722 
723  if (ptr == LLDB_INVALID_ADDRESS) {
724  dump_stream.Printf(" <could not be be found>\n");
725  } else {
726  DataBufferHeap data(m_temporary_allocation_size, 0);
727 
728  map.ReadMemory(data.GetBytes(), m_temporary_allocation,
729  m_temporary_allocation_size, err);
730 
731  if (!err.Success()) {
732  dump_stream.Printf(" <could not be read>\n");
733  } else {
734  DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
735  load_addr);
736 
737  dump_stream.PutChar('\n');
738  }
739  }
740 
741  log->PutString(dump_stream.GetString());
742  }
743 
744  void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override {
745  if (m_temporary_allocation != LLDB_INVALID_ADDRESS) {
746  Status free_error;
747 
748  map.Free(m_temporary_allocation, free_error);
749 
750  m_temporary_allocation = LLDB_INVALID_ADDRESS;
751  m_temporary_allocation_size = 0;
752  }
753  }
754 
755 private:
756  virtual ConstString GetName() const = 0;
757 
758  /// Creates and returns ValueObject tied to this variable
759  /// and prepares Entity for materialization.
760  ///
761  /// Called each time the Materializer (de)materializes a
762  /// variable. We re-create the ValueObject based on the
763  /// current ExecutionContextScope since clients such as
764  /// conditional breakpoints may materialize the same
765  /// EntityVariable multiple times with different frames.
766  ///
767  /// Each subsequent use of the EntityVariableBase interface
768  /// will query the newly created ValueObject until this
769  /// function is called again.
770  virtual lldb::ValueObjectSP
771  SetupValueObject(ExecutionContextScope *scope) = 0;
772 
773  /// Returns size in bytes of the type associated with this variable
774  ///
775  /// \returns On success, returns byte size of the type associated
776  /// with this variable. Returns NoneType otherwise.
777  virtual llvm::Optional<uint64_t>
778  GetByteSize(ExecutionContextScope *scope) const = 0;
779 
780  /// Returns 'true' if the location expression associated with this variable
781  /// is valid.
782  virtual bool LocationExpressionIsValid() const = 0;
783 
784  /// Returns alignment of the type associated with this variable in bits.
785  ///
786  /// \returns On success, returns alignment in bits for the type associated
787  /// with this variable. Returns NoneType otherwise.
788  virtual llvm::Optional<size_t>
789  GetTypeBitAlign(ExecutionContextScope *scope) const = 0;
790 
791 protected:
792  bool m_is_reference = false;
793  lldb::addr_t m_temporary_allocation = LLDB_INVALID_ADDRESS;
794  size_t m_temporary_allocation_size = 0;
795  lldb::DataBufferSP m_original_data;
796 };
797 
798 /// Represents an Entity constructed from a VariableSP.
799 ///
800 /// This class is used for materialization of variables for which
801 /// the user has a VariableSP on hand. The ValueObject is then
802 /// derived from the associated DWARF location expression when needed
803 /// by the Materializer.
805 public:
806  EntityVariable(lldb::VariableSP &variable_sp) : m_variable_sp(variable_sp) {
807  m_is_reference =
808  m_variable_sp->GetType()->GetForwardCompilerType().IsReferenceType();
809  }
810 
811  ConstString GetName() const override { return m_variable_sp->GetName(); }
812 
813  lldb::ValueObjectSP SetupValueObject(ExecutionContextScope *scope) override {
814  assert(m_variable_sp != nullptr);
815  return ValueObjectVariable::Create(scope, m_variable_sp);
816  }
817 
818  llvm::Optional<uint64_t>
819  GetByteSize(ExecutionContextScope *scope) const override {
820  return m_variable_sp->GetType()->GetByteSize(scope);
821  }
822 
823  bool LocationExpressionIsValid() const override {
824  return m_variable_sp->LocationExpressionList().IsValid();
825  }
826 
827  llvm::Optional<size_t>
828  GetTypeBitAlign(ExecutionContextScope *scope) const override {
829  return m_variable_sp->GetType()->GetLayoutCompilerType().GetTypeBitAlign(
830  scope);
831  }
832 
833 private:
834  lldb::VariableSP m_variable_sp; ///< Variable that this entity is based on.
835 };
836 
837 /// Represents an Entity constructed from a VariableSP.
838 ///
839 /// This class is used for materialization of variables for
840 /// which the user does not have a VariableSP available (e.g.,
841 /// when materializing ivars).
843 public:
844  EntityValueObject(ConstString name, ValueObjectProviderTy provider)
845  : m_name(name), m_valobj_provider(std::move(provider)) {
846  assert(m_valobj_provider);
847  }
848 
849  ConstString GetName() const override { return m_name; }
850 
851  lldb::ValueObjectSP SetupValueObject(ExecutionContextScope *scope) override {
852  m_valobj_sp =
853  m_valobj_provider(GetName(), scope->CalculateStackFrame().get());
854 
855  if (m_valobj_sp)
856  m_is_reference = m_valobj_sp->GetCompilerType().IsReferenceType();
857 
858  return m_valobj_sp;
859  }
860 
861  llvm::Optional<uint64_t>
862  GetByteSize(ExecutionContextScope *scope) const override {
863  if (m_valobj_sp)
864  return m_valobj_sp->GetCompilerType().GetByteSize(scope);
865 
866  return {};
867  }
868 
869  bool LocationExpressionIsValid() const override {
870  if (m_valobj_sp)
871  return m_valobj_sp->GetError().Success();
872 
873  return false;
874  }
875 
876  llvm::Optional<size_t>
877  GetTypeBitAlign(ExecutionContextScope *scope) const override {
878  if (m_valobj_sp)
879  return m_valobj_sp->GetCompilerType().GetTypeBitAlign(scope);
880 
881  return {};
882  }
883 
884 private:
886  lldb::ValueObjectSP m_valobj_sp;
887  ValueObjectProviderTy m_valobj_provider;
888 };
889 
890 uint32_t Materializer::AddVariable(lldb::VariableSP &variable_sp, Status &err) {
891  EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
892  *iter = std::make_unique<EntityVariable>(variable_sp);
893  uint32_t ret = AddStructMember(**iter);
894  (*iter)->SetOffset(ret);
895  return ret;
896 }
897 
899  ValueObjectProviderTy valobj_provider,
900  Status &err) {
901  assert(valobj_provider);
902  EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
903  *iter = std::make_unique<EntityValueObject>(name, std::move(valobj_provider));
904  uint32_t ret = AddStructMember(**iter);
905  (*iter)->SetOffset(ret);
906  return ret;
907 }
908 
910 public:
911  EntityResultVariable(const CompilerType &type, bool is_program_reference,
912  bool keep_in_memory,
914  : Entity(), m_type(type), m_is_program_reference(is_program_reference),
915  m_keep_in_memory(keep_in_memory), m_delegate(delegate) {
916  // Hard-coding to maximum size of a pointer since all results are
917  // materialized by reference
918  m_size = g_default_var_byte_size;
919  m_alignment = g_default_var_alignment;
920  }
921 
922  void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
923  lldb::addr_t process_address, Status &err) override {
924  if (!m_is_program_reference) {
925  if (m_temporary_allocation != LLDB_INVALID_ADDRESS) {
926  err.SetErrorString("Trying to create a temporary region for the result "
927  "but one exists");
928  return;
929  }
930 
931  const lldb::addr_t load_addr = process_address + m_offset;
932 
933  ExecutionContextScope *exe_scope = frame_sp.get();
934  if (!exe_scope)
935  exe_scope = map.GetBestExecutionContextScope();
936 
937  llvm::Optional<uint64_t> byte_size = m_type.GetByteSize(exe_scope);
938  if (!byte_size) {
939  err.SetErrorStringWithFormat("can't get size of type \"%s\"",
940  m_type.GetTypeName().AsCString());
941  return;
942  }
943 
944  llvm::Optional<size_t> opt_bit_align = m_type.GetTypeBitAlign(exe_scope);
945  if (!opt_bit_align) {
946  err.SetErrorStringWithFormat("can't get the alignment of type \"%s\"",
947  m_type.GetTypeName().AsCString());
948  return;
949  }
950 
951  size_t byte_align = (*opt_bit_align + 7) / 8;
952 
953  Status alloc_error;
954  const bool zero_memory = true;
955 
956  m_temporary_allocation = map.Malloc(
957  *byte_size, byte_align,
958  lldb::ePermissionsReadable | lldb::ePermissionsWritable,
959  IRMemoryMap::eAllocationPolicyMirror, zero_memory, alloc_error);
960  m_temporary_allocation_size = *byte_size;
961 
962  if (!alloc_error.Success()) {
964  "couldn't allocate a temporary region for the result: %s",
965  alloc_error.AsCString());
966  return;
967  }
968 
969  Status pointer_write_error;
970 
971  map.WritePointerToMemory(load_addr, m_temporary_allocation,
972  pointer_write_error);
973 
974  if (!pointer_write_error.Success()) {
975  err.SetErrorStringWithFormat("couldn't write the address of the "
976  "temporary region for the result: %s",
977  pointer_write_error.AsCString());
978  }
979  }
980  }
981 
982  void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
983  lldb::addr_t process_address, lldb::addr_t frame_top,
984  lldb::addr_t frame_bottom, Status &err) override {
985  err.Clear();
986 
987  ExecutionContextScope *exe_scope = frame_sp.get();
988  if (!exe_scope)
989  exe_scope = map.GetBestExecutionContextScope();
990 
991  if (!exe_scope) {
992  err.SetErrorString("Couldn't dematerialize a result variable: invalid "
993  "execution context scope");
994  return;
995  }
996 
997  lldb::addr_t address;
998  Status read_error;
999  const lldb::addr_t load_addr = process_address + m_offset;
1000 
1001  map.ReadPointerFromMemory(&address, load_addr, read_error);
1002 
1003  if (!read_error.Success()) {
1004  err.SetErrorString("Couldn't dematerialize a result variable: couldn't "
1005  "read its address");
1006  return;
1007  }
1008 
1009  lldb::TargetSP target_sp = exe_scope->CalculateTarget();
1010 
1011  if (!target_sp) {
1012  err.SetErrorString("Couldn't dematerialize a result variable: no target");
1013  return;
1014  }
1015 
1016  auto type_system_or_err =
1017  target_sp->GetScratchTypeSystemForLanguage(m_type.GetMinimumLanguage());
1018 
1019  if (auto error = type_system_or_err.takeError()) {
1020  err.SetErrorStringWithFormat("Couldn't dematerialize a result variable: "
1021  "couldn't get the corresponding type "
1022  "system: %s",
1023  llvm::toString(std::move(error)).c_str());
1024  return;
1025  }
1026  auto ts = *type_system_or_err;
1027  if (!ts) {
1028  err.SetErrorStringWithFormat("Couldn't dematerialize a result variable: "
1029  "couldn't corresponding type system is "
1030  "no longer live.");
1031  return;
1032  }
1033  PersistentExpressionState *persistent_state =
1034  ts->GetPersistentExpressionState();
1035 
1036  if (!persistent_state) {
1037  err.SetErrorString("Couldn't dematerialize a result variable: "
1038  "corresponding type system doesn't handle persistent "
1039  "variables");
1040  return;
1041  }
1042 
1043  ConstString name = m_delegate
1044  ? m_delegate->GetName()
1045  : persistent_state->GetNextPersistentVariableName();
1046 
1047  lldb::ExpressionVariableSP ret = persistent_state->CreatePersistentVariable(
1048  exe_scope, name, m_type, map.GetByteOrder(), map.GetAddressByteSize());
1049 
1050  if (!ret) {
1051  err.SetErrorStringWithFormat("couldn't dematerialize a result variable: "
1052  "failed to make persistent variable %s",
1053  name.AsCString());
1054  return;
1055  }
1056 
1057  lldb::ProcessSP process_sp =
1059 
1060  if (m_delegate) {
1061  m_delegate->DidDematerialize(ret);
1062  }
1063 
1064  bool can_persist =
1065  (m_is_program_reference && process_sp && process_sp->CanJIT() &&
1066  !(address >= frame_bottom && address < frame_top));
1067 
1068  if (can_persist && m_keep_in_memory) {
1069  ret->m_live_sp = ValueObjectConstResult::Create(exe_scope, m_type, name,
1070  address, eAddressTypeLoad,
1071  map.GetAddressByteSize());
1072  }
1073 
1074  ret->ValueUpdated();
1075 
1076  const size_t pvar_byte_size = ret->GetByteSize().value_or(0);
1077  uint8_t *pvar_data = ret->GetValueBytes();
1078 
1079  map.ReadMemory(pvar_data, address, pvar_byte_size, read_error);
1080 
1081  if (!read_error.Success()) {
1082  err.SetErrorString(
1083  "Couldn't dematerialize a result variable: couldn't read its memory");
1084  return;
1085  }
1086 
1087  if (!can_persist || !m_keep_in_memory) {
1088  ret->m_flags |= ExpressionVariable::EVNeedsAllocation;
1089 
1090  if (m_temporary_allocation != LLDB_INVALID_ADDRESS) {
1091  Status free_error;
1092  map.Free(m_temporary_allocation, free_error);
1093  }
1094  } else {
1095  ret->m_flags |= ExpressionVariable::EVIsLLDBAllocated;
1096  }
1097 
1098  m_temporary_allocation = LLDB_INVALID_ADDRESS;
1099  m_temporary_allocation_size = 0;
1100  }
1101 
1102  void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address,
1103  Log *log) override {
1104  StreamString dump_stream;
1105 
1106  const lldb::addr_t load_addr = process_address + m_offset;
1107 
1108  dump_stream.Printf("0x%" PRIx64 ": EntityResultVariable\n", load_addr);
1109 
1110  Status err;
1111 
1113 
1114  {
1115  dump_stream.Printf("Pointer:\n");
1116 
1117  DataBufferHeap data(m_size, 0);
1118 
1119  map.ReadMemory(data.GetBytes(), load_addr, m_size, err);
1120 
1121  if (!err.Success()) {
1122  dump_stream.Printf(" <could not be read>\n");
1123  } else {
1124  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
1125  map.GetByteOrder(), map.GetAddressByteSize());
1126 
1127  DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
1128  load_addr);
1129 
1130  lldb::offset_t offset = 0;
1131 
1132  ptr = extractor.GetAddress(&offset);
1133 
1134  dump_stream.PutChar('\n');
1135  }
1136  }
1137 
1138  if (m_temporary_allocation == LLDB_INVALID_ADDRESS) {
1139  dump_stream.Printf("Points to process memory:\n");
1140  } else {
1141  dump_stream.Printf("Temporary allocation:\n");
1142  }
1143 
1144  if (ptr == LLDB_INVALID_ADDRESS) {
1145  dump_stream.Printf(" <could not be be found>\n");
1146  } else {
1147  DataBufferHeap data(m_temporary_allocation_size, 0);
1148 
1149  map.ReadMemory(data.GetBytes(), m_temporary_allocation,
1150  m_temporary_allocation_size, err);
1151 
1152  if (!err.Success()) {
1153  dump_stream.Printf(" <could not be read>\n");
1154  } else {
1155  DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
1156  load_addr);
1157 
1158  dump_stream.PutChar('\n');
1159  }
1160  }
1161 
1162  log->PutString(dump_stream.GetString());
1163  }
1164 
1165  void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override {
1166  if (!m_keep_in_memory && m_temporary_allocation != LLDB_INVALID_ADDRESS) {
1167  Status free_error;
1168 
1169  map.Free(m_temporary_allocation, free_error);
1170  }
1171 
1172  m_temporary_allocation = LLDB_INVALID_ADDRESS;
1173  m_temporary_allocation_size = 0;
1174  }
1175 
1176 private:
1180 
1181  lldb::addr_t m_temporary_allocation = LLDB_INVALID_ADDRESS;
1182  size_t m_temporary_allocation_size = 0;
1184 };
1185 
1187  bool is_program_reference,
1188  bool keep_in_memory,
1189  PersistentVariableDelegate *delegate,
1190  Status &err) {
1191  EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
1192  *iter = std::make_unique<EntityResultVariable>(type, is_program_reference,
1193  keep_in_memory, delegate);
1194  uint32_t ret = AddStructMember(**iter);
1195  (*iter)->SetOffset(ret);
1196  return ret;
1197 }
1198 
1200 public:
1201  EntitySymbol(const Symbol &symbol) : Entity(), m_symbol(symbol) {
1202  // Hard-coding to maximum size of a symbol
1203  m_size = g_default_var_byte_size;
1204  m_alignment = g_default_var_alignment;
1205  }
1206 
1207  void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
1208  lldb::addr_t process_address, Status &err) override {
1210 
1211  const lldb::addr_t load_addr = process_address + m_offset;
1212 
1213  if (log) {
1214  LLDB_LOGF(log,
1215  "EntitySymbol::Materialize [address = 0x%" PRIx64
1216  ", m_symbol = %s]",
1217  (uint64_t)load_addr, m_symbol.GetName().AsCString());
1218  }
1219 
1220  const Address sym_address = m_symbol.GetAddress();
1221 
1222  ExecutionContextScope *exe_scope = frame_sp.get();
1223  if (!exe_scope)
1224  exe_scope = map.GetBestExecutionContextScope();
1225 
1226  lldb::TargetSP target_sp;
1227 
1228  if (exe_scope)
1229  target_sp = map.GetBestExecutionContextScope()->CalculateTarget();
1230 
1231  if (!target_sp) {
1233  "couldn't resolve symbol %s because there is no target",
1234  m_symbol.GetName().AsCString());
1235  return;
1236  }
1237 
1238  lldb::addr_t resolved_address = sym_address.GetLoadAddress(target_sp.get());
1239 
1240  if (resolved_address == LLDB_INVALID_ADDRESS)
1241  resolved_address = sym_address.GetFileAddress();
1242 
1243  Status pointer_write_error;
1244 
1245  map.WritePointerToMemory(load_addr, resolved_address, pointer_write_error);
1246 
1247  if (!pointer_write_error.Success()) {
1249  "couldn't write the address of symbol %s: %s",
1250  m_symbol.GetName().AsCString(), pointer_write_error.AsCString());
1251  return;
1252  }
1253  }
1254 
1255  void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
1256  lldb::addr_t process_address, lldb::addr_t frame_top,
1257  lldb::addr_t frame_bottom, Status &err) override {
1259 
1260  const lldb::addr_t load_addr = process_address + m_offset;
1261 
1262  if (log) {
1263  LLDB_LOGF(log,
1264  "EntitySymbol::Dematerialize [address = 0x%" PRIx64
1265  ", m_symbol = %s]",
1266  (uint64_t)load_addr, m_symbol.GetName().AsCString());
1267  }
1268 
1269  // no work needs to be done
1270  }
1271 
1272  void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address,
1273  Log *log) override {
1274  StreamString dump_stream;
1275 
1276  Status err;
1277 
1278  const lldb::addr_t load_addr = process_address + m_offset;
1279 
1280  dump_stream.Printf("0x%" PRIx64 ": EntitySymbol (%s)\n", load_addr,
1281  m_symbol.GetName().AsCString());
1282 
1283  {
1284  dump_stream.Printf("Pointer:\n");
1285 
1286  DataBufferHeap data(m_size, 0);
1287 
1288  map.ReadMemory(data.GetBytes(), load_addr, m_size, err);
1289 
1290  if (!err.Success()) {
1291  dump_stream.Printf(" <could not be read>\n");
1292  } else {
1293  DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
1294  load_addr);
1295 
1296  dump_stream.PutChar('\n');
1297  }
1298  }
1299 
1300  log->PutString(dump_stream.GetString());
1301  }
1302 
1303  void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override {}
1304 
1305 private:
1307 };
1308 
1310  EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
1311  *iter = std::make_unique<EntitySymbol>(symbol_sp);
1312  uint32_t ret = AddStructMember(**iter);
1313  (*iter)->SetOffset(ret);
1314  return ret;
1315 }
1316 
1318 public:
1319  EntityRegister(const RegisterInfo &register_info)
1320  : Entity(), m_register_info(register_info) {
1321  // Hard-coding alignment conservatively
1322  m_size = m_register_info.byte_size;
1323  m_alignment = m_register_info.byte_size;
1324  }
1325 
1326  void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
1327  lldb::addr_t process_address, Status &err) override {
1329 
1330  const lldb::addr_t load_addr = process_address + m_offset;
1331 
1332  if (log) {
1333  LLDB_LOGF(log,
1334  "EntityRegister::Materialize [address = 0x%" PRIx64
1335  ", m_register_info = %s]",
1336  (uint64_t)load_addr, m_register_info.name);
1337  }
1338 
1339  RegisterValue reg_value;
1340 
1341  if (!frame_sp.get()) {
1343  "couldn't materialize register %s without a stack frame",
1344  m_register_info.name);
1345  return;
1346  }
1347 
1348  lldb::RegisterContextSP reg_context_sp = frame_sp->GetRegisterContext();
1349 
1350  if (!reg_context_sp->ReadRegister(&m_register_info, reg_value)) {
1351  err.SetErrorStringWithFormat("couldn't read the value of register %s",
1352  m_register_info.name);
1353  return;
1354  }
1355 
1356  DataExtractor register_data;
1357 
1358  if (!reg_value.GetData(register_data)) {
1359  err.SetErrorStringWithFormat("couldn't get the data for register %s",
1360  m_register_info.name);
1361  return;
1362  }
1363 
1364  if (register_data.GetByteSize() != m_register_info.byte_size) {
1366  "data for register %s had size %llu but we expected %llu",
1367  m_register_info.name, (unsigned long long)register_data.GetByteSize(),
1368  (unsigned long long)m_register_info.byte_size);
1369  return;
1370  }
1371 
1372  m_register_contents = std::make_shared<DataBufferHeap>(
1373  register_data.GetDataStart(), register_data.GetByteSize());
1374 
1375  Status write_error;
1376 
1377  map.WriteMemory(load_addr, register_data.GetDataStart(),
1378  register_data.GetByteSize(), write_error);
1379 
1380  if (!write_error.Success()) {
1382  "couldn't write the contents of register %s: %s",
1383  m_register_info.name, write_error.AsCString());
1384  return;
1385  }
1386  }
1387 
1388  void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
1389  lldb::addr_t process_address, lldb::addr_t frame_top,
1390  lldb::addr_t frame_bottom, Status &err) override {
1392 
1393  const lldb::addr_t load_addr = process_address + m_offset;
1394 
1395  if (log) {
1396  LLDB_LOGF(log,
1397  "EntityRegister::Dematerialize [address = 0x%" PRIx64
1398  ", m_register_info = %s]",
1399  (uint64_t)load_addr, m_register_info.name);
1400  }
1401 
1402  Status extract_error;
1403 
1404  DataExtractor register_data;
1405 
1406  if (!frame_sp.get()) {
1408  "couldn't dematerialize register %s without a stack frame",
1409  m_register_info.name);
1410  return;
1411  }
1412 
1413  lldb::RegisterContextSP reg_context_sp = frame_sp->GetRegisterContext();
1414 
1415  map.GetMemoryData(register_data, load_addr, m_register_info.byte_size,
1416  extract_error);
1417 
1418  if (!extract_error.Success()) {
1419  err.SetErrorStringWithFormat("couldn't get the data for register %s: %s",
1420  m_register_info.name,
1421  extract_error.AsCString());
1422  return;
1423  }
1424 
1425  if (!memcmp(register_data.GetDataStart(), m_register_contents->GetBytes(),
1426  register_data.GetByteSize())) {
1427  // No write required, and in particular we avoid errors if the register
1428  // wasn't writable
1429 
1430  m_register_contents.reset();
1431  return;
1432  }
1433 
1434  m_register_contents.reset();
1435 
1436  RegisterValue register_value(register_data.GetData(),
1437  register_data.GetByteOrder());
1438 
1439  if (!reg_context_sp->WriteRegister(&m_register_info, register_value)) {
1440  err.SetErrorStringWithFormat("couldn't write the value of register %s",
1441  m_register_info.name);
1442  return;
1443  }
1444  }
1445 
1446  void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address,
1447  Log *log) override {
1448  StreamString dump_stream;
1449 
1450  Status err;
1451 
1452  const lldb::addr_t load_addr = process_address + m_offset;
1453 
1454  dump_stream.Printf("0x%" PRIx64 ": EntityRegister (%s)\n", load_addr,
1455  m_register_info.name);
1456 
1457  {
1458  dump_stream.Printf("Value:\n");
1459 
1460  DataBufferHeap data(m_size, 0);
1461 
1462  map.ReadMemory(data.GetBytes(), load_addr, m_size, err);
1463 
1464  if (!err.Success()) {
1465  dump_stream.Printf(" <could not be read>\n");
1466  } else {
1467  DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
1468  load_addr);
1469 
1470  dump_stream.PutChar('\n');
1471  }
1472  }
1473 
1474  log->PutString(dump_stream.GetString());
1475  }
1476 
1477  void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override {}
1478 
1479 private:
1480  RegisterInfo m_register_info;
1481  lldb::DataBufferSP m_register_contents;
1482 };
1483 
1484 uint32_t Materializer::AddRegister(const RegisterInfo &register_info,
1485  Status &err) {
1486  EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
1487  *iter = std::make_unique<EntityRegister>(register_info);
1488  uint32_t ret = AddStructMember(**iter);
1489  (*iter)->SetOffset(ret);
1490  return ret;
1491 }
1492 
1494  DematerializerSP dematerializer_sp = m_dematerializer_wp.lock();
1495 
1496  if (dematerializer_sp)
1497  dematerializer_sp->Wipe();
1498 }
1499 
1501 Materializer::Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
1502  lldb::addr_t process_address, Status &error) {
1503  ExecutionContextScope *exe_scope = frame_sp.get();
1504  if (!exe_scope)
1505  exe_scope = map.GetBestExecutionContextScope();
1506 
1507  DematerializerSP dematerializer_sp = m_dematerializer_wp.lock();
1508 
1509  if (dematerializer_sp) {
1510  error.SetErrorToGenericError();
1511  error.SetErrorString("Couldn't materialize: already materialized");
1512  }
1513 
1514  DematerializerSP ret(
1515  new Dematerializer(*this, frame_sp, map, process_address));
1516 
1517  if (!exe_scope) {
1518  error.SetErrorToGenericError();
1519  error.SetErrorString("Couldn't materialize: target doesn't exist");
1520  }
1521 
1522  for (EntityUP &entity_up : m_entities) {
1523  entity_up->Materialize(frame_sp, map, process_address, error);
1524 
1525  if (!error.Success())
1526  return DematerializerSP();
1527  }
1528 
1529  if (Log *log = GetLog(LLDBLog::Expressions)) {
1530  LLDB_LOGF(
1531  log,
1532  "Materializer::Materialize (frame_sp = %p, process_address = 0x%" PRIx64
1533  ") materialized:",
1534  static_cast<void *>(frame_sp.get()), process_address);
1535  for (EntityUP &entity_up : m_entities)
1536  entity_up->DumpToLog(map, process_address, log);
1537  }
1538 
1539  m_dematerializer_wp = ret;
1540 
1541  return ret;
1542 }
1543 
1545  lldb::addr_t frame_bottom,
1546  lldb::addr_t frame_top) {
1547  lldb::StackFrameSP frame_sp;
1548 
1549  lldb::ThreadSP thread_sp = m_thread_wp.lock();
1550  if (thread_sp)
1551  frame_sp = thread_sp->GetFrameWithStackID(m_stack_id);
1552 
1553  ExecutionContextScope *exe_scope = frame_sp.get();
1554  if (!exe_scope)
1555  exe_scope = m_map->GetBestExecutionContextScope();
1556 
1557  if (!IsValid()) {
1558  error.SetErrorToGenericError();
1559  error.SetErrorString("Couldn't dematerialize: invalid dematerializer");
1560  }
1561 
1562  if (!exe_scope) {
1563  error.SetErrorToGenericError();
1564  error.SetErrorString("Couldn't dematerialize: target is gone");
1565  } else {
1566  if (Log *log = GetLog(LLDBLog::Expressions)) {
1567  LLDB_LOGF(log,
1568  "Materializer::Dematerialize (frame_sp = %p, process_address "
1569  "= 0x%" PRIx64 ") about to dematerialize:",
1570  static_cast<void *>(frame_sp.get()), m_process_address);
1571  for (EntityUP &entity_up : m_materializer->m_entities)
1572  entity_up->DumpToLog(*m_map, m_process_address, log);
1573  }
1574 
1575  for (EntityUP &entity_up : m_materializer->m_entities) {
1576  entity_up->Dematerialize(frame_sp, *m_map, m_process_address, frame_top,
1577  frame_bottom, error);
1578 
1579  if (!error.Success())
1580  break;
1581  }
1582  }
1583 
1584  Wipe();
1585 }
1586 
1588  if (!IsValid())
1589  return;
1590 
1591  for (EntityUP &entity_up : m_materializer->m_entities) {
1592  entity_up->Wipe(*m_map, m_process_address);
1593  }
1594 
1595  m_materializer = nullptr;
1596  m_map = nullptr;
1597  m_process_address = LLDB_INVALID_ADDRESS;
1598 }
1599 
1601  default;
lldb_private::toString
const char * toString(AppleArm64ExceptionClass EC)
Definition: AppleArm64ExceptionClass.h:38
EntityVariable::EntityVariable
EntityVariable(lldb::VariableSP &variable_sp)
Definition: Materializer.cpp:806
EntityPersistentVariable
Definition: Materializer.cpp:58
EntityVariableBase::m_original_data
lldb::DataBufferSP m_original_data
Definition: Materializer.cpp:795
lldb_private::Materializer::Entity::GetAlignment
uint32_t GetAlignment()
Definition: Materializer.h:129
lldb_private::Materializer::Materialize
DematerializerSP Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Status &err)
Definition: Materializer.cpp:1501
EntityVariableBase::DumpToLog
void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address, Log *log) override
Definition: Materializer.cpp:682
EntityValueObject::m_name
ConstString m_name
Definition: Materializer.cpp:885
lldb_private::DataBufferHeap::GetByteSize
lldb::offset_t GetByteSize() const override
Definition: DataBufferHeap.cpp:43
ExpressionVariable.h
lldb_private::Materializer::m_current_offset
uint32_t m_current_offset
Definition: Materializer.h:151
lldb_private::Log::PutString
void PutString(llvm::StringRef str)
Definition: Log.cpp:135
EntityResultVariable::m_delegate
Materializer::PersistentVariableDelegate * m_delegate
Definition: Materializer.cpp:1183
lldb_private::DataExtractor::GetAddress
uint64_t GetAddress(lldb::offset_t *offset_ptr) const
Extract an address from *offset_ptr.
Definition: DataExtractor.cpp:649
EntityResultVariable::EntityResultVariable
EntityResultVariable(const CompilerType &type, bool is_program_reference, bool keep_in_memory, Materializer::PersistentVariableDelegate *delegate)
Definition: Materializer.cpp:911
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb_private::Materializer::PersistentVariableDelegate::~PersistentVariableDelegate
virtual ~PersistentVariableDelegate()
lldb_private::Symbol
Definition: Symbol.h:20
EntityValueObject
Represents an Entity constructed from a VariableSP.
Definition: Materializer.cpp:842
lldb_private::ExecutionContextScope::CalculateStackFrame
virtual lldb::StackFrameSP CalculateStackFrame()=0
EntityResultVariable::Materialize
void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Status &err) override
Definition: Materializer.cpp:922
EntitySymbol::Wipe
void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override
Definition: Materializer.cpp:1303
g_default_var_alignment
static constexpr uint32_t g_default_var_alignment
Definition: Materializer.cpp:36
lldb_private::AddressType
AddressType
Definition: lldb-private-enumerations.h:30
EntityVariable::m_variable_sp
lldb::VariableSP m_variable_sp
Variable that this entity is based on.
Definition: Materializer.cpp:834
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:344
lldb_private::IRMemoryMap::Malloc
lldb::addr_t Malloc(size_t size, uint8_t alignment, uint32_t permissions, AllocationPolicy policy, bool zero_memory, Status &error)
Definition: IRMemoryMap.cpp:289
lldb_private::ExpressionVariable::EVIsLLDBAllocated
@ EVIsLLDBAllocated
This variable is resident in a location specifically allocated for it by LLDB in the target process.
Definition: ExpressionVariable.h:82
lldb_private::Materializer::Dematerializer::m_stack_id
StackID m_stack_id
Definition: Materializer.h:59
lldb_private::Materializer::AddPersistentVariable
uint32_t AddPersistentVariable(lldb::ExpressionVariableSP &persistent_variable_sp, PersistentVariableDelegate *delegate, Status &err)
Definition: Materializer.cpp:413
EntityPersistentVariable::Materialize
void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Status &err) override
Definition: Materializer.cpp:149
EntityValueObject::GetName
ConstString GetName() const override
Definition: Materializer.cpp:849
EntityVariable::GetTypeBitAlign
llvm::Optional< size_t > GetTypeBitAlign(ExecutionContextScope *scope) const override
Returns alignment of the type associated with this variable in bits.
Definition: Materializer.cpp:828
EntityResultVariable::DumpToLog
void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address, Log *log) override
Definition: Materializer.cpp:1102
lldb_private::Materializer::Dematerializer::m_materializer
Materializer * m_materializer
Definition: Materializer.h:57
EntityValueObject::SetupValueObject
lldb::ValueObjectSP SetupValueObject(ExecutionContextScope *scope) override
Creates and returns ValueObject tied to this variable and prepares Entity for materialization.
Definition: Materializer.cpp:851
EntityVariableBase::Dematerialize
void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, lldb::addr_t frame_top, lldb::addr_t frame_bottom, Status &err) override
Definition: Materializer.cpp:601
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:192
lldb_private::Materializer::m_dematerializer_wp
DematerializerWP m_dematerializer_wp
Definition: Materializer.h:149
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
RegisterValue.h
lldb_private::Materializer::Dematerializer::Dematerialize
void Dematerialize(Status &err, lldb::addr_t frame_top, lldb::addr_t frame_bottom)
Definition: Materializer.cpp:1544
StackFrame.h
EntityResultVariable::m_is_program_reference
bool m_is_program_reference
Definition: Materializer.cpp:1178
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::IRMemoryMap::WriteScalarToMemory
void WriteScalarToMemory(lldb::addr_t process_address, Scalar &scalar, size_t size, Status &error)
Definition: IRMemoryMap.cpp:587
lldb_private::Materializer::AddResultVariable
uint32_t AddResultVariable(const CompilerType &type, bool is_lvalue, bool keep_in_memory, PersistentVariableDelegate *delegate, Status &err)
Definition: Materializer.cpp:1186
EntityRegister::Materialize
void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Status &err) override
Definition: Materializer.cpp:1326
lldb_private::IRMemoryMap::Free
void Free(lldb::addr_t process_address, Status &error)
Definition: IRMemoryMap.cpp:446
lldb_private::Materializer::Entity
Definition: Materializer.h:113
Target.h
lldb_private::IRMemoryMap::GetByteOrder
lldb::ByteOrder GetByteOrder()
Definition: IRMemoryMap.cpp:228
lldb_private::ExpressionVariable::EVNeedsAllocation
@ EVNeedsAllocation
Space for this variable has yet to be allocated in the target process.
Definition: ExpressionVariable.h:88
EntityVariableBase::EntityVariableBase
EntityVariableBase()
Definition: Materializer.cpp:432
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::DumpHexBytes
void DumpHexBytes(Stream *s, const void *src, size_t src_len, uint32_t bytes_per_line, lldb::addr_t base_addr)
Definition: DumpDataExtractor.cpp:895
lldb_private::Status::Success
bool Success() const
Test for success condition.
Definition: Status.cpp:287
EntityResultVariable
Definition: Materializer.cpp:909
EntitySymbol::Materialize
void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Status &err) override
Definition: Materializer.cpp:1207
EntitySymbol
Definition: Materializer.cpp:1199
lldb_private::PersistentExpressionState::GetNextPersistentVariableName
virtual ConstString GetNextPersistentVariableName(bool is_error=false)=0
Return a new persistent variable name with the specified prefix.
lldb_private::Materializer::~Materializer
~Materializer()
Definition: Materializer.cpp:1493
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::eAddressTypeInvalid
@ eAddressTypeInvalid
Definition: lldb-private-enumerations.h:31
Log.h
lldb_private::ExecutionContextScope
Definition: ExecutionContextScope.h:32
lldb_private::Materializer::Dematerializer::m_thread_wp
lldb::ThreadWP m_thread_wp
Definition: Materializer.h:58
EntityVariableBase
Base class for materialization of Variables and ValueObjects.
Definition: Materializer.cpp:428
lldb_private::Materializer::DematerializerSP
std::shared_ptr< Dematerializer > DematerializerSP
Definition: Materializer.h:64
lldb_private::Status::GetError
ValueType GetError() const
Access the error value.
Definition: Status.cpp:174
lldb_private::Materializer::AddRegister
uint32_t AddRegister(const RegisterInfo &register_info, Status &err)
Definition: Materializer.cpp:1484
EntityPersistentVariable::m_persistent_variable_sp
lldb::ExpressionVariableSP m_persistent_variable_sp
Definition: Materializer.cpp:409
EntityResultVariable::Wipe
void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override
Definition: Materializer.cpp:1165
EntityResultVariable::m_keep_in_memory
bool m_keep_in_memory
Definition: Materializer.cpp:1179
lldb_private::Materializer::EntityUP
std::unique_ptr< Entity > EntityUP
Definition: Materializer.h:146
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
EntityPersistentVariable::Wipe
void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override
Definition: Materializer.cpp:406
EntityRegister::m_register_info
RegisterInfo m_register_info
Definition: Materializer.cpp:1480
lldb_private::Status::SetErrorStringWithFormat
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
EntitySymbol::Dematerialize
void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, lldb::addr_t frame_top, lldb::addr_t frame_bottom, Status &err) override
Definition: Materializer.cpp:1255
GetName
static llvm::StringRef GetName(XcodeSDK::Type type)
Definition: XcodeSDK.cpp:21
EntityPersistentVariable::MakeAllocation
void MakeAllocation(IRMemoryMap &map, Status &err)
Definition: Materializer.cpp:70
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
lldb_private::Materializer::Dematerializer::Wipe
void Wipe()
Definition: Materializer.cpp:1587
Type.h
EntityVariable
Represents an Entity constructed from a VariableSP.
Definition: Materializer.cpp:804
lldb_private::RegisterValue::GetData
bool GetData(DataExtractor &data) const
Definition: RegisterValue.cpp:34
lldb_private::Materializer::AddSymbol
uint32_t AddSymbol(const Symbol &symbol_sp, Status &err)
Definition: Materializer.cpp:1309
lldb_private::DataExtractor::GetDataStart
const uint8_t * GetDataStart() const
Get the data start pointer.
Definition: DataExtractor.h:422
lldb_private::DataExtractor::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
Definition: DataExtractor.h:594
lldb_private::IRMemoryMap::eAllocationPolicyMirror
@ eAllocationPolicyMirror
The intent is that this allocation exist both in the host and the process and have the same content i...
Definition: IRMemoryMap.h:46
lldb_private::IRMemoryMap::Leak
void Leak(lldb::addr_t process_address, Status &error)
Definition: IRMemoryMap.cpp:430
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::IRMemoryMap::GetAddressByteSize
uint32_t GetAddressByteSize()
Definition: IRMemoryMap.cpp:242
lldb_private::StreamString
Definition: StreamString.h:23
EntityValueObject::GetByteSize
llvm::Optional< uint64_t > GetByteSize(ExecutionContextScope *scope) const override
Returns size in bytes of the type associated with this variable.
Definition: Materializer.cpp:862
lldb_private::Materializer::Entity::GetSize
uint32_t GetSize()
Definition: Materializer.h:131
EntityRegister::DumpToLog
void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address, Log *log) override
Definition: Materializer.cpp:1446
lldb_private::Materializer::PersistentVariableDelegate
Definition: Materializer.h:70
lldb_private::ExpressionVariable::EVNeedsFreezeDry
@ EVNeedsFreezeDry
Copy from m_live_sp to m_frozen_sp during dematerialization.
Definition: ExpressionVariable.h:93
EntityResultVariable::m_type
CompilerType m_type
Definition: Materializer.cpp:1177
lldb_private::eAddressTypeLoad
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
Definition: lldb-private-enumerations.h:34
EntityRegister::Dematerialize
void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, lldb::addr_t frame_top, lldb::addr_t frame_bottom, Status &err) override
Definition: Materializer.cpp:1388
EntityPersistentVariable::DumpToLog
void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address, Log *log) override
Definition: Materializer.cpp:346
Thread.h
lldb_private::Stream::PutChar
size_t PutChar(char ch)
Definition: Stream.cpp:104
EntityValueObject::m_valobj_provider
ValueObjectProviderTy m_valobj_provider
Definition: Materializer.cpp:887
DumpDataExtractor.h
EntitySymbol::EntitySymbol
EntitySymbol(const Symbol &symbol)
Definition: Materializer.cpp:1201
EntityValueObject::EntityValueObject
EntityValueObject(ConstString name, ValueObjectProviderTy provider)
Definition: Materializer.cpp:844
EntityPersistentVariable::Dematerialize
void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, lldb::addr_t frame_top, lldb::addr_t frame_bottom, Status &err) override
Definition: Materializer.cpp:200
lldb_private::IRMemoryMap::ReadMemory
void ReadMemory(uint8_t *bytes, lldb::addr_t process_address, size_t size, Status &error)
Definition: IRMemoryMap.cpp:621
lldb_private::Materializer::Dematerializer::m_process_address
lldb::addr_t m_process_address
Definition: Materializer.h:61
ValueObjectConstResult.h
Symbol.h
EntitySymbol::DumpToLog
void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address, Log *log) override
Definition: Materializer.cpp:1272
EntityVariableBase::Wipe
void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override
Definition: Materializer.cpp:744
lldb_private::Materializer::AddStructMember
uint32_t AddStructMember(Entity &entity)
Definition: Materializer.cpp:39
lldb_private::ExpressionVariable
Definition: ExpressionVariable.h:23
EntityRegister::m_register_contents
lldb::DataBufferSP m_register_contents
Definition: Materializer.cpp:1481
EntityVariable::LocationExpressionIsValid
bool LocationExpressionIsValid() const override
Returns 'true' if the location expression associated with this variable is valid.
Definition: Materializer.cpp:823
Materializer.h
lldb_private::Materializer::AddValueObject
uint32_t AddValueObject(ConstString name, ValueObjectProviderTy valobj_provider, Status &err)
Create entity from supplied ValueObject and count it as a member of the materialized struct.
Definition: Materializer.cpp:898
lldb_private::Status
Definition: Status.h:44
lldb_private::ExpressionVariable::m_live_sp
lldb::ValueObjectSP m_live_sp
Definition: ExpressionVariable.h:111
lldb_private::IRMemoryMap::WriteMemory
void WriteMemory(lldb::addr_t process_address, const uint8_t *bytes, size_t size, Status &error)
Definition: IRMemoryMap.cpp:512
uint32_t
EntityRegister::Wipe
void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override
Definition: Materializer.cpp:1477
lldb_private::ExpressionVariable::EVKeepInTarget
@ EVKeepInTarget
Keep the allocation after the expression is complete rather than freeze drying its contents and freei...
Definition: ExpressionVariable.h:95
EntityRegister::EntityRegister
EntityRegister(const RegisterInfo &register_info)
Definition: Materializer.cpp:1319
lldb_private::ExpressionVariable::EVIsProgramReference
@ EVIsProgramReference
This variable is a reference to a (possibly invalid) area managed by the target program.
Definition: ExpressionVariable.h:85
lldb_private::Address
Definition: Address.h:59
EntityVariableBase::Materialize
void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Status &err) override
Definition: Materializer.cpp:439
lldb_private::IRMemoryMap::GetMemoryData
void GetMemoryData(DataExtractor &extractor, lldb::addr_t process_address, size_t size, Status &error)
Definition: IRMemoryMap.cpp:773
lldb_private::Status::SetErrorString
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:241
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:311
EntityValueObject::LocationExpressionIsValid
bool LocationExpressionIsValid() const override
Returns 'true' if the location expression associated with this variable is valid.
Definition: Materializer.cpp:869
EntityPersistentVariable::EntityPersistentVariable
EntityPersistentVariable(lldb::ExpressionVariableSP &persistent_variable_sp, Materializer::PersistentVariableDelegate *delegate)
Definition: Materializer.cpp:60
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
EntityVariable::SetupValueObject
lldb::ValueObjectSP SetupValueObject(ExecutionContextScope *scope) override
Creates and returns ValueObject tied to this variable and prepares Entity for materialization.
Definition: Materializer.cpp:813
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:35
lldb_private::ValueObjectConstResult::Create
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
Definition: ValueObjectConstResult.cpp:28
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::IRMemoryMap::WritePointerToMemory
void WritePointerToMemory(lldb::addr_t process_address, lldb::addr_t address, Status &error)
Definition: IRMemoryMap.cpp:612
lldb-forward.h
EntityPersistentVariable::m_delegate
Materializer::PersistentVariableDelegate * m_delegate
Definition: Materializer.cpp:410
EntityResultVariable::Dematerialize
void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, lldb::addr_t frame_top, lldb::addr_t frame_bottom, Status &err) override
Definition: Materializer.cpp:982
EntityPersistentVariable::DestroyAllocation
void DestroyAllocation(IRMemoryMap &map, Status &err)
Definition: Materializer.cpp:131
lldb_private::PersistentExpressionState
Definition: ExpressionVariable.h:203
lldb_private::IRMemoryMap::GetBestExecutionContextScope
ExecutionContextScope * GetBestExecutionContextScope() const
Definition: IRMemoryMap.cpp:256
lldb_private::ExecutionContextScope::CalculateProcess
virtual lldb::ProcessSP CalculateProcess()=0
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
EntityVariable::GetByteSize
llvm::Optional< uint64_t > GetByteSize(ExecutionContextScope *scope) const override
Returns size in bytes of the type associated with this variable.
Definition: Materializer.cpp:819
lldb_private::Materializer::Dematerializer::m_map
IRMemoryMap * m_map
Definition: Materializer.h:60
lldb_private::ExecutionContextScope::CalculateTarget
virtual lldb::TargetSP CalculateTarget()=0
EntitySymbol::m_symbol
Symbol m_symbol
Definition: Materializer.cpp:1306
lldb_private::Status::Clear
void Clear()
Clear the object state.
Definition: Status.cpp:167
lldb_private::DataExtractor::GetData
const void * GetData(lldb::offset_t *offset_ptr, lldb::offset_t length) const
Extract length bytes from *offset_ptr.
Definition: DataExtractor.h:337
ValueObjectVariable.h
lldb_private::IRMemoryMap::ReadPointerFromMemory
void ReadPointerFromMemory(lldb::addr_t *address, lldb::addr_t process_address, Status &error)
Definition: IRMemoryMap.cpp:758
EntityVariable::GetName
ConstString GetName() const override
Definition: Materializer.cpp:811
lldb_private::Log
Definition: Log.h:115
lldb_private::ValueObjectVariable::Create
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
Definition: ValueObjectVariable.cpp:51
EntityValueObject::m_valobj_sp
lldb::ValueObjectSP m_valobj_sp
Definition: Materializer.cpp:886
lldb_private::PersistentExpressionState::CreatePersistentVariable
virtual lldb::ExpressionVariableSP CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp)=0
lldb_private::Materializer::m_entities
EntityVector m_entities
Definition: Materializer.h:150
Variable.h
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::Materializer::Dematerializer::IsValid
bool IsValid()
Definition: Materializer.h:39
lldb_private::DataExtractor::GetByteSize
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
Definition: DataExtractor.h:270
lldb_private::DataBufferHeap
Definition: DataBufferHeap.h:30
lldb_private::LLDBLog::Expressions
@ Expressions
EntityValueObject::GetTypeBitAlign
llvm::Optional< size_t > GetTypeBitAlign(ExecutionContextScope *scope) const override
Returns alignment of the type associated with this variable in bits.
Definition: Materializer.cpp:877
lldb_private::IRMemoryMap
Definition: IRMemoryMap.h:34
RegisterContext.h
lldb_private::Materializer::Dematerializer
Definition: Materializer.h:28
LLDBLog.h
ExecutionContext.h
g_default_var_byte_size
static constexpr uint32_t g_default_var_byte_size
Definition: Materializer.cpp:37
lldb_private::Materializer::m_struct_alignment
uint32_t m_struct_alignment
Definition: Materializer.h:152
lldb_private::Materializer::AddVariable
uint32_t AddVariable(lldb::VariableSP &variable_sp, Status &err)
Definition: Materializer.cpp:890
lldb_private::Status::AsCString
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
EntityRegister
Definition: Materializer.cpp:1317