1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-25 08:37:38 +01:00

ALIAS unwind_get_accessors

This commit is contained in:
Dave Watson 2017-12-28 09:38:33 -08:00
parent c73a0f4d4e
commit 43934dae83
26 changed files with 40 additions and 32 deletions

View file

@ -224,6 +224,7 @@ unw_save_loc_t;
#define unw_create_addr_space UNW_OBJ(create_addr_space) #define unw_create_addr_space UNW_OBJ(create_addr_space)
#define unw_destroy_addr_space UNW_OBJ(destroy_addr_space) #define unw_destroy_addr_space UNW_OBJ(destroy_addr_space)
#define unw_get_accessors UNW_ARCH_OBJ(get_accessors) #define unw_get_accessors UNW_ARCH_OBJ(get_accessors)
#define unw_get_accessors_int UNW_ARCH_OBJ(get_accessors_int)
#define unw_init_local UNW_OBJ(init_local) #define unw_init_local UNW_OBJ(init_local)
#define unw_init_local2 UNW_OBJ(init_local2) #define unw_init_local2 UNW_OBJ(init_local2)
#define unw_init_remote UNW_OBJ(init_remote) #define unw_init_remote UNW_OBJ(init_remote)
@ -250,6 +251,7 @@ unw_save_loc_t;
extern unw_addr_space_t unw_create_addr_space (unw_accessors_t *, int); extern unw_addr_space_t unw_create_addr_space (unw_accessors_t *, int);
extern void unw_destroy_addr_space (unw_addr_space_t); extern void unw_destroy_addr_space (unw_addr_space_t);
extern unw_accessors_t *unw_get_accessors (unw_addr_space_t); extern unw_accessors_t *unw_get_accessors (unw_addr_space_t);
extern unw_accessors_t *unw_get_accessors_int (unw_addr_space_t);
extern void unw_flush_cache (unw_addr_space_t, unw_word_t, unw_word_t); extern void unw_flush_cache (unw_addr_space_t, unw_word_t, unw_word_t);
extern int unw_set_caching_policy (unw_addr_space_t, unw_caching_policy_t); extern int unw_set_caching_policy (unw_addr_space_t, unw_caching_policy_t);
extern int unw_set_cache_size (unw_addr_space_t, size_t, int); extern int unw_set_cache_size (unw_addr_space_t, size_t, int);

View file

@ -43,7 +43,7 @@ unw_is_signal_frame (unw_cursor_t *cursor)
int ret; int ret;
as = c->dwarf.as; as = c->dwarf.as;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
arg = c->dwarf.as_arg; arg = c->dwarf.as_arg;
ip = c->dwarf.ip; ip = c->dwarf.ip;

View file

@ -39,7 +39,7 @@ is_plt_entry (struct dwarf_cursor *c)
unw_accessors_t *a; unw_accessors_t *a;
int ret; int ret;
a = unw_get_accessors (c->as); a = unw_get_accessors_int (c->as);
if ((ret = (*a->access_mem) (c->as, c->ip, &w0, 0, c->as_arg)) < 0 if ((ret = (*a->access_mem) (c->as, c->ip, &w0, 0, c->as_arg)) < 0
|| (ret = (*a->access_mem) (c->as, c->ip + 8, &w1, 0, c->as_arg)) < 0) || (ret = (*a->access_mem) (c->as, c->ip + 8, &w1, 0, c->as_arg)) < 0)
return 0; return 0;

View file

@ -102,7 +102,7 @@ unw_is_signal_frame (unw_cursor_t *cursor)
int ret; int ret;
as = c->dwarf.as; as = c->dwarf.as;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
arg = c->dwarf.as_arg; arg = c->dwarf.as_arg;
ip = c->dwarf.ip; ip = c->dwarf.ip;

View file

@ -160,7 +160,7 @@ unw_is_signal_frame (unw_cursor_t *cursor)
int ret; int ret;
as = c->dwarf.as; as = c->dwarf.as;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
arg = c->dwarf.as_arg; arg = c->dwarf.as_arg;
/* The least bit denotes thumb/arm mode. Do not read there. */ /* The least bit denotes thumb/arm mode. Do not read there. */

View file

