mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-25 16:47:38 +01:00
Move all inline functions to dwarf_i.h.
(Logical change 1.162)
This commit is contained in:
parent
b88369b831
commit
fe039e2c1f
1 changed files with 0 additions and 319 deletions
319
include/dwarf.h
319
include/dwarf.h
|
@ -200,325 +200,6 @@ dwarf_cfa_t;
|
|||
|
||||
extern struct mempool dwarf_reg_state_pool;
|
||||
|
||||
#ifdef UNW_LOCAL_ONLY
|
||||
|
||||
/* In the local-only case, we can let the compiler directly access
|
||||
memory and don't need to worry about differing byte-order. */
|
||||
|
||||
typedef union
|
||||
{
|
||||
int8_t s8;
|
||||
int16_t s16;
|
||||
int32_t s32;
|
||||
int64_t s64;
|
||||
uint8_t u8;
|
||||
uint16_t u16;
|
||||
uint32_t u32;
|
||||
uint64_t u64;
|
||||
unw_word_t w;
|
||||
void *ptr;
|
||||
}
|
||||
dwarf_misaligned_value_t __attribute__ ((packed));
|
||||
|
||||
static inline int
|
||||
dwarf_reads8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
int8_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->s8;
|
||||
*addr += sizeof (mvp->s8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_reads16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
int16_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->s16;
|
||||
*addr += sizeof (mvp->s16);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_reads32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
int32_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->s32;
|
||||
*addr += sizeof (mvp->s32);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_reads64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
int64_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->s64;
|
||||
*addr += sizeof (mvp->s64);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readu8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
uint8_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->u8;
|
||||
*addr += sizeof (mvp->u8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readu16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
uint16_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->u16;
|
||||
*addr += sizeof (mvp->u16);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readu32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
uint32_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->u32;
|
||||
*addr += sizeof (mvp->u32);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readu64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
uint64_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->u64;
|
||||
*addr += sizeof (mvp->u64);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readw (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
unw_word_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->w;
|
||||
*addr += sizeof (mvp->w);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readptr (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
unw_word_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = (unw_word_t) mvp->ptr;
|
||||
*addr += sizeof (mvp->ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* !UNW_LOCAL_ONLY */
|
||||
|
||||
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
FIX ME
|
||||
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
|
||||
|
||||
typedef union
|
||||
{
|
||||
int8_t s8;
|
||||
int16_t s16;
|
||||
int32_t s32;
|
||||
int64_t s64;
|
||||
uint8_t u8;
|
||||
uint16_t u16;
|
||||
uint32_t u32;
|
||||
uint64_t u64;
|
||||
unw_word_t w;
|
||||
void *ptr;
|
||||
}
|
||||
dwarf_misaligned_value_t __attribute__ ((packed));
|
||||
|
||||
static inline int
|
||||
dwarf_reads8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
int8_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->s8;
|
||||
*addr += sizeof (mvp->s8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_reads16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
int16_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->s16;
|
||||
*addr += sizeof (mvp->s16);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_reads32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
int32_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->s32;
|
||||
*addr += sizeof (mvp->s32);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_reads64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
int64_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->s64;
|
||||
*addr += sizeof (mvp->s64);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readu8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
uint8_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->u8;
|
||||
*addr += sizeof (mvp->u8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readu16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
uint16_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->u16;
|
||||
*addr += sizeof (mvp->u16);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readu32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
uint32_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->u32;
|
||||
*addr += sizeof (mvp->u32);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readu64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
uint64_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->u64;
|
||||
*addr += sizeof (mvp->u64);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readw (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
unw_word_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = mvp->w;
|
||||
*addr += sizeof (mvp->w);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dwarf_readptr (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
unw_word_t *val, void *arg)
|
||||
{
|
||||
dwarf_misaligned_value_t *mvp = (void *) *addr;
|
||||
|
||||
*val = (unw_word_t) mvp->ptr;
|
||||
*addr += sizeof (mvp->ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !UNW_LOCAL_ONLY */
|
||||
|
||||
/* Read an unsigned "little-endian base 128" value. See Chapter 7.6
|
||||
of DWARF spec v3. */
|
||||
|
||||
static inline int
|
||||
dwarf_read_uleb128 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
unw_word_t *valp, void *arg)
|
||||
{
|
||||
unw_word_t val = 0, shift = 0;
|
||||
unsigned char byte;
|
||||
int ret;
|
||||
|
||||
do
|
||||
{
|
||||
if ((ret = dwarf_readu8 (as, a, addr, &byte, arg)) < 0)
|
||||
return ret;
|
||||
|
||||
val |= ((unw_word_t) byte & 0x7f) << shift;
|
||||
shift += 7;
|
||||
}
|
||||
while (byte & 0x80);
|
||||
|
||||
*valp = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read a signed "little-endian base 128" value. See Chapter 7.6 of
|
||||
DWARF spec v3. */
|
||||
|
||||
static inline int
|
||||
dwarf_read_sleb128 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
|
||||
unw_word_t *valp, void *arg)
|
||||
{
|
||||
unw_word_t val = 0, shift = 0;
|
||||
unsigned char byte;
|
||||
int ret;
|
||||
|
||||
do
|
||||
{
|
||||
if ((ret = dwarf_readu8 (as, a, addr, &byte, arg)) < 0)
|
||||
return ret;
|
||||
|
||||
val |= ((unw_word_t) byte & 0x7f) << shift;
|
||||
shift += 7;
|
||||
}
|
||||
while (byte & 0x80);
|
||||
|
||||
if (shift < 8 * sizeof (unw_word_t) && (byte & 0x40) != 0)
|
||||
/* sign-extend negative value */
|
||||
val |= ((unw_word_t) -1) << shift;
|
||||
|
||||
*valp = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DWARF_WHERE_UNDEF, /* register isn't saved at all */
|
||||
|
|
Loading…
Reference in a new issue