1 /* Return backtrace of current program state. 64 bit S/390 version.
2 Copyright (C) 2001 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
25 /* This is a global variable set at program start time. It marks the
26 highest used stack address. */
27 extern void *__libc_stack_end;
30 /* This is the stack layout we see for every non-leaf function.
32 %r15 -> +------------------+
36 80 | save area r6-r15 | 48
37 16 | save area f4,f6 | 128
40 r14 in the save area holds the return address.
54 __backtrace (array, size)
58 /* We assume that all the code is generated with frame pointers set. */
62 asm ("LGR %0,%%r15" : "=d" (stack) );
63 /* We skip the call to this function, it makes no sense to record it. */
64 stack = (struct layout *) stack->back_chain;
67 if (stack == NULL || (void *) stack > __libc_stack_end)
68 /* This means the address is out of range. Note that for the
69 toplevel we see a frame pointer with value NULL which clearly is
73 array[cnt++] = stack->save_grps[9];
75 stack = (struct layout *) stack->back_chain;
80 weak_alias (__backtrace, backtrace)