1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * s390x stack implementation 4 * 5 * Copyright (c) 2017 Red Hat Inc 6 * Copyright 2021 IBM Corp 7 * 8 * Authors: 9 * Thomas Huth <thuth@redhat.com> 10 * David Hildenbrand <david@redhat.com> 11 * Janosch Frank <frankja@linux.ibm.com> 12 */ 13 #include <libcflat.h> 14 #include <stack.h> 15 #include <asm/arch_def.h> 16 arch_backtrace_frame(const void * frame,const void ** return_addrs,int max_depth,bool current_frame)17int arch_backtrace_frame(const void *frame, const void **return_addrs, 18 int max_depth, bool current_frame) 19 { 20 int depth = 0; 21 struct stack_frame *stack = (struct stack_frame *)frame; 22 23 if (current_frame) 24 stack = __builtin_frame_address(0); 25 26 for (depth = 0; stack && depth < max_depth; depth++) { 27 return_addrs[depth] = (void *)stack->grs[8]; 28 stack = stack->back_chain; 29 if (!stack) 30 break; 31 } 32 33 return depth; 34 } 35