Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Functions | Variables
memory-access.h File Reference
#include <byteswap.h>
#include <limits.h>
#include <stdint.h>
Include dependency graph for memory-access.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  unaligned
 

Macros

#define get_uleb128_step(var, addr, nth, break)
 
#define get_uleb128(var, addr)
 
#define get_uleb128_rest_return(var, i, addrp)
 
#define get_sleb128_step(var, addr, nth, break)
 
#define get_sleb128(var, addr)
 
#define get_sleb128_rest_return(var, i, addrp)
 
#define read_2ubyte_unaligned(obo, Addr)   read_2ubyte_unaligned_1 ((obo), (Addr))
 
#define read_2sbyte_unaligned(obo, Addr)   read_2sbyte_unaligned_1 ((obo), (Addr))
 
#define read_4ubyte_unaligned(obo, Addr)   read_4ubyte_unaligned_1 ((obo), (Addr))
 
#define read_4sbyte_unaligned(obo, Addr)   read_4sbyte_unaligned_1 ((obo), (Addr))
 
#define read_8ubyte_unaligned(obo, Addr)   read_8ubyte_unaligned_1 ((obo), (Addr))
 
#define read_8sbyte_unaligned(obo, Addr)   read_8sbyte_unaligned_1 ((obo), (Addr))
 
#define read_ubyte_unaligned(Nbytes, obo, Addr)
 
#define read_sbyte_unaligned(Nbytes, obo, Addr)
 
#define read_2ubyte_unaligned_inc(obo, Addr)
 
#define read_2sbyte_unaligned_inc(obo, Addr)
 
#define read_4ubyte_unaligned_inc(obo, Addr)
 
#define read_4sbyte_unaligned_inc(obo, Addr)
 
#define read_8ubyte_unaligned_inc(obo, Addr)
 
#define read_8sbyte_unaligned_inc(obo, Addr)
 
#define read_ubyte_unaligned_inc(Nbytes, obo, Addr)
 
#define read_sbyte_unaligned_inc(Nbytes, obo, Addr)
 

Functions

 get_uleb128_rest_return (acc, i, addrp)
 
 get_sleb128_rest_return (acc, i, addrp)
 
union unaligned __attribute__ ((packed))
 

Variables

static uint64_t unsigned int i
 
static uint64_t unsigned int
const unsigned char ** 
addrp
 
int64_t _v = acc
 
void * p
 
uint16_t u2
 
uint32_t u4
 
uint64_t u8
 
int16_t s2
 
int32_t s4
 
int64_t s8
 

Macro Definition Documentation

#define get_sleb128 (   var,
  addr 
)
Value:
do { \
unsigned char __b; \
int64_t _v = 0; \
get_sleb128_step (var, addr, 0, break); \
var = __libdw_get_sleb128 (_v, 1, &(addr)); \
} while (0)
#define get_sleb128_step(var, addr, nth, break)
Definition: memory-access.h:88
int64_t _v

Definition at line 98 of file memory-access.h.

#define get_sleb128_rest_return (   var,
  i,
  addrp 
)
Value:
do { \
for (; i < 9; ++i) \
{ \
get_sleb128_step (var, *addrp, i, return var); \
} \
__b = *(*addrp)++; \
if (likely ((__b & 0x80) == 0)) \
return var | ((uint64_t) __b << 63); \
else \
/* Other implementations set VALUE to INT_MAX in this \
case. So we better do this as well. */ \
return INT64_MAX; \
} while (0)
static uint64_t unsigned int const unsigned char ** addrp
#define get_sleb128_step(var, addr, nth, break)
Definition: memory-access.h:88
static uint64_t unsigned int i
#define likely(expr)
Definition: debugpred.h:102

Definition at line 106 of file memory-access.h.

