45 : m_value(scalar), m_compiler_type(), m_data_buffer() {}
48 : m_value(), m_compiler_type(), m_value_type(
ValueType::HostAddress),
54 : m_value(v.m_value), m_compiler_type(v.m_compiler_type),
55 m_context(v.m_context), m_value_type(v.m_value_type),
56 m_context_type(v.m_context_type), m_data_buffer() {
57 const uintptr_t rhs_value =
59 if ((rhs_value != 0) &&
75 const uintptr_t rhs_value =
77 if ((rhs_value != 0) &&
102 strm->
Printf(
", value_type = %s, context = %p, context_type = %s",
125 switch (address_type) {
135 llvm_unreachable(
"Unexpected address type!");
161 if (scalar_size > 0) {
162 const size_t new_size = curr_size + scalar_size;
174 const uint8_t *src = rhs.
GetBuffer().GetBytes();
176 if (src && src_len > 0) {
177 const size_t new_size = curr_size + src_len;
179 ::memcpy(
m_data_buffer.GetBytes() + curr_size, src, src_len);
224 if (std::optional<uint64_t> size =
GetCompilerType().GetByteSize(scope)) {
232 if (error_ptr && error_ptr->
Success())
322 std::optional<uint64_t> type_size = ast_type.
GetByteSize(
325 if (type_size && *type_size == 0)
330 error.SetErrorString(
"invalid value");
342 limit_byte_size = *type_size;
349 error.SetErrorString(
"extracting data from value failed");
353 if (exe_ctx ==
nullptr) {
354 error.SetErrorString(
"can't read load address (no execution context)");
357 if (process ==
nullptr || !process->
IsAlive()) {
365 if (!target_sections.
IsEmpty()) {
376 error.SetErrorString(
"can't read load address (invalid process)");
390 if (exe_ctx ==
nullptr) {
391 error.SetErrorString(
"can't read file address (no execution context)");
393 error.SetErrorString(
"can't read file address (invalid target)");
397 error.SetErrorString(
"invalid file address");
399 if (module ==
nullptr) {
411 bool resolved =
false;
417 bool process_launched_and_stopped =
424 process_launched_and_stopped) {
426 address = load_address;
436 file_so_addr = so_addr;
447 error.SetErrorStringWithFormat(
448 "unable to resolve the module for file address 0x%" PRIx64
449 " for variable '%s' in %s",
453 error.SetErrorStringWithFormat(
454 "unable to resolve the module for file address 0x%" PRIx64
459 error.SetErrorStringWithFormat(
460 "unable to resolve the module for file address 0x%" PRIx64
461 " for variable '%s'",
464 error.SetErrorStringWithFormat(
465 "unable to resolve the module for file address 0x%" PRIx64,
472 error.SetErrorString(
473 "can't read memory from file address without more context");
501 error.SetErrorStringWithFormat(
"invalid %s address",
521 auto data_sp = std::make_shared<DataBufferHeap>(byte_size,
'\0');
525 uint8_t *dst =
const_cast<uint8_t *
>(data.
PeekData(0, byte_size));
526 if (dst !=
nullptr) {
530 error.SetErrorString(
"trying to read from host address of 0.");
533 memcpy(dst,
reinterpret_cast<uint8_t *
>(address), byte_size);
537 const bool force_live_memory =
true;
539 error, force_live_memory) !=
541 error.SetErrorStringWithFormat(
542 "read memory from 0x%" PRIx64
" failed", (uint64_t)address);
552 const size_t bytes_read =
554 if (bytes_read != byte_size)
555 error.SetErrorStringWithFormat(
556 "read memory from 0x%" PRIx64
" failed (%u of %u bytes read)",
559 error.SetErrorStringWithFormat(
"read memory from 0x%" PRIx64
560 " failed (invalid process)",
565 error.SetErrorStringWithFormat(
"unsupported AddressType value (%i)",
569 error.SetErrorString(
"out of memory");
591 if (
error.Success()) {
599 if ((uintptr_t)addr != (uintptr_t)
m_data_buffer.GetBytes()) {
605 if ((uintptr_t)addr != (uintptr_t)
m_data_buffer.GetBytes()) {
632 switch (value_type) {
638 return "file address";
640 return "load address";
642 return "host address";
644 llvm_unreachable(
"enum cases exhausted.");
648 switch (context_type) {
652 return "RegisterInfo *";
658 llvm_unreachable(
"enum cases exhausted.");
static llvm::raw_ostream & error(Stream &strm)
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
bool IsValid() const
Check if the object state is valid.
bool IsSectionOffset() const
Check if an address is section offset.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Generic representation of a type in a programming language.
bool GetValueAsScalar(const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, Scalar &value, ExecutionContextScope *exe_scope) const
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
size_t GetPointerByteSize() const
AST related queries.
lldb::Format GetFormat() const
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
lldb::offset_t GetByteSize() const override
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)
void CopyData(const void *src, lldb::offset_t src_len)
Makes a copy of the src_len bytes in src.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
Target * GetTargetPtr() const
Returns a pointer to the target object.
Target & GetTargetRef() const
Returns a reference to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
A class that describes an executable image and its associated object and symbol files.
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
A plug-in interface definition class for object file parsers.
virtual lldb::ByteOrder GetByteOrder() const =0
Gets whether endian swapping should occur when extracting data from this object file.
virtual uint32_t GetAddressByteSize() const =0
Gets the address size in bytes for the current object file.
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
A plug-in interface definition class for debugging a process.
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
lldb::StateType GetState()
Get accessor for the current process state.
virtual bool IsAlive()
Check if a process is still alive.
Target & GetTarget()
Get the target object pointer for this module.
size_t GetByteSize() const
unsigned long long ULongLong(unsigned long long fail_value=0) const
size_t GetAsMemoryData(void *dst, size_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
bool GetData(DataExtractor &data, size_t limit_byte_size=UINT32_MAX) const
void GetValue(Stream *s, bool show_type) const
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, bool allow_section_end=false) const
void Clear()
Clear the object state.
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
bool Success() const
Test for success condition.
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Defines a symbol context baton that can be handed other debug core functions.
lldb::ModuleSP module_sp
The Module for a given query.
SectionLoadList & GetSectionLoadList()
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)
const ArchSpec & GetArchitecture() const
CompilerType GetForwardCompilerType()
void PushValue(const Value &value)
Value * GetValueAtIndex(size_t idx)
const Scalar & GetScalar() const
void AppendBytes(const void *bytes, int len)
Status GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, Module *module)
RegisterInfo * GetRegisterInfo() const
ValueType
Type that describes Value::m_value.
@ HostAddress
A host address value (for memory in the process that < A is using liblldb).
@ FileAddress
A file address value.
@ LoadAddress
A load address value.
@ Scalar
A raw scalar value.
static ValueType GetValueTypeFromAddressType(AddressType address_type)
ContextType m_context_type
Value & operator=(const Value &rhs)
size_t AppendDataToHostBuffer(const Value &rhs)
ValueType GetValueType() const
void SetCompilerType(const CompilerType &compiler_type)
DataBufferHeap m_data_buffer
lldb::Format GetValueDefaultFormat()
static const char * GetValueTypeAsCString(ValueType context_type)
DataBufferHeap & GetBuffer()
Scalar & ResolveValue(ExecutionContext *exe_ctx)
uint64_t GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx)
void SetValueType(ValueType value_type)
CompilerType m_compiler_type
ContextType
Type that describes Value::m_context.
@ Variable
lldb_private::Variable *.
@ RegisterInfo
RegisterInfo * (can be a scalar or a vector register).
@ LLDBType
lldb_private::Type *.
bool GetData(DataExtractor &data)
AddressType GetValueAddressType() const
const CompilerType & GetCompilerType()
static const char * GetContextTypeAsCString(ContextType context_type)
void ConvertToLoadAddress(Module *module, Target *target)
Convert this value's file address to a load address, if possible.
size_t ResizeData(size_t len)
void SetBytes(const void *bytes, int len)
bool ValueOf(ExecutionContext *exe_ctx)
ConstString GetName() const
void CalculateSymbolContext(SymbolContext *sc)
#define LLDB_INVALID_ADDRESS
lldb::ByteOrder InlHostByteOrder()
A class that represents a running process on the host machine.
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
@ eAddressTypeFile
Address is an address as found in an object or symbol file.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
@ eAddressTypeHost
Address is an address in the process that is running this code.
Format
Display format definitions.