| 1 |
/* -*- linux-c -*- |
| 2 |
* |
| 3 |
* ppc64 dwarf unwinder header file |
| 4 |
* Copyright (C) 2011 Red Hat, Inc. |
| 5 |
* |
| 6 |
* This file is part of systemtap, and is free software. You can |
| 7 |
* redistribute it and/or modify it under the terms of the GNU General |
| 8 |
* Public License (GPL); either version 2, or (at your option) any |
| 9 |
* later version. |
| 10 |
*/ |
| 11 |
#ifndef _STP_PPC64_UNWIND_H |
| 12 |
#define _STP_PPC64_UNWIND_H |
| 13 |
|
| 14 |
#include <linux/sched.h> |
| 15 |
#include <asm/ptrace.h> |
| 16 |
|
| 17 |
#define _stp_get_unaligned(ptr) (*(ptr)) |
| 18 |
|
| 19 |
#define UNW_PC(frame) (frame)->regs.nip |
| 20 |
#define UNW_SP(frame) (frame)->regs.gpr[1] |
| 21 |
|
| 22 |
#define STACK_LIMIT(ptr) (((ptr) - 1) & ~(THREAD_SIZE - 1)) |
| 23 |
|
| 24 |
#define UNW_REGISTER_INFO \ |
| 25 |
PTREGS_INFO(gpr[0]), \ |
| 26 |
PTREGS_INFO(gpr[1]), \ |
| 27 |
PTREGS_INFO(gpr[2]), \ |
| 28 |
PTREGS_INFO(gpr[3]), \ |
| 29 |
PTREGS_INFO(gpr[4]), \ |
| 30 |
PTREGS_INFO(gpr[5]), \ |
| 31 |
PTREGS_INFO(gpr[6]), \ |
| 32 |
PTREGS_INFO(gpr[7]), \ |
| 33 |
PTREGS_INFO(gpr[8]), \ |
| 34 |
PTREGS_INFO(gpr[9]), \ |
| 35 |
PTREGS_INFO(gpr[10]), \ |
| 36 |
PTREGS_INFO(gpr[11]), \ |
| 37 |
PTREGS_INFO(gpr[12]), \ |
| 38 |
PTREGS_INFO(gpr[13]), \ |
| 39 |
PTREGS_INFO(gpr[14]), \ |
| 40 |
PTREGS_INFO(gpr[15]), \ |
| 41 |
PTREGS_INFO(gpr[16]), \ |
| 42 |
PTREGS_INFO(gpr[17]), \ |
| 43 |
PTREGS_INFO(gpr[18]), \ |
| 44 |
PTREGS_INFO(gpr[19]), \ |
| 45 |
PTREGS_INFO(gpr[20]), \ |
| 46 |
PTREGS_INFO(gpr[21]), \ |
| 47 |
PTREGS_INFO(gpr[22]), \ |
| 48 |
PTREGS_INFO(gpr[23]), \ |
| 49 |
PTREGS_INFO(gpr[24]), \ |
| 50 |
PTREGS_INFO(gpr[25]), \ |
| 51 |
PTREGS_INFO(gpr[26]), \ |
| 52 |
PTREGS_INFO(gpr[27]), \ |
| 53 |
PTREGS_INFO(gpr[28]), \ |
| 54 |
PTREGS_INFO(gpr[29]), \ |
| 55 |
PTREGS_INFO(gpr[30]), \ |
| 56 |
PTREGS_INFO(gpr[31]), \ |
| 57 |
PTREGS_INFO(softe), \ |
| 58 |
PTREGS_INFO(ctr), \ |
| 59 |
PTREGS_INFO(link), \ |
| 60 |
PTREGS_INFO(nip) |
| 61 |
|
| 62 |
/* These are slightly strange since they don't really use dwarf register |
| 63 |
mappings, but gcc internal register numbers. There is some confusion about |
| 64 |
the numbering see http://gcc.gnu.org/ml/gcc/2004-01/msg00025.html |
| 65 |
We just handle the 32 fixed point registers, mq, count and link and |
| 66 |
ignore status registers, floating point, vectors and special registers |
| 67 |
(most of which aren't available in pt_regs anyway). Also we placed nip |
| 68 |
last since we use that as UNW_PC register and it needs to be filled in. |
| 69 |
Note that we handle both the .eh_frame and .debug_frame numbering at |
| 70 |
the same time. There is potential overlap though. 64 maps to cr in one |
| 71 |
and mq in the other... |
| 72 |
Everything else is mapped to an invalid register number 9999. */ |
| 73 |
#define DWARF_REG_MAP(r) \ |
| 74 |
((r >= 0 && r <= 31) ? r /* r0 - r31 */ \ |
| 75 |
: (r == 64 || r == 100) ? 32 /* mq/softe/spr0 */ \ |
| 76 |
: (r == 65 || r == 108) ? 34 /* link */ \ |
| 77 |
: (r == 66 || r == 109) ? 33 /* ctr */ \ |
| 78 |
: 9999) |
| 79 |
|
| 80 |
#define UNW_PC_IDX 35 |
| 81 |
#define UNW_SP_IDX 1 |
| 82 |
|
| 83 |
#define UNW_NR_REAL_REGS 35 /* We don't count nip. */ |
| 84 |
|
| 85 |
static inline void arch_unw_init_frame_info(struct unwind_frame_info *info, |
| 86 |
/*const*/ struct pt_regs *regs, |
| 87 |
int sanitize) |
| 88 |
{ |
| 89 |
if (&info->regs == regs) { /* happens when unwinding kernel->user */ |
| 90 |
info->call_frame = 1; |
| 91 |
return; |
| 92 |
} |
| 93 |
|
| 94 |
memset(info, 0, sizeof(*info)); |
| 95 |
/* XXX handle sanitize??? */ |
| 96 |
info->regs = *regs; |
| 97 |
} |
| 98 |
|
| 99 |
#endif /* _STP_PPC64_UNWIND_H */ |