1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-22 23:47:39 +01:00

(nerrors): New global variable.

(verbose): Ditto.
(do_unwind_tests): Add sanity checking.
(main): Be verbose only if there is an argument, print error summary.

(Logical change 1.42)
This commit is contained in:
mostang.com!davidm 2003-01-23 18:47:51 +00:00
parent 4368ea4a70
commit 0fe74701c5

View file

@ -30,6 +30,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <libunwind.h> #include <libunwind.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "ia64-test-stack.h"
#define panic(args...) \
{ printf (args); ++nerrors; }
/* The loadrs field in ar.rsc is 14 bits wide, which limits all ia64 /* The loadrs field in ar.rsc is 14 bits wide, which limits all ia64
implementations to at most 2048 physical stacked registers implementations to at most 2048 physical stacked registers
@ -43,20 +49,27 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
extern void touch_all (unsigned long recursion_depth); extern void touch_all (unsigned long recursion_depth);
extern void flushrs (void); extern void flushrs (void);
int nerrors;
int verbose;
void void
do_unwind_tests (void) do_unwind_tests (void)
{ {
unw_word_t ip, sp, bsp, v0, v1, v2, v3, n0, n1, n2, n3; unw_word_t ip, sp, bsp, v0, v1, v2, v3, n0, n1, n2, n3, cfm, sof, sol, r32;
int ret, reg, i, l;
unw_context_t uc; unw_context_t uc;
unw_cursor_t c; unw_cursor_t c;
int ret, reg;
if (verbose)
printf ("do_unwind_tests: here we go!\n"); printf ("do_unwind_tests: here we go!\n");
/* do a full stack-dump: */
unw_getcontext (&uc); unw_getcontext (&uc);
unw_init_local (&c, &uc); unw_init_local (&c, &uc);
i = 0;
do do
{
if (verbose)
{ {
if ((ret = unw_get_reg (&c, UNW_IA64_IP, &ip)) < 0 if ((ret = unw_get_reg (&c, UNW_IA64_IP, &ip)) < 0
|| (ret = unw_get_reg (&c, UNW_IA64_SP, &sp)) < 0 || (ret = unw_get_reg (&c, UNW_IA64_SP, &sp)) < 0
@ -87,15 +100,76 @@ do_unwind_tests (void)
break; break;
} }
} }
if (i >= 1 && i <= NSTACKS)
{
if ((ret = unw_get_reg (&c, UNW_IA64_CFM, &cfm)) < 0)
break;
sof = cfm & 0x7f;
if (sof != (i & 1))
panic ("\texpected sof=%d, found sof=%lu\n", i - 1, sof);
if (sof == 1)
{
if ((ret = unw_get_reg (&c, UNW_IA64_GR + 32, &r32)) < 0)
break;
if (r32 != i - 1)
panic ("\texpected r32=%d, found r32=%lu\n", i - 1, r32);
}
}
else if (i > NSTACKS && i <= NSTACKS + RECURSION_DEPTH)
{
if ((ret = unw_get_reg (&c, UNW_IA64_CFM, &cfm)) < 0)
break;
sof = cfm & 0x7f;
sol = (cfm >> 7) & 0x7f;
if (sof != 96)
panic ("\texpected sof=96, found sof=%lu\n", sof);
if (sol != 95)
panic ("\texpected sol=95, found sol=%lu\n", sol);
for (l = 2; l <= 93; ++l)
{
if ((ret = unw_get_reg (&c, UNW_IA64_GR + 33 + l, &v0)) < 0
|| (ret = unw_get_reg (&c, UNW_IA64_NAT + 33 + l, &n0)) < 0)
break;
switch (l)
{
case 2: case 31: case 73: case 93:
if (!n0)
panic ("\texpected loc%d to be a NaT!\n", l);
break;
default:
if (n0)
panic ("\tloc%d is unexpectedly a NaT!\n", l);
v1 = ((unw_word_t) (i - NSTACKS) << 32) + l;
if (v0 != v1)
panic ("\tloc%d expected to be %lx, found to be %lx\n",
l, v1, v0);
}
}
}
++i;
}
while ((ret = unw_step (&c)) > 0); while ((ret = unw_step (&c)) > 0);
if (ret < 0) if (ret < 0)
printf ("libunwind returned %d\n", ret); panic ("libunwind returned %d\n", ret);
} }
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
if (argc > 1)
++verbose;
touch_all (RECURSION_DEPTH); touch_all (RECURSION_DEPTH);
if (nerrors)
{
printf ("FAILURE: detected %d errors\n", nerrors);
exit (-1);
}
if (verbose)
printf ("SUCCESS\n");
return 0; return 0;
} }