9#ifndef LLDB_TARGET_PROCESSSTRUCTREADER_H
10#define LLDB_TARGET_PROCESSSTRUCTREADER_H
22#include "llvm/ADT/StringMap.h"
24#include <initializer_list>
53 for (
size_t idx = 0; idx < struct_type.
GetNumFields(); idx++) {
56 uint32_t bitfield_bit_size;
59 idx, name, &bit_offset, &bitfield_bit_size, &is_bitfield);
68 size_t size = *size_or_err;
73 size_t byte_index =
static_cast<size_t>(bit_offset / 8);
75 {name,
FieldImpl{field_type, byte_index,
static_cast<size_t>(size)}});
77 auto total_size_or_err = struct_type.
GetByteSize(
nullptr);
78 if (!total_size_or_err) {
83 size_t total_size = *total_size_or_err;
94 template <
typename RetType>
95 RetType
GetField(llvm::StringRef name, RetType fail_value = RetType()) {
99 auto size = iter->second.size;
100 if (
sizeof(RetType) < size)
103 if (offset + size >
m_data.GetByteSize())
105 return (RetType)(
m_data.GetMaxU64(&offset, size));
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG_ERROR(log, error,...)
Generic representation of a type in a programming language.
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
uint32_t GetNumFields() const
A subclass of DataBuffer that stores a data buffer on the heap.
lldb::ByteOrder m_byte_order
RetType GetField(llvm::StringRef name, RetType fail_value=RetType())
ProcessStructReader(Process *process, lldb::addr_t base_addr, CompilerType struct_type)
llvm::StringMap< FieldImpl > m_fields
A plug-in interface definition class for debugging a process.
size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
lldb::ByteOrder GetByteOrder() const
uint32_t GetAddressByteSize() const
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP