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) &&
104 strm->
Printf(
", value_type = %s, context = %p, context_type = %s",
127 switch (address_type) {
137 llvm_unreachable(
"Unexpected address type!");
163 if (scalar_size > 0) {
164 const size_t new_size = curr_size + scalar_size;
178 if (src && src_len > 0) {
179 const size_t new_size = curr_size + src_len;
226 if (std::optional<uint64_t> size =
GetCompilerType().GetByteSize(scope)) {
234 if (error_ptr && error_ptr->
Success())
324 std::optional<uint64_t> type_size = ast_type.
GetByteSize(
327 if (type_size && *type_size == 0)
332 error.SetErrorString(
"invalid value");
344 limit_byte_size = *type_size;
351 error.SetErrorString(
"extracting data from value failed");
355 if (exe_ctx ==
nullptr) {
356 error.SetErrorString(
"can't read load address (no execution context)");
359 if (process ==
nullptr || !process->
IsAlive()) {
367 if (!target_sections.
IsEmpty()) {
378 error.SetErrorString(
"can't read load address (invalid process)");
392 if (exe_ctx ==
nullptr) {
393 error.SetErrorString(
"can't read file address (no execution context)");
395 error.SetErrorString(
"can't read file address (invalid target)");
399 error.SetErrorString(
"invalid file address");
401 if (module ==
nullptr) {
413 bool resolved =
false;
419 bool process_launched_and_stopped =
426 process_launched_and_stopped) {
428 address = load_address;
438 file_so_addr = so_addr;
449 error.SetErrorStringWithFormat(
450 "unable to resolve the module for file address 0x%" PRIx64
451 " for variable '%s' in %s",
455 error.SetErrorStringWithFormat(
456 "unable to resolve the module for file address 0x%" PRIx64
461 error.SetErrorStringWithFormat(
462 "unable to resolve the module for file address 0x%" PRIx64
463 " for variable '%s'",
466 error.SetErrorStringWithFormat(
467 "unable to resolve the module for file address 0x%" PRIx64,
474 error.SetErrorString(
475 "can't read memory from file address without more context");
503 error.SetErrorStringWithFormat(
"invalid %s address",
523 auto data_sp = std::make_shared<DataBufferHeap>(byte_size,
'\0');
527 uint8_t *dst =
const_cast<uint8_t *
>(data.
PeekData(0, byte_size));
528 if (dst !=
nullptr) {
532 error.SetErrorString(
"trying to read from host address of 0.");
535 memcpy(dst,
reinterpret_cast<uint8_t *
>(address), byte_size);
539 const bool force_live_memory =
true;
541 error, force_live_memory) !=
543 error.SetErrorStringWithFormat(
544 "read memory from 0x%" PRIx64
" failed", (uint64_t)address);
554 const size_t bytes_read =
556 if (bytes_read != byte_size)
557 error.SetErrorStringWithFormat(
558 "read memory from 0x%" PRIx64
" failed (%u of %u bytes read)",
559 (uint64_t)address, (uint32_t)bytes_read, (uint32_t)byte_size);
561 error.SetErrorStringWithFormat(
"read memory from 0x%" PRIx64
562 " failed (invalid process)",
567 error.SetErrorStringWithFormat(
"unsupported AddressType value (%i)",
571 error.SetErrorString(
"out of memory");
593 if (
error.Success()) {
634 switch (value_type) {
640 return "file address";
642 return "load address";
644 return "host address";
646 llvm_unreachable(
"enum cases exhausted.");
650 switch (context_type) {
654 return "RegisterInfo *";
660 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
Get the number of bytes in the data buffer.
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.
void GetValue(Stream &s, bool show_type) const
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
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()
virtual 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()
Scalar & ResolveValue(ExecutionContext *exe_ctx, Module *module=nullptr)
static const char * GetValueTypeAsCString(ValueType context_type)
DataBufferHeap & GetBuffer()
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)
uint8_t * GetBytes()
Get a pointer to the data.
#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.
Every register is described in detail including its name, alternate name (optional),...
uint32_t byte_size
Size in bytes of the register.
lldb::Format format
Default display format.