2 * arch/s390/oprofile/backtrace.c
5 * Copyright (C) 2005 IBM Corporation, IBM Deutschland Entwicklung GmbH.
6 * Author(s): Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
9 #include <linux/oprofile.h>
11 #include <asm/processor.h> /* for struct stack_frame */
14 __show_trace(unsigned int *depth, unsigned long sp,
15 unsigned long low, unsigned long high)
17 struct stack_frame *sf;
21 sp = sp & PSW_ADDR_INSN;
22 if (sp < low || sp > high - sizeof(*sf))
24 sf = (struct stack_frame *) sp;
26 oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN);
28 /* Follow the backchain. */
31 sp = sf->back_chain & PSW_ADDR_INSN;
34 if (sp <= low || sp > high - sizeof(*sf))
36 sf = (struct stack_frame *) sp;
38 oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN);
45 /* Zero backchain detected, check for interrupt frame. */
46 sp = (unsigned long) (sf + 1);
47 if (sp <= low || sp > high - sizeof(*regs))
49 regs = (struct pt_regs *) sp;
51 oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN);
58 void s390_backtrace(struct pt_regs * const regs, unsigned int depth)
61 struct stack_frame* head_sf;
66 head = regs->gprs[15];
67 head_sf = (struct stack_frame*)head;
69 if (!head_sf->back_chain)
72 head = head_sf->back_chain;
74 head = __show_trace(&depth, head, S390_lowcore.async_stack - ASYNC_SIZE,
75 S390_lowcore.async_stack);
77 __show_trace(&depth, head, S390_lowcore.thread_info,
78 S390_lowcore.thread_info + THREAD_SIZE);