mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2025-02-16 18:21:41 +01:00
(Logical change 1.41)
This commit is contained in:
parent
01ead91d21
commit
3f0ebaa7e3
2 changed files with 279 additions and 0 deletions
|
@ -0,0 +1,178 @@
|
|||
/* libunwind - a platform-independent unwind library
|
||||
Copyright (C) 2003 Hewlett-Packard Co
|
||||
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
|
||||
|
||||
This file is part of libunwind.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
|
||||
#define NSTACKS 1024
|
||||
#define STACK_SIZE_SHIFT 17
|
||||
#define STACK_SIZE (1 << STACK_SIZE_SHIFT)
|
||||
|
||||
.common stackmem, NSTACKS*STACK_SIZE, 16
|
||||
|
||||
.text
|
||||
|
||||
#define SAVED_SP_OFF 0
|
||||
#define SAVED_RP_OFF 8
|
||||
#define SAVED_PFS_OFF 16
|
||||
#define SAVED_RNAT_OFF 24
|
||||
#define SAVED_BSP_OFF 32
|
||||
#define SAVED_BSPSTORE_OFF 40
|
||||
#define FRAME_SIZE 48
|
||||
|
||||
.proc stack_it
|
||||
stack_it:
|
||||
.prologue
|
||||
alloc r18 = ar.pfs, 0, 0, 0, 0 // read ar.pfs
|
||||
// first, calculate address of new stack:
|
||||
addl r2 = @ltoff(stackmem), gp
|
||||
shl r3 = r8, STACK_SIZE_SHIFT
|
||||
;;
|
||||
ld8 r2 = [r2] // r2 = &stackmem
|
||||
;;
|
||||
add r2 = r2, r3 // r2 = stackmem[iteration]
|
||||
;;
|
||||
addl r3 = STACK_SIZE-FRAME_SIZE, r2 // r3 = &stackframe
|
||||
;;
|
||||
st8 [r3] = sp
|
||||
.vframesp SAVED_SP_OFF+16
|
||||
adds sp = -16, r3 // switch the memory stack
|
||||
;;
|
||||
adds r3 = (SAVED_RP_OFF - SAVED_SP_OFF), r3
|
||||
mov r16 = rp
|
||||
;;
|
||||
.savesp rp, SAVED_RP_OFF+16
|
||||
st8 [r3] = r16, (SAVED_PFS_OFF - SAVED_RP_OFF)
|
||||
;;
|
||||
.savesp ar.pfs, SAVED_PFS_OFF+16
|
||||
st8 [r3] = r18, (SAVED_BSP_OFF - SAVED_PFS_OFF)
|
||||
|
||||
mov r16 = ar.bsp
|
||||
mov r17 = ar.bspstore
|
||||
mov r18 = ar.rnat
|
||||
;;
|
||||
.savesp ar.bsp, SAVED_BSP_OFF+16
|
||||
st8 [r3] = r16, (SAVED_BSPSTORE_OFF - SAVED_BSP_OFF)
|
||||
;;
|
||||
.savesp ar.bspstore, SAVED_BSPSTORE_OFF+16
|
||||
st8 [r3] = r17, (SAVED_RNAT_OFF - SAVED_BSPSTORE_OFF)
|
||||
;;
|
||||
.savesp ar.rnat, SAVED_RNAT_OFF+16
|
||||
st8 [r3] = r18
|
||||
;;
|
||||
mov ar.bspstore = r2 // switch the backing store
|
||||
|
||||
.body
|
||||
|
||||
// for even iterations, allocate a local variable:
|
||||
tbit.nz p6, p0 = r8, 0
|
||||
(p6) br.cond.sptk.few 1f
|
||||
;;
|
||||
alloc r2 = ar.pfs, 0, 1, 0, 0
|
||||
mov loc0 = r8
|
||||
;;
|
||||
1: cmp.ne p6, p7 = 0, r8
|
||||
;;
|
||||
{ .mbb
|
||||
(p6) adds r8 = -1, r8
|
||||
(p6) br.call.sptk.many rp = stack_it // next iteration
|
||||
(p7) br.call.sptk.many rp = do_unwind_tests // time for introspection...
|
||||
}
|
||||
// switch back to stack:
|
||||
|
||||
adds r3 = SAVED_SP_OFF+16, sp
|
||||
;;
|
||||
ld8 r16 = [r3], (SAVED_RP_OFF-SAVED_SP_OFF);; // saved sp
|
||||
ld8 r17 = [r3], (SAVED_PFS_OFF-SAVED_RP_OFF);; // saved rp
|
||||
ld8 r18 = [r3], (SAVED_RNAT_OFF-SAVED_PFS_OFF);; // saved pfs
|
||||
ld8 r19 = [r3], (SAVED_BSP_OFF-SAVED_RNAT_OFF);; // saved rnat
|
||||
ld8 r20 = [r3], (SAVED_BSPSTORE_OFF-SAVED_BSP_OFF);; // saved bsp
|
||||
ld8 r21 = [r3];; // saved bspstore
|
||||
|
||||
mov rp = r17
|
||||
mov ar.pfs = r18
|
||||
mov ar.bspstore = r21 // this also restores ar.bsp
|
||||
;;
|
||||
mov ar.rnat = r19
|
||||
|
||||
.restore sp
|
||||
mov sp = r16
|
||||
br.ret.sptk.many rp
|
||||
.endp stack_it
|
||||
|
||||
|
||||
#define SET_LOC(n) add loc##n = n, r8
|
||||
#define SET_NAT(n) ld8.s loc##n = [r0]
|
||||
|
||||
.global touch_all
|
||||
.proc touch_all
|
||||
touch_all:
|
||||
.prologue
|
||||
.save ar.pfs, r34
|
||||
alloc loc1 = ar.pfs, 1, 94, 1, 0
|
||||
.save rp, loc0
|
||||
mov loc0 = rp
|
||||
.body
|
||||
|
||||
mov ar.rsc = 0 // put RSE into enforced lazy mode
|
||||
shl r8 = in0, 32 // store iteration # in top 32 bits
|
||||
add out0 = -1, in0
|
||||
cmp.eq p6, p7 = 1, in0
|
||||
;;
|
||||
SET_LOC( 2); SET_LOC( 3)
|
||||
SET_LOC( 4); SET_LOC( 5); SET_LOC( 6); SET_LOC( 7)
|
||||
SET_LOC( 8); SET_LOC( 9); SET_LOC(10); SET_LOC(11)
|
||||
SET_LOC(12); SET_LOC(13); SET_LOC(14); SET_LOC(15)
|
||||
SET_LOC(16); SET_LOC(17); SET_LOC(18); SET_LOC(19)
|
||||
SET_LOC(20); SET_LOC(21); SET_LOC(22); SET_LOC(23)
|
||||
SET_LOC(24); SET_LOC(25); SET_LOC(26); SET_LOC(27)
|
||||
SET_LOC(28); SET_LOC(29); SET_LOC(30); SET_LOC(31)
|
||||
SET_LOC(32); SET_LOC(33); SET_LOC(34); SET_LOC(35)
|
||||
SET_LOC(36); SET_LOC(37); SET_LOC(38); SET_LOC(39)
|
||||
SET_LOC(40); SET_LOC(41); SET_LOC(42); SET_LOC(43)
|
||||
SET_LOC(44); SET_LOC(45); SET_LOC(46); SET_LOC(47)
|
||||
SET_LOC(48); SET_LOC(49); SET_LOC(50); SET_LOC(51)
|
||||
SET_LOC(52); SET_LOC(53); SET_LOC(54); SET_LOC(55)
|
||||
SET_LOC(56); SET_LOC(57); SET_LOC(58); SET_LOC(59)
|
||||
SET_LOC(60); SET_LOC(61); SET_LOC(62); SET_LOC(63)
|
||||
SET_LOC(64); SET_LOC(65); SET_LOC(66); SET_LOC(67)
|
||||
SET_LOC(68); SET_LOC(69); SET_LOC(70); SET_LOC(71)
|
||||
SET_LOC(72); SET_LOC(73); SET_LOC(74); SET_LOC(75)
|
||||
SET_LOC(76); SET_LOC(77); SET_LOC(78); SET_LOC(79)
|
||||
SET_LOC(80); SET_LOC(81); SET_LOC(82); SET_LOC(83)
|
||||
SET_LOC(84); SET_LOC(85); SET_LOC(86); SET_LOC(87)
|
||||
SET_LOC(88); SET_LOC(89); SET_LOC(90); SET_LOC(91)
|
||||
SET_LOC(92); SET_LOC(93)
|
||||
;;
|
||||
SET_NAT(2); SET_NAT(31); SET_NAT(73); SET_NAT(93)
|
||||
;;
|
||||
{ .mbb
|
||||
mov r8=NSTACKS-1
|
||||
(p6) br.call.sptk.many rp = stack_it
|
||||
(p7) br.call.sptk.many rp = touch_all
|
||||
}
|
||||
;;
|
||||
|
||||
mov rp = loc0
|
||||
mov ar.pfs = loc1
|
||||
br.ret.sptk.many rp
|
||||
.endp touch_all
|
|
@ -0,0 +1,101 @@
|
|||
/* libunwind - a platform-independent unwind library
|
||||
Copyright (C) 2003 Hewlett-Packard Co
|
||||
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
|
||||
|
||||
This file is part of libunwind.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
|
||||
/* This file tests corner-cases of unwinding across multiple stacks.
|
||||
In particular, it verifies that the extreme case with a frame of 96
|
||||
stacked registers that are all backed up by separate stacks works
|
||||
as expected. */
|
||||
|
||||
#include <libunwind.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* The loadrs field in ar.rsc is 14 bits wide, which limits all ia64
|
||||
implementations to at most 2048 physical stacked registers
|
||||
(actually, slightly less than that, because loadrs also counts RNaT
|
||||
slots). Since we can dirty 95 stacked registers per recursion, we
|
||||
need to recurse RECURSION_DEPTH times to ensure all physical
|
||||
stacked registers are in use. */
|
||||
#define MAX_PHYS_STACKED 2048
|
||||
#define RECURSION_DEPTH ((MAX_PHYS_STACKED + 94) / 95)
|
||||
|
||||
extern void touch_all (unsigned long recursion_depth);
|
||||
extern void flushrs (void);
|
||||
|
||||
void
|
||||
do_unwind_tests (void)
|
||||
{
|
||||
unw_word_t ip, sp, bsp, v0, v1, v2, v3, n0, n1, n2, n3;
|
||||
unw_context_t uc;
|
||||
unw_cursor_t c;
|
||||
int ret, reg;
|
||||
|
||||
printf ("do_unwind_tests: here we go!\n");
|
||||
|
||||
unw_getcontext (&uc);
|
||||
unw_init_local (&c, &uc);
|
||||
|
||||
do
|
||||
{
|
||||
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_BSP, &bsp)) < 0)
|
||||
break;
|
||||
printf ("ip=0x%16lx sp=0x%16lx bsp=0x%16lx\n", ip, sp, bsp);
|
||||
|
||||
for (reg = 32; reg < 128; reg += 4)
|
||||
{
|
||||
v0 = v1 = v2 = v3 = 0;
|
||||
n0 = n1 = n2 = n3 = 0;
|
||||
((ret = unw_get_reg (&c, UNW_IA64_GR + reg, &v0)) < 0
|
||||
|| (ret = unw_get_reg (&c, UNW_IA64_NAT + reg, &n0)) < 0
|
||||
|| (ret = unw_get_reg (&c, UNW_IA64_GR + reg + 1, &v1)) < 0
|
||||
|| (ret = unw_get_reg (&c, UNW_IA64_NAT + reg + 1, &n1)) < 0
|
||||
|| (ret = unw_get_reg (&c, UNW_IA64_GR + reg + 2, &v2)) < 0
|
||||
|| (ret = unw_get_reg (&c, UNW_IA64_NAT + reg + 2, &n2)) < 0
|
||||
|| (ret = unw_get_reg (&c, UNW_IA64_GR + reg + 3, &v3)) < 0
|
||||
|| (ret = unw_get_reg (&c, UNW_IA64_NAT + reg + 3, &n3)) < 0);
|
||||
if (reg < 100)
|
||||
printf (" r%d", reg);
|
||||
else
|
||||
printf (" r%d", reg);
|
||||
printf (" %c%016lx %c%016lx %c%016lx %c%016lx\n",
|
||||
n0 ? '*' : ' ', v0, n1 ? '*' : ' ', v1,
|
||||
n2 ? '*' : ' ', v2, n3 ? '*' : ' ', v3);
|
||||
if (ret < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ((ret = unw_step (&c)) > 0);
|
||||
|
||||
if (ret < 0)
|
||||
printf ("libunwind returned %d\n", ret);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
touch_all (RECURSION_DEPTH);
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue