1 /* Target-dependent code for the IA-64 for GDB, the GNU debugger. 2 Copyright 2000, 2001 3 Free Software Foundation, Inc. 4 5 This file is part of GDB. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place - Suite 330, 20 Boston, MA 02111-1307, USA. */ 21 22 #include "defs.h" 23 24 /* External hook for finding gate addresses on AIX. */ 25 void (*aix5_find_gate_addresses_hook) (CORE_ADDR *, CORE_ADDR *) = 0; 26 27 /* Offset to sc_context member of sigcontext structure from frame of handler */ 28 #define IA64_AIX_SIGCONTEXT_OFFSET 64 29 30 /* Return a non-zero value iff PC is in a signal trampoline. On 31 AIX, we determine this by seeing if the pc is in a special 32 execute only page called the ``gate page''. The addresses in 33 question are determined by letting the AIX native portion of 34 the code determine these addresses via its own nefarious 35 means. */ 36 37 int 38 ia64_aix_in_sigtramp (CORE_ADDR pc, char *func_name) 39 { 40 CORE_ADDR gate_area_start, gate_area_end; 41 42 if (aix5_find_gate_addresses_hook == 0) 43 return 0; 44 45 (*aix5_find_gate_addresses_hook) (&gate_area_start, &gate_area_end); 46 47 return (pc >= gate_area_start && pc < gate_area_end); 48 } 49 50 51 /* IA-64 AIX specific function which, given a frame address and 52 a register number, returns the address at which that register may be 53 found. 0 is returned for registers which aren't stored in the 54 sigcontext structure. */ 55 56 CORE_ADDR 57 ia64_aix_sigcontext_register_address (CORE_ADDR sp, int regno) 58 { 59 /* The hardcoded offsets that follow are actually offsets to the 60 corresponding members in struct __context in 61 /usr/include/sys/context.h (on an IA-64 AIX5 box). */ 62 if (IA64_GR0_REGNUM <= regno && regno <= IA64_GR31_REGNUM) 63 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 152 + 8 * (regno - IA64_GR0_REGNUM); 64 else if (IA64_BR0_REGNUM <= regno && regno <= IA64_BR7_REGNUM) 65 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 408 + 8 * (regno - IA64_BR0_REGNUM); 66 else if (IA64_FR0_REGNUM <= regno && regno <= IA64_FR127_REGNUM) 67 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 480 + 16 * (regno - IA64_FR0_REGNUM); 68 else 69 switch (regno) 70 { 71 case IA64_PSR_REGNUM : 72 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 0; 73 case IA64_IP_REGNUM : 74 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 8; 75 /* iipa is at 16. 76 isr is at 24. 77 ifa is at 32. 78 iim is at 40. */ 79 case IA64_CFM_REGNUM : 80 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 48; /* ifs, actually */ 81 case IA64_RSC_REGNUM : 82 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 56; 83 case IA64_BSP_REGNUM : 84 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 64; 85 case IA64_BSPSTORE_REGNUM : 86 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 72; 87 case IA64_RNAT_REGNUM : 88 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 80; 89 case IA64_PFS_REGNUM : 90 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 88; 91 case IA64_UNAT_REGNUM : 92 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 96; 93 case IA64_PR_REGNUM : 94 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 104; 95 case IA64_CCV_REGNUM : 96 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 112; 97 case IA64_LC_REGNUM : 98 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 120; 99 case IA64_EC_REGNUM : 100 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 128; 101 /* nats is at 136; this is an address independent NaT bitmask */ 102 case IA64_FPSR_REGNUM : 103 return sp + IA64_AIX_SIGCONTEXT_OFFSET + 144; 104 default : 105 return 0; 106 } 107 } 108