#define get_sleb128_step (   var,
  addr,
  nth,
  break 
)
Value:
__b = *(addr)++; \
_v |= (uint64_t) (__b & 0x7f) << (nth * 7); \
if (likely ((__b & 0x80) == 0)) \
{ \
var = (_v << (64 - (nth * 7) - 7)) >> (64 - (nth * 7) - 7); \
break; \
} \
else do {} while (0)
#define likely(expr)
Definition: debugpred.h:102
int64_t _v

Definition at line 88 of file memory-access.h.

#define get_uleb128 (   var,
  addr 
)
Value:
do { \
unsigned char __b; \
var = 0; \
get_uleb128_step (var, addr, 0, break); \
var = __libdw_get_uleb128 (var, 1, &(addr)); \
} while (0)
#define get_uleb128_step(var, addr, nth, break)
Definition: memory-access.h:61

Definition at line 67 of file memory-access.h.

#define get_uleb128_rest_return (   var,
  i,
  addrp 
)
Value:
do { \
for (; i < 10; ++i) \
{ \
get_uleb128_step (var, *addrp, i, return var); \
} \
/* Other implementations set VALUE to UINT_MAX in this \
case. So we better do this as well. */ \
return UINT64_MAX; \
} while (0)
static uint64_t unsigned int const unsigned char ** addrp
static uint64_t unsigned int i
#define get_uleb128_step(var, addr, nth, break)
Definition: memory-access.h:61

Definition at line 75 of file memory-access.h.

#define get_uleb128_step (   var,
  addr,
  nth,
  break 
)
Value:
__b = *(addr)++; \
var |= (uintmax_t) (__b & 0x7f) << (nth * 7); \
if (likely ((__b & 0x80) == 0)) \
break
#define likely(expr)
Definition: debugpred.h:102

Definition at line 61 of file memory-access.h.

#define read_2sbyte_unaligned (   obo,
  Addr 
)    read_2sbyte_unaligned_1 ((obo), (Addr))

Definition at line 195 of file memory-access.h.

#define read_2sbyte_unaligned_inc (   obo,
  Addr 
)
Value:
({ int16_t t_ = read_2sbyte_unaligned (obo, Addr); \
Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 2); \
t_; })
#define read_2sbyte_unaligned(obo, Addr)

Definition at line 281 of file memory-access.h.

#define read_2ubyte_unaligned (   obo,
  Addr 
)    read_2ubyte_unaligned_1 ((obo), (Addr))

Definition at line 193 of file memory-access.h.

#define read_2ubyte_unaligned_inc (   obo,
  Addr 
)
Value:
({ uint16_t t_ = read_2ubyte_unaligned (obo, Addr); \
Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 2); \
t_; })
#define read_2ubyte_unaligned(obo, Addr)

Definition at line 277 of file memory-access.h.

#define read_4sbyte_unaligned (   obo,
  Addr 
)    read_4sbyte_unaligned_1 ((obo), (Addr))

Definition at line 199 of file memory-access.h.

#define read_4sbyte_unaligned_inc (   obo,
  Addr 
)
Value:
({ int32_t t_ = read_4sbyte_unaligned (obo, Addr); \
Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 4); \
t_; })
#define read_4sbyte_unaligned(obo, Addr)

Definition at line 290 of file memory-access.h.

#define read_4ubyte_unaligned (   obo,
  Addr 
)    read_4ubyte_unaligned_1 ((obo), (Addr))

Definition at line 197 of file memory-access.h.

#define read_4ubyte_unaligned_inc (   obo,
  Addr 
)
Value:
({ uint32_t t_ = read_4ubyte_unaligned (obo, Addr); \
Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 4); \
t_; })
#define read_4ubyte_unaligned(obo, Addr)

Definition at line 286 of file memory-access.h.

#define read_8sbyte_unaligned (   obo,
  Addr 
)    read_8sbyte_unaligned_1 ((obo), (Addr))

Definition at line 203 of file memory-access.h.

