1 //===-- Value.cpp -----------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "lldb/Core/Value.h"
11 
12 #include "lldb/Core/Address.h"
13 #include "lldb/Core/Module.h"
14 #include "lldb/Symbol/CompilerType.h"
15 #include "lldb/Symbol/ObjectFile.h"
16 #include "lldb/Symbol/SymbolContext.h"
17 #include "lldb/Symbol/Type.h"
18 #include "lldb/Symbol/Variable.h"
19 #include "lldb/Target/ExecutionContext.h"
20 #include "lldb/Target/Process.h"
21 #include "lldb/Target/SectionLoadList.h"
22 #include "lldb/Target/Target.h"
23 #include "lldb/Utility/ConstString.h"
24 #include "lldb/Utility/DataBufferHeap.h"
25 #include "lldb/Utility/DataExtractor.h"
26 #include "lldb/Utility/Endian.h"
27 #include "lldb/Utility/FileSpec.h"
28 #include "lldb/Utility/State.h"
29 #include "lldb/Utility/Stream.h"
30 #include "lldb/lldb-defines.h"
31 #include "lldb/lldb-forward.h"
32 #include "lldb/lldb-types.h"
33 
34 #include <memory>
35 #include <string>
36 
37 #include <inttypes.h>
38 
39 using namespace lldb;
40 using namespace lldb_private;
41 
42 Value::Value()
43     : m_value(), m_vector(), m_compiler_type(), m_context(NULL),
44       m_value_type(eValueTypeScalar), m_context_type(eContextTypeInvalid),
45       m_data_buffer() {}
46 
47 Value::Value(const Scalar &scalar)
48     : m_value(scalar), m_vector(), m_compiler_type(), m_context(NULL),
49       m_value_type(eValueTypeScalar), m_context_type(eContextTypeInvalid),
50       m_data_buffer() {}
51 
52 Value::Value(const void *bytes, int len)
53     : m_value(), m_vector(), m_compiler_type(), m_context(NULL),
54       m_value_type(eValueTypeHostAddress), m_context_type(eContextTypeInvalid),
55       m_data_buffer() {
56   SetBytes(bytes, len);
57 }
58 
59 Value::Value(const Value &v)
60     : m_value(v.m_value), m_vector(v.m_vector),
61       m_compiler_type(v.m_compiler_type), m_context(v.m_context),
62       m_value_type(v.m_value_type), m_context_type(v.m_context_type),
63       m_data_buffer() {
64   const uintptr_t rhs_value =
65       (uintptr_t)v.m_value.ULongLong(LLDB_INVALID_ADDRESS);
66   if ((rhs_value != 0) &&
67       (rhs_value == (uintptr_t)v.m_data_buffer.GetBytes())) {
68     m_data_buffer.CopyData(v.m_data_buffer.GetBytes(),
69                            v.m_data_buffer.GetByteSize());
70 
71     m_value = (uintptr_t)m_data_buffer.GetBytes();
72   }
73 }
74 
75 Value &Value::operator=(const Value &rhs) {
76   if (this != &rhs) {
77     m_value = rhs.m_value;
78     m_vector = rhs.m_vector;
79     m_compiler_type = rhs.m_compiler_type;
80     m_context = rhs.m_context;
81     m_value_type = rhs.m_value_type;
82     m_context_type = rhs.m_context_type;
83     const uintptr_t rhs_value =
84         (uintptr_t)rhs.m_value.ULongLong(LLDB_INVALID_ADDRESS);
85     if ((rhs_value != 0) &&
86         (rhs_value == (uintptr_t)rhs.m_data_buffer.GetBytes())) {
87       m_data_buffer.CopyData(rhs.m_data_buffer.GetBytes(),
88                              rhs.m_data_buffer.GetByteSize());
89 
90       m_value = (uintptr_t)m_data_buffer.GetBytes();
91     }
92   }
93   return *this;
94 }
95 
96 void Value::SetBytes(const void *bytes, int len) {
97   m_value_type = eValueTypeHostAddress;
98   m_data_buffer.CopyData(bytes, len);
99   m_value = (uintptr_t)m_data_buffer.GetBytes();
100 }
101 
102 void Value::AppendBytes(const void *bytes, int len) {
103   m_value_type = eValueTypeHostAddress;
104   m_data_buffer.AppendData(bytes, len);
105   m_value = (uintptr_t)m_data_buffer.GetBytes();
106 }
107 
108 void Value::Dump(Stream *strm) {
109   m_value.GetValue(strm, true);
110   strm->Printf(", value_type = %s, context = %p, context_type = %s",
111                Value::GetValueTypeAsCString(m_value_type), m_context,
112                Value::GetContextTypeAsCString(m_context_type));
113 }
114 
115 Value::ValueType Value::GetValueType() const { return m_value_type; }
116 
117 AddressType Value::GetValueAddressType() const {
118   switch (m_value_type) {
119   default:
120   case eValueTypeScalar:
121     break;
122   case eValueTypeLoadAddress:
123     return eAddressTypeLoad;
124   case eValueTypeFileAddress:
125     return eAddressTypeFile;
126   case eValueTypeHostAddress:
127     return eAddressTypeHost;
128   }
129   return eAddressTypeInvalid;
130 }
131 
132 RegisterInfo *Value::GetRegisterInfo() const {
133   if (m_context_type == eContextTypeRegisterInfo)
134     return static_cast<RegisterInfo *>(m_context);
135   return NULL;
136 }
137 
138 Type *Value::GetType() {
139   if (m_context_type == eContextTypeLLDBType)
140     return static_cast<Type *>(m_context);
141   return NULL;
142 }
143 
144 size_t Value::AppendDataToHostBuffer(const Value &rhs) {
145   if (this == &rhs)
146     return 0;
147 
148   size_t curr_size = m_data_buffer.GetByteSize();
149   Status error;
150   switch (rhs.GetValueType()) {
151   case eValueTypeScalar: {
152     const size_t scalar_size = rhs.m_value.GetByteSize();
153     if (scalar_size > 0) {
154       const size_t new_size = curr_size + scalar_size;
155       if (ResizeData(new_size) == new_size) {
156         rhs.m_value.GetAsMemoryData(m_data_buffer.GetBytes() + curr_size,
157                                     scalar_size, endian::InlHostByteOrder(),
158                                     error);
159         return scalar_size;
160       }
161     }
162   } break;
163   case eValueTypeVector: {
164     const size_t vector_size = rhs.m_vector.length;
165     if (vector_size > 0) {
166       const size_t new_size = curr_size + vector_size;
167       if (ResizeData(new_size) == new_size) {
168         ::memcpy(m_data_buffer.GetBytes() + curr_size, rhs.m_vector.bytes,
169                  vector_size);
170         return vector_size;
171       }
172     }
173   } break;
174   case eValueTypeFileAddress:
175   case eValueTypeLoadAddress:
176   case eValueTypeHostAddress: {
177     const uint8_t *src = rhs.GetBuffer().GetBytes();
178     const size_t src_len = rhs.GetBuffer().GetByteSize();
179     if (src && src_len > 0) {
180       const size_t new_size = curr_size + src_len;
181       if (ResizeData(new_size) == new_size) {
182         ::memcpy(m_data_buffer.GetBytes() + curr_size, src, src_len);
183         return src_len;
184       }
185     }
186   } break;
187   }
188   return 0;
189 }
190 
191 size_t Value::ResizeData(size_t len) {
192   m_value_type = eValueTypeHostAddress;
193   m_data_buffer.SetByteSize(len);
194   m_value = (uintptr_t)m_data_buffer.GetBytes();
195   return m_data_buffer.GetByteSize();
196 }
197 
198 bool Value::ValueOf(ExecutionContext *exe_ctx) {
199   switch (m_context_type) {
200   case eContextTypeInvalid:
201   case eContextTypeRegisterInfo: // RegisterInfo *
202   case eContextTypeLLDBType:     // Type *
203     break;
204 
205   case eContextTypeVariable: // Variable *
206     ResolveValue(exe_ctx);
207     return true;
208   }
209   return false;
210 }
211 
212 uint64_t Value::GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx) {
213   uint64_t byte_size = 0;
214 
215   switch (m_context_type) {
216   case eContextTypeRegisterInfo: // RegisterInfo *
217     if (GetRegisterInfo())
218       byte_size = GetRegisterInfo()->byte_size;
219     break;
220 
221   case eContextTypeInvalid:
222   case eContextTypeLLDBType: // Type *
223   case eContextTypeVariable: // Variable *
224   {
225     const CompilerType &ast_type = GetCompilerType();
226     if (ast_type.IsValid())
227       if (llvm::Optional<uint64_t> size = ast_type.GetByteSize(
228               exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr))
229         byte_size = *size;
230   } break;
231   }
232 
233   if (error_ptr) {
234     if (byte_size == 0) {
235       if (error_ptr->Success())
236         error_ptr->SetErrorString("Unable to determine byte size.");
237     } else {
238       error_ptr->Clear();
239     }
240   }
241   return byte_size;
242 }
243 
244 const CompilerType &Value::GetCompilerType() {
245   if (!m_compiler_type.IsValid()) {
246     switch (m_context_type) {
247     case eContextTypeInvalid:
248       break;
249 
250     case eContextTypeRegisterInfo:
251       break; // TODO: Eventually convert into a compiler type?
252 
253     case eContextTypeLLDBType: {
254       Type *lldb_type = GetType();
255       if (lldb_type)
256         m_compiler_type = lldb_type->GetForwardCompilerType();
257     } break;
258 
259     case eContextTypeVariable: {
260       Variable *variable = GetVariable();
261       if (variable) {
262         Type *variable_type = variable->GetType();
263         if (variable_type)
264           m_compiler_type = variable_type->GetForwardCompilerType();
265       }
266     } break;
267     }
268   }
269 
270   return m_compiler_type;
271 }
272 
273 void Value::SetCompilerType(const CompilerType &compiler_type) {
274   m_compiler_type = compiler_type;
275 }
276 
277 lldb::Format Value::GetValueDefaultFormat() {
278   switch (m_context_type) {
279   case eContextTypeRegisterInfo:
280     if (GetRegisterInfo())
281       return GetRegisterInfo()->format;
282     break;
283 
284   case eContextTypeInvalid:
285   case eContextTypeLLDBType:
286   case eContextTypeVariable: {
287     const CompilerType &ast_type = GetCompilerType();
288     if (ast_type.IsValid())
289       return ast_type.GetFormat();
290   } break;
291   }
292 
293   // Return a good default in case we can't figure anything out
294   return eFormatHex;
295 }
296 
297 bool Value::GetData(DataExtractor &data) {
298   switch (m_value_type) {
299   default:
300     break;
301 
302   case eValueTypeScalar:
303     if (m_value.GetData(data))
304       return true;
305     break;
306 
307   case eValueTypeLoadAddress:
308   case eValueTypeFileAddress:
309   case eValueTypeHostAddress:
310     if (m_data_buffer.GetByteSize()) {
311       data.SetData(m_data_buffer.GetBytes(), m_data_buffer.GetByteSize(),
312                    data.GetByteOrder());
313       return true;
314     }
315     break;
316   }
317 
318   return false;
319 }
320 
321 Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
322                              uint32_t data_offset, Module *module) {
323   data.Clear();
324 
325   Status error;
326   lldb::addr_t address = LLDB_INVALID_ADDRESS;
327   AddressType address_type = eAddressTypeFile;
328   Address file_so_addr;
329   const CompilerType &ast_type = GetCompilerType();
330   switch (m_value_type) {
331   case eValueTypeVector:
332     if (ast_type.IsValid())
333       data.SetAddressByteSize(ast_type.GetPointerByteSize());
334     else
335       data.SetAddressByteSize(sizeof(void *));
336     data.SetData(m_vector.bytes, m_vector.length, m_vector.byte_order);
337     break;
338 
339   case eValueTypeScalar: {
340     data.SetByteOrder(endian::InlHostByteOrder());
341     if (ast_type.IsValid())
342       data.SetAddressByteSize(ast_type.GetPointerByteSize());
343     else
344       data.SetAddressByteSize(sizeof(void *));
345 
346     uint32_t limit_byte_size = UINT32_MAX;
347 
348     if (ast_type.IsValid()) {
349       if (llvm::Optional<uint64_t> size = ast_type.GetByteSize(
350               exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr))
351         limit_byte_size = *size;
352     }
353 
354     if (limit_byte_size <= m_value.GetByteSize()) {
355       if (m_value.GetData(data, limit_byte_size))
356         return error; // Success;
357     }
358 
359     error.SetErrorStringWithFormat("extracting data from value failed");
360     break;
361   }
362   case eValueTypeLoadAddress:
363     if (exe_ctx == NULL) {
364       error.SetErrorString("can't read load address (no execution context)");
365     } else {
366       Process *process = exe_ctx->GetProcessPtr();
367       if (process == NULL || !process->IsAlive()) {
368         Target *target = exe_ctx->GetTargetPtr();
369         if (target) {
370           // Allow expressions to run and evaluate things when the target has
371           // memory sections loaded. This allows you to use "target modules
372           // load" to load your executable and any shared libraries, then
373           // execute commands where you can look at types in data sections.
374           const SectionLoadList &target_sections = target->GetSectionLoadList();
375           if (!target_sections.IsEmpty()) {
376             address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
377             if (target_sections.ResolveLoadAddress(address, file_so_addr)) {
378               address_type = eAddressTypeLoad;
379               data.SetByteOrder(target->GetArchitecture().GetByteOrder());
380               data.SetAddressByteSize(
381                   target->GetArchitecture().GetAddressByteSize());
382             } else
383               address = LLDB_INVALID_ADDRESS;
384           }
385         } else {
386           error.SetErrorString("can't read load address (invalid process)");
387         }
388       } else {
389         address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
390         address_type = eAddressTypeLoad;
391         data.SetByteOrder(
392             process->GetTarget().GetArchitecture().GetByteOrder());
393         data.SetAddressByteSize(
394             process->GetTarget().GetArchitecture().GetAddressByteSize());
395       }
396     }
397     break;
398 
399   case eValueTypeFileAddress:
400     if (exe_ctx == NULL) {
401       error.SetErrorString("can't read file address (no execution context)");
402     } else if (exe_ctx->GetTargetPtr() == NULL) {
403       error.SetErrorString("can't read file address (invalid target)");
404     } else {
405       address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
406       if (address == LLDB_INVALID_ADDRESS) {
407         error.SetErrorString("invalid file address");
408       } else {
409         if (module == NULL) {
410           // The only thing we can currently lock down to a module so that we
411           // can resolve a file address, is a variable.
412           Variable *variable = GetVariable();
413           if (variable) {
414             SymbolContext var_sc;
415             variable->CalculateSymbolContext(&var_sc);
416             module = var_sc.module_sp.get();
417           }
418         }
419 
420         if (module) {
421           bool resolved = false;
422           ObjectFile *objfile = module->GetObjectFile();
423           if (objfile) {
424             Address so_addr(address, objfile->GetSectionList());
425             addr_t load_address =
426                 so_addr.GetLoadAddress(exe_ctx->GetTargetPtr());
427             bool process_launched_and_stopped =
428                 exe_ctx->GetProcessPtr()
429                     ? StateIsStoppedState(exe_ctx->GetProcessPtr()->GetState(),
430                                           true /* must_exist */)
431                     : false;
432             // Don't use the load address if the process has exited.
433             if (load_address != LLDB_INVALID_ADDRESS &&
434                 process_launched_and_stopped) {
435               resolved = true;
436               address = load_address;
437               address_type = eAddressTypeLoad;
438               data.SetByteOrder(
439                   exe_ctx->GetTargetRef().GetArchitecture().GetByteOrder());
440               data.SetAddressByteSize(exe_ctx->GetTargetRef()
441                                           .GetArchitecture()
442                                           .GetAddressByteSize());
443             } else {
444               if (so_addr.IsSectionOffset()) {
445                 resolved = true;
446                 file_so_addr = so_addr;
447                 data.SetByteOrder(objfile->GetByteOrder());
448                 data.SetAddressByteSize(objfile->GetAddressByteSize());
449               }
450             }
451           }
452           if (!resolved) {
453             Variable *variable = GetVariable();
454 
455             if (module) {
456               if (variable)
457                 error.SetErrorStringWithFormat(
458                     "unable to resolve the module for file address 0x%" PRIx64
459                     " for variable '%s' in %s",
460                     address, variable->GetName().AsCString(""),
461                     module->GetFileSpec().GetPath().c_str());
462               else
463                 error.SetErrorStringWithFormat(
464                     "unable to resolve the module for file address 0x%" PRIx64
465                     " in %s",
466                     address, module->GetFileSpec().GetPath().c_str());
467             } else {
468               if (variable)
469                 error.SetErrorStringWithFormat(
470                     "unable to resolve the module for file address 0x%" PRIx64
471                     " for variable '%s'",
472                     address, variable->GetName().AsCString(""));
473               else
474                 error.SetErrorStringWithFormat(
475                     "unable to resolve the module for file address 0x%" PRIx64,
476                     address);
477             }
478           }
479         } else {
480           // Can't convert a file address to anything valid without more
481           // context (which Module it came from)
482           error.SetErrorString(
483               "can't read memory from file address without more context");
484         }
485       }
486     }
487     break;
488 
489   case eValueTypeHostAddress:
490     address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
491     address_type = eAddressTypeHost;
492     if (exe_ctx) {
493       Target *target = exe_ctx->GetTargetPtr();
494       if (target) {
495         data.SetByteOrder(target->GetArchitecture().GetByteOrder());
496         data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
497         break;
498       }
499     }
500     // fallback to host settings
501     data.SetByteOrder(endian::InlHostByteOrder());
502     data.SetAddressByteSize(sizeof(void *));
503     break;
504   }
505 
506   // Bail if we encountered any errors
507   if (error.Fail())
508     return error;
509 
510   if (address == LLDB_INVALID_ADDRESS) {
511     error.SetErrorStringWithFormat("invalid %s address",
512                                    address_type == eAddressTypeHost ? "host"
513                                                                     : "load");
514     return error;
515   }
516 
517   // If we got here, we need to read the value from memory
518   size_t byte_size = GetValueByteSize(&error, exe_ctx);
519 
520   // Bail if we encountered any errors getting the byte size
521   if (error.Fail())
522     return error;
523 
524   // Make sure we have enough room within "data", and if we don't make
525   // something large enough that does
526   if (!data.ValidOffsetForDataOfSize(data_offset, byte_size)) {
527     auto data_sp =
528         std::make_shared<DataBufferHeap>(data_offset + byte_size, '\0');
529     data.SetData(data_sp);
530   }
531 
532   uint8_t *dst = const_cast<uint8_t *>(data.PeekData(data_offset, byte_size));
533   if (dst != NULL) {
534     if (address_type == eAddressTypeHost) {
535       // The address is an address in this process, so just copy it.
536       if (address == 0) {
537         error.SetErrorStringWithFormat(
538             "trying to read from host address of 0.");
539         return error;
540       }
541       memcpy(dst, reinterpret_cast<uint8_t *>(address), byte_size);
542     } else if ((address_type == eAddressTypeLoad) ||
543                (address_type == eAddressTypeFile)) {
544       if (file_so_addr.IsValid()) {
545         // We have a file address that we were able to translate into a section
546         // offset address so we might be able to read this from the object
547         // files if we don't have a live process. Lets always try and read from
548         // the process if we have one though since we want to read the actual
549         // value by setting "prefer_file_cache" to false.
550         const bool prefer_file_cache = false;
551         if (exe_ctx->GetTargetRef().ReadMemory(file_so_addr, prefer_file_cache,
552                                                dst, byte_size,
553                                                error) != byte_size) {
554           error.SetErrorStringWithFormat(
555               "read memory from 0x%" PRIx64 " failed", (uint64_t)address);
556         }
557       } else {
558         // The execution context might have a NULL process, but it might have a
559         // valid process in the exe_ctx->target, so use the
560         // ExecutionContext::GetProcess accessor to ensure we get the process
561         // if there is one.
562         Process *process = exe_ctx->GetProcessPtr();
563 
564         if (process) {
565           const size_t bytes_read =
566               process->ReadMemory(address, dst, byte_size, error);
567           if (bytes_read != byte_size)
568             error.SetErrorStringWithFormat(
569                 "read memory from 0x%" PRIx64 " failed (%u of %u bytes read)",
570                 (uint64_t)address, (uint32_t)bytes_read, (uint32_t)byte_size);
571         } else {
572           error.SetErrorStringWithFormat("read memory from 0x%" PRIx64
573                                          " failed (invalid process)",
574                                          (uint64_t)address);
575         }
576       }
577     } else {
578       error.SetErrorStringWithFormat("unsupported AddressType value (%i)",
579                                      address_type);
580     }
581   } else {
582     error.SetErrorStringWithFormat("out of memory");
583   }
584 
585   return error;
586 }
587 
588 Scalar &Value::ResolveValue(ExecutionContext *exe_ctx) {
589   const CompilerType &compiler_type = GetCompilerType();
590   if (compiler_type.IsValid()) {
591     switch (m_value_type) {
592     case eValueTypeScalar: // raw scalar value
593       break;
594 
595     default:
596     case eValueTypeFileAddress:
597     case eValueTypeLoadAddress: // load address value
598     case eValueTypeHostAddress: // host address value (for memory in the process
599                                 // that is using liblldb)
600     {
601       DataExtractor data;
602       lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS);
603       Status error(GetValueAsData(exe_ctx, data, 0, NULL));
604       if (error.Success()) {
605         Scalar scalar;
606         if (compiler_type.GetValueAsScalar(data, 0, data.GetByteSize(),
607                                            scalar)) {
608           m_value = scalar;
609           m_value_type = eValueTypeScalar;
610         } else {
611           if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes()) {
612             m_value.Clear();
613             m_value_type = eValueTypeScalar;
614           }
615         }
616       } else {
617         if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes()) {
618           m_value.Clear();
619           m_value_type = eValueTypeScalar;
620         }
621       }
622     } break;
623     }
624   }
625   return m_value;
626 }
627 
628 Variable *Value::GetVariable() {
629   if (m_context_type == eContextTypeVariable)
630     return static_cast<Variable *>(m_context);
631   return NULL;
632 }
633 
634 void Value::Clear() {
635   m_value.Clear();
636   m_vector.Clear();
637   m_compiler_type.Clear();
638   m_value_type = eValueTypeScalar;
639   m_context = NULL;
640   m_context_type = eContextTypeInvalid;
641   m_data_buffer.Clear();
642 }
643 
644 const char *Value::GetValueTypeAsCString(ValueType value_type) {
645   switch (value_type) {
646   case eValueTypeScalar:
647     return "scalar";
648   case eValueTypeVector:
649     return "vector";
650   case eValueTypeFileAddress:
651     return "file address";
652   case eValueTypeLoadAddress:
653     return "load address";
654   case eValueTypeHostAddress:
655     return "host address";
656   };
657   return "???";
658 }
659 
660 const char *Value::GetContextTypeAsCString(ContextType context_type) {
661   switch (context_type) {
662   case eContextTypeInvalid:
663     return "invalid";
664   case eContextTypeRegisterInfo:
665     return "RegisterInfo *";
666   case eContextTypeLLDBType:
667     return "Type *";
668   case eContextTypeVariable:
669     return "Variable *";
670   };
671   return "???";
672 }
673 
674 void Value::ConvertToLoadAddress(Module *module, Target *target) {
675   if (!module || !target || (GetValueType() != eValueTypeFileAddress))
676     return;
677 
678   lldb::addr_t file_addr = GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
679   if (file_addr == LLDB_INVALID_ADDRESS)
680     return;
681 
682   Address so_addr;
683   if (!module->ResolveFileAddress(file_addr, so_addr))
684     return;
685   lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
686   if (load_addr == LLDB_INVALID_ADDRESS)
687     return;
688 
689   SetValueType(Value::eValueTypeLoadAddress);
690   GetScalar() = load_addr;
691 }
692 
693 ValueList::ValueList(const ValueList &rhs) { m_values = rhs.m_values; }
694 
695 const ValueList &ValueList::operator=(const ValueList &rhs) {
696   m_values = rhs.m_values;
697   return *this;
698 }
699 
700 void ValueList::PushValue(const Value &value) { m_values.push_back(value); }
701 
702 size_t ValueList::GetSize() { return m_values.size(); }
703 
704 Value *ValueList::GetValueAtIndex(size_t idx) {
705   if (idx < GetSize()) {
706     return &(m_values[idx]);
707   } else
708     return NULL;
709 }
710 
711 void ValueList::Clear() { m_values.clear(); }
712