LLDB  mainline
Value.cpp
Go to the documentation of this file.
1 //===-- Value.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 
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 <cinttypes>
37 
38 using namespace lldb;
39 using namespace lldb_private;
40 
41 Value::Value() : m_value(), m_compiler_type(), m_data_buffer() {}
42 
43 Value::Value(const Scalar &scalar)
44  : m_value(scalar), m_compiler_type(), m_context(nullptr),
45  m_value_type(ValueType::Scalar), m_context_type(ContextType::Invalid),
46  m_data_buffer() {}
47 
48 Value::Value(const void *bytes, int len)
49  : m_value(), m_compiler_type(), m_context(nullptr),
50  m_value_type(ValueType::HostAddress), m_context_type(ContextType::Invalid),
51  m_data_buffer() {
52  SetBytes(bytes, len);
53 }
54 
56  : m_value(v.m_value), m_compiler_type(v.m_compiler_type),
57  m_context(v.m_context), m_value_type(v.m_value_type),
58  m_context_type(v.m_context_type), m_data_buffer() {
59  const uintptr_t rhs_value =
61  if ((rhs_value != 0) &&
62  (rhs_value == (uintptr_t)v.m_data_buffer.GetBytes())) {
65 
66  m_value = (uintptr_t)m_data_buffer.GetBytes();
67  }
68 }
69 
71  if (this != &rhs) {
72  m_value = rhs.m_value;
74  m_context = rhs.m_context;
77  const uintptr_t rhs_value =
78  (uintptr_t)rhs.m_value.ULongLong(LLDB_INVALID_ADDRESS);
79  if ((rhs_value != 0) &&
80  (rhs_value == (uintptr_t)rhs.m_data_buffer.GetBytes())) {
83 
84  m_value = (uintptr_t)m_data_buffer.GetBytes();
85  }
86  }
87  return *this;
88 }
89 
90 void Value::SetBytes(const void *bytes, int len) {
92  m_data_buffer.CopyData(bytes, len);
93  m_value = (uintptr_t)m_data_buffer.GetBytes();
94 }
95 
96 void Value::AppendBytes(const void *bytes, int len) {
98  m_data_buffer.AppendData(bytes, len);
99  m_value = (uintptr_t)m_data_buffer.GetBytes();
100 }
101 
102 void Value::Dump(Stream *strm) {
103  m_value.GetValue(strm, true);
104  strm->Printf(", value_type = %s, context = %p, context_type = %s",
107 }
108 
110 
112  switch (m_value_type) {
113  case ValueType::Invalid:
114  case ValueType::Scalar:
115  break;
117  return eAddressTypeLoad;
119  return eAddressTypeFile;
121  return eAddressTypeHost;
122  }
123  return eAddressTypeInvalid;
124 }
125 
126 RegisterInfo *Value::GetRegisterInfo() const {
128  return static_cast<RegisterInfo *>(m_context);
129  return nullptr;
130 }
131 
134  return static_cast<Type *>(m_context);
135  return nullptr;
136 }
137 
139  if (this == &rhs)
140  return 0;
141 
142  size_t curr_size = m_data_buffer.GetByteSize();
143  Status error;
144  switch (rhs.GetValueType()) {
145  case ValueType::Invalid:
146  return 0;
147  case ValueType::Scalar: {
148  const size_t scalar_size = rhs.m_value.GetByteSize();
149  if (scalar_size > 0) {
150  const size_t new_size = curr_size + scalar_size;
151  if (ResizeData(new_size) == new_size) {
152  rhs.m_value.GetAsMemoryData(m_data_buffer.GetBytes() + curr_size,
153  scalar_size, endian::InlHostByteOrder(),
154  error);
155  return scalar_size;
156  }
157  }
158  } break;
161  case ValueType::HostAddress: {
162  const uint8_t *src = rhs.GetBuffer().GetBytes();
163  const size_t src_len = rhs.GetBuffer().GetByteSize();
164  if (src && src_len > 0) {
165  const size_t new_size = curr_size + src_len;
166  if (ResizeData(new_size) == new_size) {
167  ::memcpy(m_data_buffer.GetBytes() + curr_size, src, src_len);
168  return src_len;
169  }
170  }
171  } break;
172  }
173  return 0;
174 }
175 
176 size_t Value::ResizeData(size_t len) {
179  m_value = (uintptr_t)m_data_buffer.GetBytes();
180  return m_data_buffer.GetByteSize();
181 }
182 
184  switch (m_context_type) {
186  case ContextType::RegisterInfo: // RegisterInfo *
187  case ContextType::LLDBType: // Type *
188  break;
189 
190  case ContextType::Variable: // Variable *
191  ResolveValue(exe_ctx);
192  return true;
193  }
194  return false;
195 }
196 
197 uint64_t Value::GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx) {
198  switch (m_context_type) {
199  case ContextType::RegisterInfo: // RegisterInfo *
200  if (GetRegisterInfo()) {
201  if (error_ptr)
202  error_ptr->Clear();
203  return GetRegisterInfo()->byte_size;
204  }
205  break;
206 
208  case ContextType::LLDBType: // Type *
209  case ContextType::Variable: // Variable *
210  {
211  auto *scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
212  if (llvm::Optional<uint64_t> size = GetCompilerType().GetByteSize(scope)) {
213  if (error_ptr)
214  error_ptr->Clear();
215  return *size;
216  }
217  break;
218  }
219  }
220  if (error_ptr && error_ptr->Success())
221  error_ptr->SetErrorString("Unable to determine byte size.");
222  return 0;
223 }
224 
226  if (!m_compiler_type.IsValid()) {
227  switch (m_context_type) {
229  break;
230 
232  break; // TODO: Eventually convert into a compiler type?
233 
234  case ContextType::LLDBType: {
235  Type *lldb_type = GetType();
236  if (lldb_type)
238  } break;
239 
240  case ContextType::Variable: {
241  Variable *variable = GetVariable();
242  if (variable) {
243  Type *variable_type = variable->GetType();
244  if (variable_type)
245  m_compiler_type = variable_type->GetForwardCompilerType();
246  }
247  } break;
248  }
249  }
250 
251  return m_compiler_type;
252 }
253 
254 void Value::SetCompilerType(const CompilerType &compiler_type) {
255  m_compiler_type = compiler_type;
256 }
257 
259  switch (m_context_type) {
261  if (GetRegisterInfo())
262  return GetRegisterInfo()->format;
263  break;
264 
267  case ContextType::Variable: {
268  const CompilerType &ast_type = GetCompilerType();
269  if (ast_type.IsValid())
270  return ast_type.GetFormat();
271  } break;
272  }
273 
274  // Return a good default in case we can't figure anything out
275  return eFormatHex;
276 }
277 
279  switch (m_value_type) {
280  case ValueType::Invalid:
281  return false;
282  case ValueType::Scalar:
283  if (m_value.GetData(data))
284  return true;
285  break;
286 
290  if (m_data_buffer.GetByteSize()) {
292  data.GetByteOrder());
293  return true;
294  }
295  break;
296  }
297 
298  return false;
299 }
300 
302  Module *module) {
303  data.Clear();
304 
305  Status error;
307  AddressType address_type = eAddressTypeFile;
308  Address file_so_addr;
309  const CompilerType &ast_type = GetCompilerType();
310  llvm::Optional<uint64_t> type_size = ast_type.GetByteSize(
311  exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr);
312  // Nothing to be done for a zero-sized type.
313  if (type_size && *type_size == 0)
314  return error;
315 
316  switch (m_value_type) {
317  case ValueType::Invalid:
318  error.SetErrorString("invalid value");
319  break;
320  case ValueType::Scalar: {
322  if (ast_type.IsValid())
323  data.SetAddressByteSize(ast_type.GetPointerByteSize());
324  else
325  data.SetAddressByteSize(sizeof(void *));
326 
327  uint32_t limit_byte_size = UINT32_MAX;
328 
329  if (type_size)
330  limit_byte_size = *type_size;
331 
332  if (limit_byte_size <= m_value.GetByteSize()) {
333  if (m_value.GetData(data, limit_byte_size))
334  return error; // Success;
335  }
336 
337  error.SetErrorString("extracting data from value failed");
338  break;
339  }
341  if (exe_ctx == nullptr) {
342  error.SetErrorString("can't read load address (no execution context)");
343  } else {
344  Process *process = exe_ctx->GetProcessPtr();
345  if (process == nullptr || !process->IsAlive()) {
346  Target *target = exe_ctx->GetTargetPtr();
347  if (target) {
348  // Allow expressions to run and evaluate things when the target has
349  // memory sections loaded. This allows you to use "target modules
350  // load" to load your executable and any shared libraries, then
351  // execute commands where you can look at types in data sections.
352  const SectionLoadList &target_sections = target->GetSectionLoadList();
353  if (!target_sections.IsEmpty()) {
355  if (target_sections.ResolveLoadAddress(address, file_so_addr)) {
356  address_type = eAddressTypeLoad;
357  data.SetByteOrder(target->GetArchitecture().GetByteOrder());
358  data.SetAddressByteSize(
359  target->GetArchitecture().GetAddressByteSize());
360  } else
361  address = LLDB_INVALID_ADDRESS;
362  }
363  } else {
364  error.SetErrorString("can't read load address (invalid process)");
365  }
366  } else {
368  address_type = eAddressTypeLoad;
369  data.SetByteOrder(
370  process->GetTarget().GetArchitecture().GetByteOrder());
371  data.SetAddressByteSize(
373  }
374  }
375  break;
376 
378  if (exe_ctx == nullptr) {
379  error.SetErrorString("can't read file address (no execution context)");
380  } else if (exe_ctx->GetTargetPtr() == nullptr) {
381  error.SetErrorString("can't read file address (invalid target)");
382  } else {
384  if (address == LLDB_INVALID_ADDRESS) {
385  error.SetErrorString("invalid file address");
386  } else {
387  if (module == nullptr) {
388  // The only thing we can currently lock down to a module so that we
389  // can resolve a file address, is a variable.
390  Variable *variable = GetVariable();
391  if (variable) {
392  SymbolContext var_sc;
393  variable->CalculateSymbolContext(&var_sc);
394  module = var_sc.module_sp.get();
395  }
396  }
397 
398  if (module) {
399  bool resolved = false;
400  ObjectFile *objfile = module->GetObjectFile();
401  if (objfile) {
402  Address so_addr(address, objfile->GetSectionList());
403  addr_t load_address =
404  so_addr.GetLoadAddress(exe_ctx->GetTargetPtr());
405  bool process_launched_and_stopped =
406  exe_ctx->GetProcessPtr()
408  true /* must_exist */)
409  : false;
410  // Don't use the load address if the process has exited.
411  if (load_address != LLDB_INVALID_ADDRESS &&
412  process_launched_and_stopped) {
413  resolved = true;
414  address = load_address;
415  address_type = eAddressTypeLoad;
416  data.SetByteOrder(
417  exe_ctx->GetTargetRef().GetArchitecture().GetByteOrder());
418  data.SetAddressByteSize(exe_ctx->GetTargetRef()
419  .GetArchitecture()
420  .GetAddressByteSize());
421  } else {
422  if (so_addr.IsSectionOffset()) {
423  resolved = true;
424  file_so_addr = so_addr;
425  data.SetByteOrder(objfile->GetByteOrder());
426  data.SetAddressByteSize(objfile->GetAddressByteSize());
427  }
428  }
429  }
430  if (!resolved) {
431  Variable *variable = GetVariable();
432 
433  if (module) {
434  if (variable)
435  error.SetErrorStringWithFormat(
436  "unable to resolve the module for file address 0x%" PRIx64
437  " for variable '%s' in %s",
438  address, variable->GetName().AsCString(""),
439  module->GetFileSpec().GetPath().c_str());
440  else
441  error.SetErrorStringWithFormat(
442  "unable to resolve the module for file address 0x%" PRIx64
443  " in %s",
444  address, module->GetFileSpec().GetPath().c_str());
445  } else {
446  if (variable)
447  error.SetErrorStringWithFormat(
448  "unable to resolve the module for file address 0x%" PRIx64
449  " for variable '%s'",
450  address, variable->GetName().AsCString(""));
451  else
452  error.SetErrorStringWithFormat(
453  "unable to resolve the module for file address 0x%" PRIx64,
454  address);
455  }
456  }
457  } else {
458  // Can't convert a file address to anything valid without more
459  // context (which Module it came from)
460  error.SetErrorString(
461  "can't read memory from file address without more context");
462  }
463  }
464  }
465  break;
466 
469  address_type = eAddressTypeHost;
470  if (exe_ctx) {
471  Target *target = exe_ctx->GetTargetPtr();
472  if (target) {
473  data.SetByteOrder(target->GetArchitecture().GetByteOrder());
475  break;
476  }
477  }
478  // fallback to host settings
480  data.SetAddressByteSize(sizeof(void *));
481  break;
482  }
483 
484  // Bail if we encountered any errors
485  if (error.Fail())
486  return error;
487 
488  if (address == LLDB_INVALID_ADDRESS) {
489  error.SetErrorStringWithFormat("invalid %s address",
490  address_type == eAddressTypeHost ? "host"
491  : "load");
492  return error;
493  }
494 
495  // If we got here, we need to read the value from memory.
496  size_t byte_size = GetValueByteSize(&error, exe_ctx);
497 
498  // Bail if we encountered any errors getting the byte size.
499  if (error.Fail())
500  return error;
501 
502  // No memory to read for zero-sized types.
503  if (byte_size == 0)
504  return error;
505 
506  // Make sure we have enough room within "data", and if we don't make
507  // something large enough that does
508  if (!data.ValidOffsetForDataOfSize(0, byte_size)) {
509  auto data_sp = std::make_shared<DataBufferHeap>(byte_size, '\0');
510  data.SetData(data_sp);
511  }
512 
513  uint8_t *dst = const_cast<uint8_t *>(data.PeekData(0, byte_size));
514  if (dst != nullptr) {
515  if (address_type == eAddressTypeHost) {
516  // The address is an address in this process, so just copy it.
517  if (address == 0) {
518  error.SetErrorString("trying to read from host address of 0.");
519  return error;
520  }
521  memcpy(dst, reinterpret_cast<uint8_t *>(address), byte_size);
522  } else if ((address_type == eAddressTypeLoad) ||
523  (address_type == eAddressTypeFile)) {
524  if (file_so_addr.IsValid()) {
525  const bool force_live_memory = true;
526  if (exe_ctx->GetTargetRef().ReadMemory(file_so_addr, dst, byte_size,
527  error, force_live_memory) !=
528  byte_size) {
529  error.SetErrorStringWithFormat(
530  "read memory from 0x%" PRIx64 " failed", (uint64_t)address);
531  }
532  } else {
533  // The execution context might have a NULL process, but it might have a
534  // valid process in the exe_ctx->target, so use the
535  // ExecutionContext::GetProcess accessor to ensure we get the process
536  // if there is one.
537  Process *process = exe_ctx->GetProcessPtr();
538 
539  if (process) {
540  const size_t bytes_read =
541  process->ReadMemory(address, dst, byte_size, error);
542  if (bytes_read != byte_size)
543  error.SetErrorStringWithFormat(
544  "read memory from 0x%" PRIx64 " failed (%u of %u bytes read)",
545  (uint64_t)address, (uint32_t)bytes_read, (uint32_t)byte_size);
546  } else {
547  error.SetErrorStringWithFormat("read memory from 0x%" PRIx64
548  " failed (invalid process)",
549  (uint64_t)address);
550  }
551  }
552  } else {
553  error.SetErrorStringWithFormat("unsupported AddressType value (%i)",
554  address_type);
555  }
556  } else {
557  error.SetErrorString("out of memory");
558  }
559 
560  return error;
561 }
562 
564  const CompilerType &compiler_type = GetCompilerType();
565  if (compiler_type.IsValid()) {
566  switch (m_value_type) {
567  case ValueType::Invalid:
568  case ValueType::Scalar: // raw scalar value
569  break;
570 
572  case ValueType::LoadAddress: // load address value
573  case ValueType::HostAddress: // host address value (for memory in the process
574  // that is using liblldb)
575  {
576  DataExtractor data;
578  Status error(GetValueAsData(exe_ctx, data, nullptr));
579  if (error.Success()) {
580  Scalar scalar;
581  if (compiler_type.GetValueAsScalar(
582  data, 0, data.GetByteSize(), scalar,
583  exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)) {
584  m_value = scalar;
586  } else {
587  if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes()) {
588  m_value.Clear();
590  }
591  }
592  } else {
593  if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes()) {
594  m_value.Clear();
596  }
597  }
598  } break;
599  }
600  }
601  return m_value;
602 }
603 
606  return static_cast<Variable *>(m_context);
607  return nullptr;
608 }
609 
610 void Value::Clear() {
611  m_value.Clear();
614  m_context = nullptr;
617 }
618 
619 const char *Value::GetValueTypeAsCString(ValueType value_type) {
620  switch (value_type) {
621  case ValueType::Invalid:
622  return "invalid";
623  case ValueType::Scalar:
624  return "scalar";
626  return "file address";
628  return "load address";
630  return "host address";
631  };
632  llvm_unreachable("enum cases exhausted.");
633 }
634 
635 const char *Value::GetContextTypeAsCString(ContextType context_type) {
636  switch (context_type) {
638  return "invalid";
640  return "RegisterInfo *";
642  return "Type *";
644  return "Variable *";
645  };
646  llvm_unreachable("enum cases exhausted.");
647 }
648 
649 void Value::ConvertToLoadAddress(Module *module, Target *target) {
650  if (!module || !target || (GetValueType() != ValueType::FileAddress))
651  return;
652 
654  if (file_addr == LLDB_INVALID_ADDRESS)
655  return;
656 
657  Address so_addr;
658  if (!module->ResolveFileAddress(file_addr, so_addr))
659  return;
660  lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
661  if (load_addr == LLDB_INVALID_ADDRESS)
662  return;
663 
665  GetScalar() = load_addr;
666 }
667 
669 
671  m_values = rhs.m_values;
672  return *this;
673 }
674 
675 void ValueList::PushValue(const Value &value) { m_values.push_back(value); }
676 
677 size_t ValueList::GetSize() { return m_values.size(); }
678 
680  if (idx < GetSize()) {
681  return &(m_values[idx]);
682  } else
683  return nullptr;
684 }
685 
686 void ValueList::Clear() { m_values.clear(); }
lldb_private::CompilerType::GetValueAsScalar
bool GetValueAsScalar(const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, Scalar &value, ExecutionContextScope *exe_scope) const
Definition: CompilerType.cpp:780
lldb_private::Module::GetObjectFile
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition: Module.cpp:1238
lldb_private::Value::GetValueDefaultFormat
lldb::Format GetValueDefaultFormat()
Definition: Value.cpp:258
lldb_private::Value::ValueType::Scalar
@ Scalar
A raw scalar value.
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::ArchSpec::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition: ArchSpec.cpp:730
lldb_private::DataBufferHeap::GetBytes
uint8_t * GetBytes() override
Definition: DataBufferHeap.cpp:34
lldb_private::DataBufferHeap::GetByteSize
lldb::offset_t GetByteSize() const override
Definition: DataBufferHeap.cpp:45
lldb_private::Value::GetValueAddressType
AddressType GetValueAddressType() const
Definition: Value.cpp:111
lldb_private::Value::GetBuffer
DataBufferHeap & GetBuffer()
Definition: Value.h:120
lldb_private::CompilerContextKind::Invalid
@ Invalid
lldb_private::Value::ContextType::Variable
@ Variable
lldb_private::Variable *.
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:336
lldb_private::DataBufferHeap::AppendData
void AppendData(const void *src, uint64_t src_len)
Definition: DataBufferHeap.cpp:62
lldb_private::Process::ReadMemory
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:1914
lldb::Format
Format
Display format definitions.
Definition: lldb-enumerations.h:155
lldb_private::Scalar::GetData
bool GetData(DataExtractor &data, size_t limit_byte_size=UINT32_MAX) const
Definition: Scalar.cpp:84
lldb_private::DataBufferHeap::SetByteSize
lldb::offset_t SetByteSize(lldb::offset_t byte_size)
Set the number of bytes in the data buffer.
Definition: DataBufferHeap.cpp:49
lldb_private::Value::Clear
void Clear()
Definition: Value.cpp:610
lldb_private::Value
Definition: Value.h:38
lldb_private::Value::SetValueType
void SetValueType(ValueType value_type)
Definition: Value.h:89
lldb_private::ExecutionContext::GetProcessPtr
Process * GetProcessPtr() const
Returns a pointer to the process object.
Definition: ExecutionContext.cpp:208
lldb_private::Value::ContextType::LLDBType
@ LLDBType
lldb_private::Type *.
lldb_private::Value::GetValueAsData
Status GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, Module *module)
Definition: Value.cpp:301
lldb_private::Value::ValueType::Invalid
@ Invalid
lldb_private::Value::ValueType::FileAddress
@ FileAddress
A file address value.
lldb_private::Value::GetValueType
ValueType GetValueType() const
Definition: Value.cpp:109
lldb-defines.h
lldb_private::ValueList::GetValueAtIndex
Value * GetValueAtIndex(size_t idx)
Definition: Value.cpp:679
lldb_private::AddressType
AddressType
Definition: lldb-private-enumerations.h:30
lldb_private::Value::m_compiler_type
CompilerType m_compiler_type
Definition: Value.h:150
lldb_private::Scalar
Definition: Scalar.h:34
lldb_private::Process
Definition: Process.h:342
lldb_private::Scalar::GetAsMemoryData
size_t GetAsMemoryData(void *dst, size_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
Definition: Scalar.cpp:773
Module.h
lldb_private::eAddressTypeHost
@ eAddressTypeHost
Address is an address in the process that is running this code.
Definition: lldb-private-enumerations.h:36
lldb_private::DataBufferHeap::CopyData
void CopyData(const void *src, lldb::offset_t src_len)
Makes a copy of the src_len bytes in src.
Definition: DataBufferHeap.cpp:54
lldb_private::Process::GetTarget
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1214
lldb_private::DataExtractor::PeekData
const uint8_t * PeekData(lldb::offset_t offset, lldb::offset_t length) const
Peek at a bytes at offset.
Definition: DataExtractor.h:832
lldb_private::Module
Definition: Module.h:84
SectionLoadList.h
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:193
lldb_private::Value::ValueOf
bool ValueOf(ExecutionContext *exe_ctx)
Definition: Value.cpp:183
lldb_private::Value::ValueType::LoadAddress
@ LoadAddress
A load address value.
lldb_private::CompilerType::GetByteSize
llvm::Optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
Definition: CompilerType.cpp:489
lldb_private::ValueList
Definition: Value.h:157
lldb_private::Process::IsAlive
virtual bool IsAlive()
Check if a process is still alive.
Definition: Process.cpp:1085
lldb_private::Stream
Definition: Stream.h:28
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::Value::GetValueTypeAsCString
static const char * GetValueTypeAsCString(ValueType context_type)
Definition: Value.cpp:619
lldb_private::Variable::GetName
ConstString GetName() const
Definition: Variable.cpp:71
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:454
lldb_private::ValueList::GetSize
size_t GetSize()
Definition: Value.cpp:677
lldb_private::Value::m_context
void * m_context
Definition: Value.h:151
lldb_private::Value::operator=
Value & operator=(const Value &rhs)
Definition: Value.cpp:70
lldb_private::DataExtractor::SetData
lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
Definition: DataExtractor.cpp:225
lldb_private::Process::GetState
lldb::StateType GetState()
Get accessor for the current process state.
Definition: Process.cpp:1295
Process.h
lldb_private::Value::ContextType::Invalid
@ Invalid
Undefined.
lldb_private::Value::GetRegisterInfo
RegisterInfo * GetRegisterInfo() const
Definition: Value.cpp:126
lldb_private::Value::SetCompilerType
void SetCompilerType(const CompilerType &compiler_type)
Definition: Value.cpp:254
Target.h
lldb_private::DataExtractor::SetByteOrder
void SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
Definition: DataExtractor.h:931
lldb_private::Value::GetScalar
const Scalar & GetScalar() const
Definition: Value.h:112
lldb_private::Module::GetFileSpec
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:476
lldb_private::ValueList::m_values
collection m_values
Definition: Value.h:177
lldb_private::Value::m_value
Scalar m_value
Definition: Value.h:149
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ValueList::operator=
const ValueList & operator=(const ValueList &rhs)
Definition: Value.cpp:670
lldb_private::ObjectFile::GetSectionList
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:583
lldb_private::Status::Success
bool Success() const
Test for success condition.
Definition: Status.cpp:288
lldb_private::ValueList::PushValue
void PushValue(const Value &value)
Definition: Value.cpp:675
lldb_private::CompilerType::Clear
void Clear()
Definition: CompilerType.h:395
lldb_private::StateIsStoppedState
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
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::eAddressTypeInvalid
@ eAddressTypeInvalid
Definition: lldb-private-enumerations.h:31
lldb_private::Value::ConvertToLoadAddress
void ConvertToLoadAddress(Module *module, Target *target)
Convert this value's file address to a load address, if possible.
Definition: Value.cpp:649
lldb_private::Scalar::ULongLong
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition: Scalar.cpp:334
lldb_private::CompilerType::GetFormat
lldb::Format GetFormat() const
Definition: CompilerType.cpp:508
lldb_private::DataExtractor::SetAddressByteSize
void SetAddressByteSize(uint32_t addr_size)
Set the address byte size.
Definition: DataExtractor.h:845
Type.h
lldb_private::Value::m_value_type
ValueType m_value_type
Definition: Value.h:152
lldb_private::Module::ResolveFileAddress
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
Definition: Module.cpp:439
lldb_private::DataExtractor::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
Definition: DataExtractor.h:594
lldb_private::ObjectFile::GetByteOrder
virtual lldb::ByteOrder GetByteOrder() const =0
Gets whether endian swapping should occur when extracting data from this object file.
lldb_private::Scalar::Clear
void Clear()
Definition: Scalar.h:97
lldb_private::Value::AppendBytes
void AppendBytes(const void *bytes, int len)
Definition: Value.cpp:96
lldb_private::Value::ValueType
ValueType
Type that describes Value::m_value.
Definition: Value.h:41
lldb_private::Scalar::GetByteSize
size_t GetByteSize() const
Definition: Scalar.cpp:131
lldb_private::Value::m_data_buffer
DataBufferHeap m_data_buffer
Definition: Value.h:154
lldb_private::SectionLoadList
Definition: SectionLoadList.h:22
lldb_private::eAddressTypeLoad
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
Definition: lldb-private-enumerations.h:34
lldb_private::Value::GetContextTypeAsCString
static const char * GetContextTypeAsCString(ContextType context_type)
Definition: Value.cpp:635
lldb_private::SectionLoadList::ResolveLoadAddress
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, bool allow_section_end=false) const
Definition: SectionLoadList.cpp:208
CompilerType.h
Address.h
lldb_private::CompilerType::IsValid
bool IsValid() const
Definition: CompilerType.h:72
lldb_private::ArchSpec::GetAddressByteSize
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:683
ObjectFile.h
lldb_private::CompilerType::GetPointerByteSize
size_t GetPointerByteSize() const
AST related queries.
Definition: CompilerType.cpp:271
lldb_private::DataBufferHeap::Clear
void Clear()
Definition: DataBufferHeap.cpp:67
lldb-types.h
lldb_private::Value::ResolveValue
Scalar & ResolveValue(ExecutionContext *exe_ctx)
Definition: Value.cpp:563
lldb_private::Value::m_context_type
ContextType m_context_type
Definition: Value.h:153
lldb_private::SectionLoadList::IsEmpty
bool IsEmpty() const
Definition: SectionLoadList.cpp:37
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:970
lldb_private::Status
Definition: Status.h:44
lldb_private::Target::ReadMemory
size_t ReadMemory(const Address &addr, void *dst, size_t dst_len, Status &error, bool force_live_memory=false, lldb::addr_t *load_addr_ptr=nullptr)
Definition: Target.cpp:1721
uint32_t
lldb_private::ExecutionContext::GetBestExecutionContextScope
ExecutionContextScope * GetBestExecutionContextScope() const
Definition: ExecutionContext.cpp:216
lldb_private::Address
Definition: Address.h:59
lldb_private::Value::ValueType::HostAddress
@ HostAddress
A host address value (for memory in the process that < A is using liblldb).
lldb_private::Value::GetData
bool GetData(DataExtractor &data)
Definition: Value.cpp:278
lldb_private::endian::InlHostByteOrder
lldb::ByteOrder InlHostByteOrder()
Definition: Endian.h:25
lldb_private::eAddressTypeFile
@ eAddressTypeFile
Address is an address as found in an object or symbol file.
Definition: lldb-private-enumerations.h:32
lldb_private::Type
Definition: Type.h:66
lldb_private::Status::SetErrorString
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:242
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:310
lldb_private::Type::GetForwardCompilerType
CompilerType GetForwardCompilerType()
Definition: Type.cpp:656
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
lldb_private::Value::GetType
Type * GetType()
Definition: Value.cpp:132
lldb_private::ValueList::Clear
void Clear()
Definition: Value.cpp:686
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
lldb_private::Variable::CalculateSymbolContext
void CalculateSymbolContext(SymbolContext *sc)
Definition: Variable.cpp:216
lldb_private::Target::GetSectionLoadList
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1043
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
DataExtractor.h
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
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-forward.h
lldb_private::Value::GetCompilerType
const CompilerType & GetCompilerType()
Definition: Value.cpp:225
lldb_private::Value::ContextType::RegisterInfo
@ RegisterInfo
RegisterInfo * (can be a scalar or a vector register).
lldb_private::ExecutionContext::GetTargetRef
Target & GetTargetRef() const
Returns a reference to the target object.
Definition: ExecutionContext.cpp:226
SymbolContext.h
lldb_private::Value::SetBytes
void SetBytes(const void *bytes, int len)
Definition: Value.cpp:90
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::eFormatHex
@ eFormatHex
Definition: lldb-enumerations.h:169
lldb_private::ObjectFile::GetAddressByteSize
virtual uint32_t GetAddressByteSize() const =0
Gets the address size in bytes for the current object file.
lldb_private::Value::ResizeData
size_t ResizeData(size_t len)
Definition: Value.cpp:176
lldb_private::Value::GetVariable
Variable * GetVariable()
Definition: Value.cpp:604
lldb_private::Value::ContextType
ContextType
Type that describes Value::m_context.
Definition: Value.h:56
FileSpec.h
lldb_private::Address::IsSectionOffset
bool IsSectionOffset() const
Check if an address is section offset.
Definition: Address.h:323
lldb_private::Status::Clear
void Clear()
Clear the object state.
Definition: Status.cpp:168
ConstString.h
lldb_private::DataExtractor::Clear
void Clear()
Clears the object state.
Definition: DataExtractor.cpp:194
State.h
lldb_private::Variable::GetType
Type * GetType()
Definition: Variable.cpp:96
lldb_private::Value::GetValueByteSize
uint64_t GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx)
Definition: Value.cpp:197
Stream.h
lldb_private::Variable
Definition: Variable.h:25
lldb_private::Value::Dump
void Dump(Stream *strm)
Definition: Value.cpp:102
Variable.h
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:348
lldb_private::DataExtractor::GetByteSize
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
Definition: DataExtractor.h:270
lldb_private::DataExtractor::ValidOffsetForDataOfSize
bool ValidOffsetForDataOfSize(lldb::offset_t offset, lldb::offset_t length) const
Test the availability of length bytes of data from offset.
Definition: DataExtractor.h:965
lldb
Definition: SBAddress.h:15
Endian.h
Value.h
lldb_private::Value::Value
Value()
Definition: Value.cpp:41
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:200
lldb_private::ObjectFile
Definition: ObjectFile.h:58
lldb_private::Value::AppendDataToHostBuffer
size_t AppendDataToHostBuffer(const Value &rhs)
Definition: Value.cpp:138
ExecutionContext.h
DataBufferHeap.h
lldb_private::ValueList::ValueList
ValueList()
Definition: Value.h:159
lldb_private::Scalar::GetValue
void GetValue(Stream *s, bool show_type) const
Definition: Scalar.cpp:155