@ -196,7 +196,7 @@ dwarf_stack_aligned(struct dwarf_cursor *c, unw_word_t cfa_addr,
uint8_t opcode; uint8_t opcode;
unw_word_t operand1; unw_word_t operand1;
a = unw_get_accessors (c->as); a = unw_get_accessors_int (c->as);
arg = c->as_arg; arg = c->as_arg;
ret = dwarf_read_uleb128(c->as, a, &rbp_addr, &len, arg); ret = dwarf_read_uleb128(c->as, a, &rbp_addr, &len, arg);
@ -281,7 +281,7 @@ do { \
as = c->as; as = c->as;
arg = c->as_arg; arg = c->as_arg;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
end_addr = *addr + len; end_addr = *addr + len;
*is_register = 0; *is_register = 0;

View file

@ -58,7 +58,7 @@ linear_search (unw_addr_space_t as, unw_word_t ip,
unw_word_t fde_count, unw_word_t fde_count,
unw_proc_info_t *pi, int need_unwind_info, void *arg) unw_proc_info_t *pi, int need_unwind_info, void *arg)
{ {
unw_accessors_t *a = unw_get_accessors (unw_local_addr_space); unw_accessors_t *a = unw_get_accessors_int (unw_local_addr_space);
unw_word_t i = 0, fde_addr, addr = eh_frame_start; unw_word_t i = 0, fde_addr, addr = eh_frame_start;
int ret; int ret;
@ -316,7 +316,7 @@ dwarf_find_debug_frame (int found, unw_dyn_info_t *di_debug, unw_word_t ip,
{ {
addr = (unw_word_t) (uintptr_t) buf; addr = (unw_word_t) (uintptr_t) buf;
a = unw_get_accessors (unw_local_addr_space); a = unw_get_accessors_int (unw_local_addr_space);
/* Find all FDE entries in debug_frame, and make into a sorted /* Find all FDE entries in debug_frame, and make into a sorted
index. */ index. */
@ -586,7 +586,7 @@ dwarf_callback (struct dl_phdr_info *info, size_t size, void *ptr)
return 0; return 0;
} }
a = unw_get_accessors (unw_local_addr_space); a = unw_get_accessors_int (unw_local_addr_space);
addr = (unw_word_t) (uintptr_t) (&hdr->eh_frame); addr = (unw_word_t) (uintptr_t) (&hdr->eh_frame);
/* (Optionally) read eh_frame_ptr: */ /* (Optionally) read eh_frame_ptr: */
@ -764,7 +764,7 @@ remote_lookup (unw_addr_space_t as,
struct table_entry *e, int32_t *last_ip_offset, void *arg) struct table_entry *e, int32_t *last_ip_offset, void *arg)
{ {
unsigned long table_len = table_size / sizeof (struct table_entry); unsigned long table_len = table_size / sizeof (struct table_entry);
unw_accessors_t *a = unw_get_accessors (as); unw_accessors_t *a = unw_get_accessors_int (as);
unsigned long lo, hi, mid; unsigned long lo, hi, mid;
unw_word_t e_addr = 0; unw_word_t e_addr = 0;
int32_t start = 0; int32_t start = 0;
@ -848,7 +848,7 @@ dwarf_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
#endif #endif
} }
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
segbase = di->u.rti.segbase; segbase = di->u.rti.segbase;
if (di->format == UNW_INFO_FORMAT_IP_OFFSET) { if (di->format == UNW_INFO_FORMAT_IP_OFFSET) {

View file

@ -138,7 +138,7 @@ dwarf_find_unwind_table (struct elf_dyn_info *edi, unw_addr_space_t as,
return -UNW_ENOINFO; return -UNW_ENOINFO;
} }
a = unw_get_accessors (unw_local_addr_space); a = unw_get_accessors_int (unw_local_addr_space);
addr = to_unw_word (&hdr->eh_frame); addr = to_unw_word (&hdr->eh_frame);
/* Fill in a dummy proc_info structure. We just need to fill in /* Fill in a dummy proc_info structure. We just need to fill in

View file

@ -109,7 +109,7 @@ run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
as = c->as; as = c->as;
arg = c->as_arg; arg = c->as_arg;
} }
unw_accessors_t *a = unw_get_accessors (as); unw_accessors_t *a = unw_get_accessors_int (as);
int ret = 0; int ret = 0;
while (*ip <= end_ip && *addr < end_addr && ret >= 0) while (*ip <= end_ip && *addr < end_addr && ret >= 0)
@ -773,7 +773,7 @@ apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs)
as = c->as; as = c->as;
arg = c->as_arg; arg = c->as_arg;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
/* Evaluate the CFA first, because it may be referred to by other /* Evaluate the CFA first, because it may be referred to by other
expressions. */ expressions. */

View file

@ -37,7 +37,7 @@ unw_is_signal_frame (unw_cursor_t *cursor)
int ret; int ret;
as = c->dwarf.as; as = c->dwarf.as;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
arg = c->dwarf.as_arg; arg = c->dwarf.as_arg;
/* Check if IP points at sigreturn() sequence. On Linux, this normally is: /* Check if IP points at sigreturn() sequence. On Linux, this normally is:

View file

@ -25,6 +25,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h" #include "unwind_i.h"
HIDDEN ALIAS(unw_get_accessors) unw_accessors_t *
unw_get_accessors_int (unw_addr_space_t as);
unw_accessors_t * unw_accessors_t *
unw_get_accessors (unw_addr_space_t as) unw_get_accessors (unw_addr_space_t as)
{ {

View file

@ -68,7 +68,7 @@ is_local_addr_space (unw_addr_space_t as)
static inline int static inline int
read_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *valp, void *arg) read_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *valp, void *arg)
{ {
unw_accessors_t *a = unw_get_accessors (as); unw_accessors_t *a = unw_get_accessors_int (as);
return (*a->access_mem) (as, addr, valp, 0, arg); return (*a->access_mem) (as, addr, valp, 0, arg);
} }
@ -87,7 +87,7 @@ remote_lookup (unw_addr_space_t as,
struct ia64_table_entry *e, void *arg) struct ia64_table_entry *e, void *arg)
{ {
unw_word_t e_addr = 0, start_offset, end_offset, info_offset; unw_word_t e_addr = 0, start_offset, end_offset, info_offset;
unw_accessors_t *a = unw_get_accessors (as); unw_accessors_t *a = unw_get_accessors_int (as);
unsigned long lo, hi, mid; unsigned long lo, hi, mid;
int ret; int ret;
@ -165,7 +165,7 @@ _Uia64_find_dyn_list (unw_addr_space_t as, unw_dyn_info_t *di, void *arg)
case UNW_INFO_FORMAT_REMOTE_TABLE: case UNW_INFO_FORMAT_REMOTE_TABLE:
{ {
unw_accessors_t *a = unw_get_accessors (as); unw_accessors_t *a = unw_get_accessors_int (as);
unw_word_t e_addr = di->u.rti.table_data; unw_word_t e_addr = di->u.rti.table_data;
table_size = di->u.rti.table_len * sizeof (unw_word_t); table_size = di->u.rti.table_len * sizeof (unw_word_t);

View file

@ -205,7 +205,7 @@ unwi_dyn_remote_find_proc_info (unw_addr_space_t as, unw_word_t ip,
unw_proc_info_t *pi, unw_proc_info_t *pi,
int need_unwind_info, void *arg) int need_unwind_info, void *arg)
{ {
unw_accessors_t *a = unw_get_accessors (as); unw_accessors_t *a = unw_get_accessors_int (as);
unw_word_t dyn_list_addr, addr, next_addr, gen1, gen2, start_ip, end_ip; unw_word_t dyn_list_addr, addr, next_addr, gen1, gen2, start_ip, end_ip;
unw_dyn_info_t *di = NULL; unw_dyn_info_t *di = NULL;
int ret; int ret;
@ -311,7 +311,7 @@ unwi_dyn_validate_cache (unw_addr_space_t as, void *arg)
in the cache. */ in the cache. */
return 0; return 0;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
addr = as->dyn_info_list_addr; addr = as->dyn_info_list_addr;
if (fetchw (as, a, &addr, &gen, arg) < 0) if (fetchw (as, a, &addr, &gen, arg) < 0)

View file

@ -25,6 +25,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "libunwind_i.h" #include "libunwind_i.h"
HIDDEN ALIAS(unw_get_accessors) unw_accessors_t *
unw_get_accessors_int (unw_addr_space_t as);
unw_accessors_t * unw_accessors_t *
unw_get_accessors (unw_addr_space_t as) unw_get_accessors (unw_addr_space_t as)
{ {

View file

@ -29,7 +29,7 @@ int
unw_get_proc_info_by_ip (unw_addr_space_t as, unw_word_t ip, unw_get_proc_info_by_ip (unw_addr_space_t as, unw_word_t ip,
unw_proc_info_t *pi, void *as_arg) unw_proc_info_t *pi, void *as_arg)
{ {
unw_accessors_t *a = unw_get_accessors (as); unw_accessors_t *a = unw_get_accessors_int (as);
int ret; int ret;
ret = unwi_find_dynamic_proc_info (as, ip, pi, 0, as_arg); ret = unwi_find_dynamic_proc_info (as, ip, pi, 0, as_arg);

View file

@ -49,7 +49,7 @@ static inline int
get_proc_name (unw_addr_space_t as, unw_word_t ip, get_proc_name (unw_addr_space_t as, unw_word_t ip,
char *buf, size_t buf_len, unw_word_t *offp, void *arg) char *buf, size_t buf_len, unw_word_t *offp, void *arg)
{ {
unw_accessors_t *a = unw_get_accessors (as); unw_accessors_t *a = unw_get_accessors_int (as);
unw_proc_info_t pi; unw_proc_info_t pi;
int ret; int ret;

View file

@ -37,7 +37,7 @@ unw_is_signal_frame (unw_cursor_t *cursor)
int ret; int ret;
as = c->dwarf.as; as = c->dwarf.as;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
arg = c->dwarf.as_arg; arg = c->dwarf.as_arg;
ip = c->dwarf.ip; ip = c->dwarf.ip;

View file

@ -56,7 +56,7 @@ unw_is_signal_frame (unw_cursor_t * cursor)
consecutive 32-bit words, so the second 8-byte word needs to be consecutive 32-bit words, so the second 8-byte word needs to be
shifted right by 32 bits (think big-endian) */ shifted right by 32 bits (think big-endian) */
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0 if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0
|| (ret = (*a->access_mem) (as, ip + 8, &w1, 0, arg)) < 0) || (ret = (*a->access_mem) (as, ip + 8, &w1, 0, arg)) < 0)
return 0; return 0;

View file

@ -448,7 +448,7 @@ unw_step (unw_cursor_t * cursor)
{ {
unw_word_t ip = c->dwarf.ip; unw_word_t ip = c->dwarf.ip;
unw_addr_space_t as = c->dwarf.as; unw_addr_space_t as = c->dwarf.as;
unw_accessors_t *a = unw_get_accessors (as); unw_accessors_t *a = unw_get_accessors_int (as);
void *arg = c->dwarf.as_arg; void *arg = c->dwarf.as_arg;
uint32_t toc_save = (as->abi == UNW_PPC64_ABI_ELFv2)? 24 : 40; uint32_t toc_save = (as->abi == UNW_PPC64_ABI_ELFv2)? 24 : 40;
int32_t inst; int32_t inst;

View file

@ -36,7 +36,7 @@ tdep_get_func_addr (unw_addr_space_t as, unw_word_t addr,
unw_accessors_t *a; unw_accessors_t *a;
int ret; int ret;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
/* Entry-point is stored in the 1st word of the function descriptor. /* Entry-point is stored in the 1st word of the function descriptor.
In case that changes in the future, we'd have to update the line In case that changes in the future, we'd have to update the line
below and read the word at addr + offset: */ below and read the word at addr + offset: */

View file

@ -75,7 +75,7 @@ unw_is_signal_frame (unw_cursor_t *cursor)
int ret; int ret;
as = c->dwarf.as; as = c->dwarf.as;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
arg = c->dwarf.as_arg; arg = c->dwarf.as_arg;
ip = c->dwarf.ip; ip = c->dwarf.ip;

View file

@ -51,7 +51,7 @@ unw_is_signal_frame (unw_cursor_t *cursor)
int ret; int ret;
as = c->dwarf.as; as = c->dwarf.as;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
arg = c->dwarf.as_arg; arg = c->dwarf.as_arg;
ip = c->dwarf.ip; ip = c->dwarf.ip;

View file

@ -46,7 +46,7 @@ unw_is_signal_frame (unw_cursor_t *cursor)
int ret; int ret;
as = c->dwarf.as; as = c->dwarf.as;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
arg = c->dwarf.as_arg; arg = c->dwarf.as_arg;
/* Check if EIP points at sigreturn() sequence. It can be: /* Check if EIP points at sigreturn() sequence. It can be:

View file

@ -39,7 +39,7 @@ unw_is_signal_frame (unw_cursor_t *cursor)
int ret; int ret;
as = c->dwarf.as; as = c->dwarf.as;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
arg = c->dwarf.as_arg; arg = c->dwarf.as_arg;
/* Check if EIP points at sigreturn() sequence. On Linux, this is: /* Check if EIP points at sigreturn() sequence. On Linux, this is:

View file

@ -45,7 +45,7 @@ unw_is_signal_frame (unw_cursor_t *cursor)
int ret; int ret;
as = c->dwarf.as; as = c->dwarf.as;
a = unw_get_accessors (as); a = unw_get_accessors_int (as);
arg = c->dwarf.as_arg; arg = c->dwarf.as_arg;
/* Check if RIP points at sigreturn sequence. /* Check if RIP points at sigreturn sequence.

View file

@ -39,7 +39,7 @@ is_plt_entry (struct dwarf_cursor *c)
unw_accessors_t *a; unw_accessors_t *a;
int ret; int ret;
a = unw_get_accessors (c->as); a = unw_get_accessors_int (c->as);
if ((ret = (*a->access_mem) (c->as, c->ip, &w0, 0, c->as_arg)) < 0 if ((ret = (*a->access_mem) (c->as, c->ip, &w0, 0, c->as_arg)) < 0
|| (ret = (*a->access_mem) (c->as, c->ip + 8, &w1, 0, c->as_arg)) < 0) || (ret = (*a->access_mem) (c->as, c->ip + 8, &w1, 0, c->as_arg)) < 0)
return 0; return 0;