LLDB mainline
DataExtractor.cpp File Reference
#include "lldb/Utility/DataExtractor.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/UUID.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <array>
#include <cassert>
#include <cstdint>
#include <string>
#include <cctype>
#include <cinttypes>
#include <cstring>

Go to the source code of this file.

Functions

static uint16_t ReadInt16 (const unsigned char *ptr, offset_t offset)
static uint32_t ReadInt32 (const unsigned char *ptr, offset_t offset=0)
static uint64_t ReadInt64 (const unsigned char *ptr, offset_t offset=0)
static uint16_t ReadInt16 (const void *ptr)
template<typename T>
static T ReadSwap (const uint8_t *ptr, offset_t offset=0)
 Read a byte-swapped T from ptr + offset, which need not be aligned for T.
static uint64_t ReadMaxInt64 (const uint8_t *data, size_t byte_size, ByteOrder byte_order)
template<typename T>
static void * GetUInt (const DataExtractor &data, offset_t *offset_ptr, void *dst, uint32_t count)
 Implements DataExtractor::GetU16/GetU32/GetU64(offset_ptr, dst, count); see DataExtractor.h for the contract.

Function Documentation

◆ GetUInt()

template<typename T>
void * GetUInt ( const DataExtractor & data,
offset_t * offset_ptr,
void * dst,
uint32_t count )
static

Implements DataExtractor::GetU16/GetU32/GetU64(offset_ptr, dst, count); see DataExtractor.h for the contract.

data's buffer and dst are only byte-aligned, so every value is transferred with memcpy: loading or storing a T through a pointer that is not sizeof(T)-aligned is undefined behavior, and trips UBSan.

Definition at line 100 of file DataExtractor.cpp.

References lldb_private::DataExtractor::GetByteOrder(), lldb_private::DataExtractor::GetData(), lldb_private::endian::InlHostByteOrder(), and ReadSwap().

Referenced by lldb_private::DataExtractor::GetU16(), lldb_private::DataExtractor::GetU32(), and lldb_private::DataExtractor::GetU64().

◆ ReadInt16() [1/2]

uint16_t ReadInt16 ( const unsigned char * ptr,
offset_t offset )
inlinestatic

◆ ReadInt16() [2/2]

uint16_t ReadInt16 ( const void * ptr)
inlinestatic

Definition at line 64 of file DataExtractor.cpp.

◆ ReadInt32()

uint32_t ReadInt32 ( const unsigned char * ptr,
offset_t offset = 0 )
inlinestatic

Definition at line 50 of file DataExtractor.cpp.

Referenced by lldb_private::DataExtractor::GetU32_unchecked().

◆ ReadInt64()

uint64_t ReadInt64 ( const unsigned char * ptr,
offset_t offset = 0 )
inlinestatic

Definition at line 57 of file DataExtractor.cpp.

Referenced by lldb_private::DataExtractor::GetU64_unchecked().

◆ ReadMaxInt64()

uint64_t ReadMaxInt64 ( const uint8_t * data,
size_t byte_size,
ByteOrder byte_order )
inlinestatic

◆ ReadSwap()

template<typename T>
T ReadSwap ( const uint8_t * ptr,
offset_t offset = 0 )
inlinestatic