#define read_8sbyte_unaligned_inc (   obo,
  Addr 
)
Value:
({ int64_t t_ = read_8sbyte_unaligned (obo, Addr); \
Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 8); \
t_; })
#define read_8sbyte_unaligned(obo, Addr)

Definition at line 299 of file memory-access.h.

#define read_8ubyte_unaligned (   obo,
  Addr 
)    read_8ubyte_unaligned_1 ((obo), (Addr))

Definition at line 201 of file memory-access.h.

#define read_8ubyte_unaligned_inc (   obo,
  Addr 
)
Value:
({ uint64_t t_ = read_8ubyte_unaligned (obo, Addr); \
Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 8); \
t_; })
#define read_8ubyte_unaligned(obo, Addr)

Definition at line 295 of file memory-access.h.

#define read_sbyte_unaligned (   Nbytes,
  obo,
  Addr 
)
Value:
((Nbytes) == 2 ? read_2sbyte_unaligned (obo, Addr) \
: (Nbytes) == 4 ? read_4sbyte_unaligned (obo, Addr) \
: read_8sbyte_unaligned (obo, Addr))
#define read_2sbyte_unaligned(obo, Addr)
#define read_4sbyte_unaligned(obo, Addr)
#define read_8sbyte_unaligned(obo, Addr)

Definition at line 271 of file memory-access.h.

#define read_sbyte_unaligned_inc (   Nbytes,
  obo,
  Addr 
)
Value:
((Nbytes) == 2 ? read_2sbyte_unaligned_inc (obo, Addr) \
: (Nbytes) == 4 ? read_4sbyte_unaligned_inc (obo, Addr) \
#define read_2sbyte_unaligned_inc(obo, Addr)
#define read_4sbyte_unaligned_inc(obo, Addr)
#define read_8sbyte_unaligned_inc(obo, Addr)

Definition at line 310 of file memory-access.h.

#define read_ubyte_unaligned (   Nbytes,
  obo,
  Addr 
)
Value:
((Nbytes) == 2 ? read_2ubyte_unaligned (obo, Addr) \
: (Nbytes) == 4 ? read_4ubyte_unaligned (obo, Addr) \
: read_8ubyte_unaligned (obo, Addr))
#define read_4ubyte_unaligned(obo, Addr)
#define read_2ubyte_unaligned(obo, Addr)
#define read_8ubyte_unaligned(obo, Addr)

Definition at line 266 of file memory-access.h.

#define read_ubyte_unaligned_inc (   Nbytes,
  obo,
  Addr 
)
Value:
((Nbytes) == 2 ? read_2ubyte_unaligned_inc (obo, Addr) \
: (Nbytes) == 4 ? read_4ubyte_unaligned_inc (obo, Addr) \
#define read_8ubyte_unaligned_inc(obo, Addr)
#define read_4ubyte_unaligned_inc(obo, Addr)
#define read_2ubyte_unaligned_inc(obo, Addr)

Definition at line 305 of file memory-access.h.

Function Documentation

union unaligned __attribute__ ( (packed)  )
get_sleb128_rest_return ( acc  ,
i  ,
addrp   
)
get_uleb128_rest_return ( acc  ,
i  ,
addrp   
)

Variable Documentation

int64_t _v = acc

Definition at line 141 of file memory-access.h.

static int64_t unsigned int const unsigned char ** addrp
Initial value:
{
unsigned char __b

Definition at line 132 of file memory-access.h.

static int64_t unsigned int i

Definition at line 131 of file memory-access.h.

void* p

Definition at line 143 of file memory-access.h.

int16_t s2

Definition at line 147 of file memory-access.h.

int32_t s4

Definition at line 148 of file memory-access.h.

int64_t s8

Definition at line 149 of file memory-access.h.

uint16_t u2

Definition at line 144 of file memory-access.h.

uint32_t u4

Definition at line 145 of file memory-access.h.

uint64_t u8

Definition at line 146 of file memory-access.h.