1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-14 12:18:12 +01:00

Remove next field from dwarf_reg_state. Create new struct

that includes next field and dwarf_reg_state, and use that
strictly for stack push/pop in run_cfi_program.
This commit is contained in:
Doug Moore 2017-05-10 20:47:53 -05:00
parent bfb246a499
commit a7c65f5c3e
3 changed files with 15 additions and 9 deletions

View file

@ -258,13 +258,19 @@ dwarf_save_loc_t;
typedef struct dwarf_reg_state
{
struct dwarf_reg_state *next; /* for rs_stack */
dwarf_save_loc_t reg[DWARF_NUM_PRESERVED_REGS + 2];
unw_word_t ret_addr_column; /* indicates which column in the rule table represents return address */
unsigned short signal_frame : 1; /* optional machine-dependent signal info */
}
dwarf_reg_state_t;
typedef struct dwarf_stackable_reg_state
{
struct dwarf_stackable_reg_state *next; /* for rs_stack */
dwarf_reg_state_t state;
}
dwarf_stackable_reg_state_t;
typedef struct dwarf_reg_cache_entry
{
unw_word_t ip; /* ip this rs is for */

View file

@ -60,9 +60,9 @@ set_reg (dwarf_state_record_t *sr, unw_word_t regnum, dwarf_where_t where,
}
static inline int
push_rstate_stack(dwarf_reg_state_t **rs_stack)
push_rstate_stack(dwarf_stackable_reg_state_t **rs_stack)
{
dwarf_reg_state_t *old_rs = *rs_stack;
dwarf_stackable_reg_state_t *old_rs = *rs_stack;
if (NULL == (*rs_stack = alloc_reg_state ()))
{
*rs_stack = old_rs;
@ -73,9 +73,9 @@ push_rstate_stack(dwarf_reg_state_t **rs_stack)
}
static inline void
pop_rstate_stack(dwarf_reg_state_t **rs_stack)
pop_rstate_stack(dwarf_stackable_reg_state_t **rs_stack)
{
dwarf_reg_state_t *old_rs = *rs_stack;
dwarf_stackable_reg_state_t *old_rs = *rs_stack;
*rs_stack = old_rs->next;
free_reg_state (old_rs);
}
@ -87,7 +87,7 @@ run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
unw_word_t *addr, unw_word_t end_addr,
struct dwarf_cie_info *dci)
{
dwarf_reg_state_t *rs_stack = NULL;
dwarf_stackable_reg_state_t *rs_stack = NULL;
unw_addr_space_t as;
void *arg;
@ -269,7 +269,7 @@ run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
ret = -UNW_ENOMEM;
break;
}
memcpy (rs_stack->reg, sr->rs_current.reg, sizeof (rs_stack->reg));
memcpy (rs_stack->state.reg, sr->rs_current.reg, sizeof (rs_stack->state.reg));
Debug (15, "CFA_remember_state\n");
break;
@ -280,7 +280,7 @@ run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
ret = -UNW_EINVAL;
break;
}
memcpy (&sr->rs_current.reg, &rs_stack->reg, sizeof (rs_stack->reg));
memcpy (&sr->rs_current.reg, &rs_stack->state.reg, sizeof (rs_stack->state.reg));
pop_rstate_stack(&rs_stack);
Debug (15, "CFA_restore_state\n");
break;

View file

@ -31,7 +31,7 @@ HIDDEN struct mempool dwarf_cie_info_pool;
HIDDEN int
dwarf_init (void)
{
mempool_init (&dwarf_reg_state_pool, sizeof (dwarf_reg_state_t), 0);
mempool_init (&dwarf_reg_state_pool, sizeof (dwarf_stackable_reg_state_t), 0);
mempool_init (&dwarf_cie_info_pool, sizeof (struct dwarf_cie_info), 0);
return 0;
}