1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-15 20:58:13 +01:00

Cast register indices of type unw_word_t to (unsigned int) before

printing them.  Avoids compiler-warning for 64-bit targets.

(apply_reg_state): Handle the special case where the stack-pointer
	plays the role of the CFA and the stack-pointer hasn't
	been saved.  This is based on a patch by Max Asbock.

(Logical change 1.253)
This commit is contained in:
homeip.net!davidm 2004-08-20 11:23:15 +00:00
parent 6058013abe
commit 642607dbaa

View file

@ -42,7 +42,7 @@ read_regnum (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
if (*valp >= DWARF_NUM_PRESERVED_REGS) if (*valp >= DWARF_NUM_PRESERVED_REGS)
{ {
Debug (1, "Invalid register number %u\n", *valp); Debug (1, "Invalid register number %u\n", (unsigned int) *valp);
return -UNW_EBADREG; return -UNW_EBADREG;
} }
return 0; return 0;
@ -137,7 +137,7 @@ run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
if (regnum >= DWARF_NUM_PRESERVED_REGS) if (regnum >= DWARF_NUM_PRESERVED_REGS)
{ {
Debug (1, "Invalid register number %u in DW_cfa_OFFSET\n", Debug (1, "Invalid register number %u in DW_cfa_OFFSET\n",
regnum); (unsigned int) regnum);
ret = -UNW_EBADREG; ret = -UNW_EBADREG;
goto fail; goto fail;
} }
@ -171,7 +171,7 @@ run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
if (regnum >= DWARF_NUM_PRESERVED_REGS) if (regnum >= DWARF_NUM_PRESERVED_REGS)
{ {
Debug (1, "Invalid register number %u in DW_CFA_restore\n", Debug (1, "Invalid register number %u in DW_CFA_restore\n",
regnum); (unsigned int) regnum);
ret = -UNW_EINVAL; ret = -UNW_EINVAL;
goto fail; goto fail;
} }
@ -185,7 +185,7 @@ run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
if (regnum >= DWARF_NUM_PRESERVED_REGS) if (regnum >= DWARF_NUM_PRESERVED_REGS)
{ {
Debug (1, "Invalid register number %u in " Debug (1, "Invalid register number %u in "
"DW_CFA_restore_extended\n", regnum); "DW_CFA_restore_extended\n", (unsigned int) regnum);
ret = -UNW_EINVAL; ret = -UNW_EINVAL;
goto fail; goto fail;
} }
@ -513,6 +513,8 @@ apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs)
arg = c->as_arg; arg = c->as_arg;
a = unw_get_accessors (as); a = unw_get_accessors (as);
c->cfa_is_sp = 0;
/* Evaluate the CFA first, because it may be referred to be other /* Evaluate the CFA first, because it may be referred to be other
expressions. */ expressions. */
@ -520,10 +522,21 @@ apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs)
{ {
/* CFA is equal to [reg] + offset: */ /* CFA is equal to [reg] + offset: */
regnum = dwarf_to_unw_regnum (rs->reg[DWARF_CFA_REG_COLUMN].val); /* As a special-case, if the stack-pointer is the CFA and the
if ((ret = unw_get_reg ((unw_cursor_t *) c, regnum, &cfa)) < 0) stack-pointer wasn't saved, popping the CFA implicitly pops
return ret; the stack-pointer as well. */
if ((rs->reg[DWARF_CFA_REG_COLUMN].val == UNW_TDEP_SP)
&& (rs->reg[UNW_TDEP_SP].where == DWARF_WHERE_SAME))
{
cfa = c->cfa;
c->cfa_is_sp = 1;
}
else
{
regnum = dwarf_to_unw_regnum (rs->reg[DWARF_CFA_REG_COLUMN].val);
if ((ret = unw_get_reg ((unw_cursor_t *) c, regnum, &cfa)) < 0)
return ret;
}
cfa += rs->reg[DWARF_CFA_OFF_COLUMN].val; cfa += rs->reg[DWARF_CFA_OFF_COLUMN].val;
} }
else else