LLDB  mainline
Value.cpp
Go to the documentation of this file.
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"
14 #include "lldb/Symbol/ObjectFile.h"
16 #include "lldb/Symbol/Type.h"
17 #include "lldb/Symbol/Variable.h"
19 #include "lldb/Target/Process.h"
21 #include "lldb/Target/Target.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(NULL),
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(NULL),
49  m_data_buffer() {}
50 
51 Value::Value(const void *bytes, int len)
52  : m_value(), m_vector(), m_compiler_type(), m_context(NULL),
54  m_data_buffer() {
55  SetBytes(bytes, len);
56 }
57 
62  m_data_buffer() {
63  const uintptr_t rhs_value =
65  if ((rhs_value != 0) &&
66  (rhs_value == (uintptr_t)v.m_data_buffer.GetBytes())) {
69 
70  m_value = (uintptr_t)m_data_buffer.GetBytes();
71  }
72 }
73 
75  if (this != &rhs) {
76  m_value = rhs.m_value;
77  m_vector = rhs.m_vector;
79  m_context = rhs.m_context;
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())) {
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) {
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) {
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",
112 }
113 
115 
117  switch (m_value_type) {
118  default:
119  case eValueTypeScalar:
120  break;
122  return eAddressTypeLoad;
124  return eAddressTypeFile;
126  return eAddressTypeHost;
127  }
128  return eAddressTypeInvalid;
129 }
130 
131 RegisterInfo *Value::GetRegisterInfo() const {
133  return static_cast<RegisterInfo *>(m_context);
134  return NULL;
135 }
136 
139  return static_cast<Type *>(m_context);
140  return NULL;
141 }
142 
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;
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) {
193  m_value = (uintptr_t)m_data_buffer.GetBytes();
194  return m_data_buffer.GetByteSize();
195 }
196 
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 
240  if (!m_compiler_type.IsValid()) {
241  switch (m_context_type) {
242  case eContextTypeInvalid:
243  break;
244 
246  break; // TODO: Eventually convert into a compiler type?
247 
248  case eContextTypeLLDBType: {
249  Type *lldb_type = GetType();
250  if (lldb_type)
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 
273  switch (m_context_type) {
275  if (GetRegisterInfo())
276  return GetRegisterInfo()->format;
277  break;
278 
279  case eContextTypeInvalid:
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 
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 
305  if (m_data_buffer.GetByteSize()) {
307  data.GetByteOrder());
308  return true;
309  }
310  break;
311  }
312 
313  return false;
314 }
315 
317  uint32_t data_offset, Module *module) {
318  data.Clear();
319 
320  Status error;
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 *));
332  break;
333 
334  case eValueTypeScalar: {
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  }
356  if (exe_ctx == NULL) {
357  error.SetErrorString("can't read load address (no execution context)");
358  } else {
359  Process *process = exe_ctx->GetProcessPtr();
360  if (process == NULL || !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()) {
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 {
383  address_type = eAddressTypeLoad;
384  data.SetByteOrder(
385  process->GetTarget().GetArchitecture().GetByteOrder());
386  data.SetAddressByteSize(
388  }
389  }
390  break;
391 
393  if (exe_ctx == NULL) {
394  error.SetErrorString("can't read file address (no execution context)");
395  } else if (exe_ctx->GetTargetPtr() == NULL) {
396  error.SetErrorString("can't read file address (invalid target)");
397  } else {
399  if (address == LLDB_INVALID_ADDRESS) {
400  error.SetErrorString("invalid file address");
401  } else {
402  if (module == NULL) {
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()
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)
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
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)
463  "unable to resolve the module for file address 0x%" PRIx64
464  " for variable '%s'",
465  address, variable->GetName().AsCString(""));
466  else
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 
484  address_type = eAddressTypeHost;
485  if (exe_ctx) {
486  Target *target = exe_ctx->GetTargetPtr();
487  if (target) {
488  data.SetByteOrder(target->GetArchitecture().GetByteOrder());
490  break;
491  }
492  }
493  // fallback to host settings
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 != NULL) {
531  if (address_type == eAddressTypeHost) {
532  // The address is an address in this process, so just copy it.
533  if (address == 0) {
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) {
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)
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 
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:
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;
600  Status error(GetValueAsData(exe_ctx, data, 0, NULL));
601  if (error.Success()) {
602  Scalar scalar;
603  if (compiler_type.GetValueAsScalar(data, 0, data.GetByteSize(),
604  scalar)) {
605  m_value = scalar;
607  } else {
608  if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes()) {
609  m_value.Clear();
611  }
612  }
613  } else {
614  if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes()) {
615  m_value.Clear();
617  }
618  }
619  } break;
620  }
621  }
622  return m_value;
623 }
624 
627  return static_cast<Variable *>(m_context);
628  return NULL;
629 }
630 
631 void Value::Clear() {
632  m_value.Clear();
633  m_vector.Clear();
636  m_context = NULL;
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";
648  return "file address";
650  return "load address";
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";
662  return "RegisterInfo *";
664  return "Type *";
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 
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 
687  GetScalar() = load_addr;
688 }
689 
690 ValueList::ValueList(const ValueList &rhs) { m_values = rhs.m_values; }
691 
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 
702  if (idx < GetSize()) {
703  return &(m_values[idx]);
704  } else
705  return NULL;
706 }
707 
708 void ValueList::Clear() { m_values.clear(); }
An data extractor class.
Definition: DataExtractor.h:47
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
const ArchSpec & GetArchitecture() const
Definition: Target.h:941
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:224
static const char * GetValueTypeAsCString(ValueType context_type)
Definition: Value.cpp:641
size_t GetByteSize() const
Definition: Scalar.cpp:187
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Address is an address as found in an object or symbol file.
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:531
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:742
ContextType m_context_type
Definition: Value.h:243
void Dump(Stream *strm)
Definition: Value.cpp:107
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:292
Value & operator=(const Value &rhs)
Definition: Value.cpp:74
size_t GetAsMemoryData(void *dst, size_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
Definition: Scalar.cpp:2650
RegisterInfo * GetRegisterInfo() const
Definition: Value.cpp:131
bool ValueOf(ExecutionContext *exe_ctx)
Definition: Value.cpp:197
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition: Module.cpp:1251
lldb::Format GetFormat() const
lldb::offset_t SetByteSize(lldb::offset_t byte_size)
Set the number of bytes in the data buffer.
void AppendData(const void *src, uint64_t src_len)
size_t GetPointerByteSize() const
lldb::StateType GetState()
Get accessor for the current process state.
Definition: Process.cpp:1347
Status GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, uint32_t data_offset, Module *module)
Definition: Value.cpp:316
bool GetData(DataExtractor &data, size_t limit_byte_size=UINT32_MAX) const
Definition: Scalar.cpp:77
lldb::ByteOrder byte_order
Definition: Value.h:82
void ConvertToLoadAddress(Module *module, Target *target)
Convert this value&#39;s file address to a load address, if possible.
Definition: Value.cpp:671
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:58
Value * GetValueAtIndex(size_t idx)
Definition: Value.cpp:701
void SetValueType(ValueType value_type)
Definition: Value.h:154
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void SetAddressByteSize(uint32_t addr_size)
Set the address byte size.
void AppendBytes(const void *bytes, int len)
Definition: Value.cpp:101
llvm::Optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
const ValueList & operator=(const ValueList &rhs)
Definition: Value.cpp:692
void GetValue(Stream *s, bool show_type) const
Definition: Scalar.cpp:240
lldb::Format GetValueDefaultFormat()
Definition: Value.cpp:272
void SetBytes(const void *bytes, int len)
Definition: Value.cpp:95
ConstString GetName() const
Definition: Variable.cpp:64
#define UINT32_MAX
Definition: lldb-defines.h:31
ValueType GetValueType() const
Definition: Value.cpp:114
Target * GetTargetPtr() const
Returns a pointer to the target object.
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
Definition: State.cpp:89
Address is an address in the process that is running this code.
Type * GetType()
Definition: Value.cpp:137
void Clear()
Clears the object state.
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1012
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:109
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
static const char * GetContextTypeAsCString(ContextType context_type)
Definition: Value.cpp:657
size_t AppendDataToHostBuffer(const Value &rhs)
Definition: Value.cpp:143
void Clear()
Clear the object state.
Definition: Status.cpp:167
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
Definition: Module.cpp:426
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:605
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition: Scalar.cpp:1566
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, bool allow_section_end=false) const
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:241
bool GetData(DataExtractor &data)
Definition: Value.cpp:292
A plug-in interface definition class for debugging a process.
Definition: Process.h:353
Process * GetProcessPtr() const
Returns a pointer to the process object.
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition: ArchSpec.cpp:788
void CalculateSymbolContext(SymbolContext *sc)
Definition: Variable.cpp:212
bool ValidOffsetForDataOfSize(lldb::offset_t offset, lldb::offset_t length) const
Test the availability of length bytes of data from offset.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
bool Success() const
Test for success condition.
Definition: Status.cpp:287
const CompilerType & GetCompilerType()
Definition: Value.cpp:239
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:343
A section + offset based address class.
Definition: Address.h:80
CompilerType GetForwardCompilerType()
Definition: Type.cpp:610
DataBufferHeap m_data_buffer
Definition: Value.h:244
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
size_t ReadMemory(const Address &addr, bool prefer_file_cache, void *dst, size_t dst_len, Status &error, lldb::addr_t *load_addr_ptr=nullptr)
Definition: Target.cpp:1761
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1194
uint64_t addr_t
Definition: lldb-types.h:83
CompilerType m_compiler_type
Definition: Value.h:240
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
virtual bool IsAlive()
Check if a process is still alive.
Definition: Process.cpp:1182
Target & GetTargetRef() const
Returns a reference to the target object.
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SBAddress.h:15
uint64_t GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx)
Definition: Value.cpp:211
ValueType m_value_type
Definition: Value.h:242
uint8_t * GetBytes() override
size_t ResizeData(size_t len)
Definition: Value.cpp:190
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
void SetCompilerType(const CompilerType &compiler_type)
Definition: Value.cpp:268
lldb::ByteOrder InlHostByteOrder()
Definition: Endian.h:25
const Scalar & GetScalar() const
Definition: Value.h:178
virtual uint32_t GetAddressByteSize() const =0
Gets the address size in bytes for the current object file.
Address is an address as in the current target inferior process.
lldb::offset_t GetByteSize() const override
DataBufferHeap & GetBuffer()
Definition: Value.h:208
Scalar & ResolveValue(ExecutionContext *exe_ctx)
Definition: Value.cpp:585
AddressType GetValueAddressType() const
Definition: Value.cpp:116
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:376
ExecutionContextScope * GetBestExecutionContextScope() const
bool GetValueAsScalar(const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, Scalar &value) const
Variable * GetVariable()
Definition: Value.cpp:625
Scalar m_value
Definition: Value.h:238
void CopyData(const void *src, lldb::offset_t src_len)
Makes a copy of the src_len bytes in src.
Vector m_vector
Definition: Value.h:239
uint8_t bytes[kMaxByteSize]
Definition: Value.h:80
An error handling class.
Definition: Status.h:44
const uint8_t * PeekData(lldb::offset_t offset, lldb::offset_t length) const
Peek at a bytes at offset.
void PushValue(const Value &value)
Definition: Value.cpp:697
void SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition: Process.cpp:1966
virtual lldb::ByteOrder GetByteOrder() const =0
Gets whether endian swapping should occur when extracting data from this object file.
void * m_context
Definition: Value.h:241