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