mostang.com!davidm | fb9b517 | 2002-04-04 19:04:09 +0000 | [diff] [blame] | 1 | /* libunwind - a platform-independent unwind library |
| 2 | Copyright (C) 2002 Hewlett-Packard Co |
| 3 | Contributed by David Mosberger-Tang <davidm@hpl.hp.com> |
| 4 | |
| 5 | This file is part of libunwind. |
| 6 | |
mostang.com!davidm | aca3843 | 2002-11-16 03:25:36 +0000 | [diff] [blame] | 7 | Permission is hereby granted, free of charge, to any person obtaining |
| 8 | a copy of this software and associated documentation files (the |
| 9 | "Software"), to deal in the Software without restriction, including |
| 10 | without limitation the rights to use, copy, modify, merge, publish, |
| 11 | distribute, sublicense, and/or sell copies of the Software, and to |
| 12 | permit persons to whom the Software is furnished to do so, subject to |
| 13 | the following conditions: |
mostang.com!davidm | fb9b517 | 2002-04-04 19:04:09 +0000 | [diff] [blame] | 14 | |
mostang.com!davidm | aca3843 | 2002-11-16 03:25:36 +0000 | [diff] [blame] | 15 | The above copyright notice and this permission notice shall be |
| 16 | included in all copies or substantial portions of the Software. |
mostang.com!davidm | fb9b517 | 2002-04-04 19:04:09 +0000 | [diff] [blame] | 17 | |
mostang.com!davidm | aca3843 | 2002-11-16 03:25:36 +0000 | [diff] [blame] | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 22 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
mostang.com!davidm | fb9b517 | 2002-04-04 19:04:09 +0000 | [diff] [blame] | 25 | |
| 26 | #include "unwind_i.h" |
| 27 | |
mostang.com!davidm | 9ac7c9c | 2002-07-18 03:58:34 +0000 | [diff] [blame] | 28 | static inline int |
mostang.com!davidm | c333cb0 | 2002-12-19 07:16:50 +0000 | [diff] [blame^] | 29 | common_init (struct cursor *c) |
mostang.com!davidm | fb9b517 | 2002-04-04 19:04:09 +0000 | [diff] [blame] | 30 | { |
| 31 | int i, ret; |
| 32 | |
| 33 | c->cfm_loc = IA64_REG_LOC (c, UNW_IA64_CFM); |
| 34 | c->top_rnat_loc = IA64_REG_LOC (c, UNW_IA64_AR_RNAT); |
| 35 | c->bsp_loc = IA64_REG_LOC (c, UNW_IA64_AR_BSP); |
| 36 | c->bspstore_loc = IA64_REG_LOC (c, UNW_IA64_AR_BSPSTORE); |
| 37 | c->pfs_loc = IA64_REG_LOC (c, UNW_IA64_AR_PFS); |
| 38 | c->rnat_loc = IA64_REG_LOC (c, UNW_IA64_AR_RNAT); |
| 39 | c->ip_loc = IA64_REG_LOC (c, UNW_IA64_IP); |
| 40 | c->pri_unat_loc = 0; /* no primary UNaT location */ |
| 41 | c->unat_loc = IA64_REG_LOC (c, UNW_IA64_AR_UNAT); |
| 42 | c->pr_loc = IA64_REG_LOC (c, UNW_IA64_PR); |
| 43 | c->lc_loc = IA64_REG_LOC (c, UNW_IA64_AR_LC); |
| 44 | c->fpsr_loc = IA64_REG_LOC (c, UNW_IA64_AR_FPSR); |
| 45 | |
| 46 | c->r4_loc = IA64_REG_LOC (c, UNW_IA64_GR + 4); |
| 47 | c->r5_loc = IA64_REG_LOC (c, UNW_IA64_GR + 5); |
| 48 | c->r6_loc = IA64_REG_LOC (c, UNW_IA64_GR + 6); |
| 49 | c->r7_loc = IA64_REG_LOC (c, UNW_IA64_GR + 7); |
| 50 | |
| 51 | /* This says that each NaT bit is stored along with the |
| 52 | corresponding preserved register: */ |
| 53 | c->nat4_loc = IA64_LOC (4, 0); |
| 54 | c->nat5_loc = IA64_LOC (5, 0); |
| 55 | c->nat6_loc = IA64_LOC (6, 0); |
| 56 | c->nat7_loc = IA64_LOC (7, 0); |
| 57 | |
| 58 | c->b1_loc = IA64_REG_LOC (c, UNW_IA64_BR + 1); |
| 59 | c->b2_loc = IA64_REG_LOC (c, UNW_IA64_BR + 2); |
| 60 | c->b3_loc = IA64_REG_LOC (c, UNW_IA64_BR + 3); |
| 61 | c->b4_loc = IA64_REG_LOC (c, UNW_IA64_BR + 4); |
| 62 | c->b5_loc = IA64_REG_LOC (c, UNW_IA64_BR + 5); |
| 63 | |
| 64 | c->f2_loc = IA64_FPREG_LOC (c, UNW_IA64_FR + 2); |
| 65 | c->f3_loc = IA64_FPREG_LOC (c, UNW_IA64_FR + 3); |
| 66 | c->f4_loc = IA64_FPREG_LOC (c, UNW_IA64_FR + 4); |
| 67 | c->f5_loc = IA64_FPREG_LOC (c, UNW_IA64_FR + 5); |
| 68 | for (i = 16; i <= 31; ++i) |
| 69 | c->fr_loc[i - 16] = IA64_FPREG_LOC (c, UNW_IA64_FR + i); |
| 70 | |
| 71 | ret = ia64_get (c, c->pr_loc, &c->pr); |
| 72 | if (ret < 0) |
| 73 | return ret; |
| 74 | |
| 75 | ret = ia64_get (c, c->ip_loc, &c->ip); |
| 76 | if (ret < 0) |
| 77 | return ret; |
| 78 | |
| 79 | ret = ia64_get (c, IA64_REG_LOC (c, UNW_IA64_GR + 12), &c->sp); |
| 80 | if (ret < 0) |
| 81 | return ret; |
| 82 | |
| 83 | c->psp = c->sp; |
| 84 | |
| 85 | ret = ia64_get (c, c->bsp_loc, &c->bsp); |
| 86 | if (ret < 0) |
| 87 | return ret; |
| 88 | |
| 89 | c->rbs_top = c->bsp; |
| 90 | c->pi.flags = 0; |
| 91 | |
| 92 | #ifdef UNW_LOCAL_ONLY |
| 93 | c->eh_args[0] = c->eh_args[1] = c->eh_args[2] = c->eh_args[3] = 0; |
| 94 | #else |
| 95 | for (i = 0; i < 4; ++i) |
| 96 | { |
| 97 | ret = ia64_get (c, IA64_REG_LOC (c, UNW_IA64_GR + 15 + i), |
| 98 | &c->eh_args[i]); |
| 99 | if (ret < 0) |
| 100 | { |
| 101 | if (ret == -UNW_EBADREG) |
| 102 | c->eh_args[i] = 0; |
| 103 | else |
| 104 | return ret; |
| 105 | } |
| 106 | } |
| 107 | #endif |
mostang.com!davidm | c56126e | 2002-04-25 06:47:29 +0000 | [diff] [blame] | 108 | c->sigcontext_loc = 0; |
mostang.com!davidm | 2e05058 | 2002-12-12 09:17:41 +0000 | [diff] [blame] | 109 | c->is_signal_frame = 0; |
mostang.com!davidm | fb9b517 | 2002-04-04 19:04:09 +0000 | [diff] [blame] | 110 | |
mostang.com!davidm | fb9b517 | 2002-04-04 19:04:09 +0000 | [diff] [blame] | 111 | c->hint = 0; |
| 112 | c->prev_script = 0; |
mostang.com!davidm | 2e05058 | 2002-12-12 09:17:41 +0000 | [diff] [blame] | 113 | c->pi_valid = 0; |
| 114 | return 0; |
mostang.com!davidm | fb9b517 | 2002-04-04 19:04:09 +0000 | [diff] [blame] | 115 | } |