mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-12-25 04:23:42 +01:00
(unwi_dyn_remote_find_proc_info): If anything goes wrong, return -UNW_ENOINFO.
Skip over "prev_addr". Read start/end-IP directly into the "di" structure, not into temporary variables. Skip padding by directly adjusting the address (don't bother fetching padding values; that only slows things down). Return 0 only if we really did find dynamic unwind info. (Logical change 1.55)
This commit is contained in:
parent
95a55361c8
commit
1fc6f4e6b3
1 changed files with 32 additions and 27 deletions
|
@ -190,61 +190,66 @@ unwi_dyn_remote_find_proc_info (unw_addr_space_t as, unw_word_t ip,
|
||||||
{
|
{
|
||||||
unw_accessors_t *a = unw_get_accessors (as);
|
unw_accessors_t *a = unw_get_accessors (as);
|
||||||
unw_word_t dyn_list_addr, addr, next_addr, gen1, gen2;
|
unw_word_t dyn_list_addr, addr, next_addr, gen1, gen2;
|
||||||
unw_word_t start_ip, end_ip;
|
|
||||||
unw_dyn_info_t di;
|
unw_dyn_info_t di;
|
||||||
int32_t pad;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = (*a->get_dyn_info_list_addr) (as, &dyn_list_addr, arg);
|
if ((*a->get_dyn_info_list_addr) (as, &dyn_list_addr, arg) < 0)
|
||||||
if (ret < 0)
|
return -UNW_ENOINFO;
|
||||||
return ret;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
addr = dyn_list_addr;
|
addr = dyn_list_addr;
|
||||||
|
|
||||||
if ((ret = fetchw (as, a, &addr, &gen1, arg)) < 0
|
ret = -UNW_ENOINFO;
|
||||||
|| (ret = fetchw (as, a, &addr, &next_addr, arg)) < 0)
|
|
||||||
|
if (fetchw (as, a, &addr, &gen1, arg) < 0
|
||||||
|
|| fetchw (as, a, &addr, &next_addr, arg) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (addr = next_addr; addr != 0; addr = next_addr)
|
for (addr = next_addr; addr != 0; addr = next_addr)
|
||||||
{
|
{
|
||||||
if ((ret = fetchw (as, a, &addr, &next_addr, arg)) < 0
|
if (fetchw (as, a, &addr, &next_addr, arg) < 0)
|
||||||
|| (ret = fetchw (as, a, &addr, &start_ip, arg)) < 0
|
goto recheck; /* only fail if generation # didn't change */
|
||||||
|| (ret = fetchw (as, a, &addr, &end_ip, arg)) < 0)
|
|
||||||
return ret;
|
addr += WSIZE; /* skip over prev_addr */
|
||||||
|
|
||||||
|
if (fetchw (as, a, &addr, &di.start_ip, arg) < 0
|
||||||
|
|| fetchw (as, a, &addr, &di.end_ip, arg) < 0)
|
||||||
|
goto recheck; /* only fail if generation # didn't change */
|
||||||
|
|
||||||
if (ip >= di.start_ip && ip < di.end_ip)
|
if (ip >= di.start_ip && ip < di.end_ip)
|
||||||
{
|
{
|
||||||
if ((ret = fetchw (as, a, &addr, &di.gp, arg)) < 0
|
if (fetchw (as, a, &addr, &di.gp, arg) < 0
|
||||||
|| (ret = fetch32 (as, a, &addr, &di.format, arg)) < 0
|
|| fetch32 (as, a, &addr, &di.format, arg) < 0)
|
||||||
|| (ret = fetch32 (as, a, &addr, &pad, arg)) < 0)
|
goto recheck; /* only fail if generation # didn't change */
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (need_unwind_info)
|
addr += 4; /* skip over padding */
|
||||||
if ((ret = intern_dyn_info (as, a, &addr, &di, arg)) < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = unwi_extract_dynamic_proc_info (as, ip, pi, &di,
|
if (need_unwind_info
|
||||||
need_unwind_info, arg);
|
&& intern_dyn_info (as, a, &addr, &di, arg) < 0)
|
||||||
if (ret < 0)
|
goto recheck; /* only fail if generation # didn't change */
|
||||||
|
|
||||||
|
if (unwi_extract_dynamic_proc_info (as, ip, pi, &di,
|
||||||
|
need_unwind_info, arg) < 0)
|
||||||
{
|
{
|
||||||
free_dyn_info (&di);
|
free_dyn_info (&di);
|
||||||
return ret;
|
goto recheck; /* only fail if generation # didn't change */
|
||||||
}
|
}
|
||||||
return 0;
|
ret = 0; /* OK, found it */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Recheck generation number to ensure things didn't change
|
/* Re-check generation number to ensure the data we have is
|
||||||
underneath us: */
|
consistent. */
|
||||||
|
recheck:
|
||||||
addr = dyn_list_addr;
|
addr = dyn_list_addr;
|
||||||
if ((ret = fetchw (as, a, &addr, &gen2, arg)) < 0)
|
if (fetchw (as, a, &addr, &gen2, arg) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
while (gen1 != gen2);
|
while (gen1 != gen2);
|
||||||
*genp = gen1;
|
*genp = gen1;
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HIDDEN void
|
HIDDEN void
|
||||||
|
|
Loading…
Reference in a new issue