mostang.com!davidm | db59d4f | 2002-12-19 07:16:50 +0000 | [diff] [blame^] | 1 | /* libunwind - a platform-independent unwind library |
| 2 | Copyright (C) 2001-2002 Hewlett-Packard Co |
| 3 | Contributed by David Mosberger-Tang <davidm@hpl.hp.com> |
| 4 | |
| 5 | This file is part of libunwind. |
| 6 | |
| 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: |
| 14 | |
| 15 | The above copyright notice and this permission notice shall be |
| 16 | included in all copies or substantial portions of the Software. |
| 17 | |
| 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. */ |
| 25 | |
| 26 | #define IA64_LOG_UNW_CACHE_SIZE 7 |
| 27 | #define IA64_UNW_CACHE_SIZE (1 << IA64_LOG_UNW_CACHE_SIZE) |
| 28 | |
| 29 | #define IA64_LOG_UNW_HASH_SIZE (IA64_LOG_UNW_CACHE_SIZE + 1) |
| 30 | #define IA64_UNW_HASH_SIZE (1 << IA64_LOG_UNW_HASH_SIZE) |
| 31 | |
| 32 | typedef unsigned char unw_hash_index_t; |
| 33 | |
| 34 | enum ia64_script_insn_opcode |
| 35 | { |
| 36 | IA64_INSN_SET, /* s[dst] = val */ |
| 37 | IA64_INSN_ADD, /* s[dst] += val */ |
| 38 | IA64_INSN_ADD_PSP, /* s[dst] = (s.psp + val) */ |
| 39 | IA64_INSN_ADD_SP, /* s[dst] = (s.sp + val) */ |
| 40 | IA64_INSN_MOVE, /* s[dst] = s[val] */ |
| 41 | IA64_INSN_MOVE_STACKED, /* s[dst] = ia64_rse_skip(*s.bsp_loc, val) */ |
| 42 | IA64_INSN_MOVE_SCRATCH, /* s[dst] = scratch reg "val" */ |
| 43 | IA64_INSN_SETNAT_MEMSTK, /* s[dst].nat.type = s.pri_unat_loc | MEMSTK */ |
| 44 | IA64_INSN_LOAD /* s[dst] = *s[val] */ |
| 45 | }; |
| 46 | |
| 47 | /* libunwind - a platform-independent unwind library |
| 48 | Copyright (C) 2001-2002 Hewlett-Packard Co |
| 49 | Contributed by David Mosberger-Tang <davidm@hpl.hp.com> |
| 50 | |
| 51 | This file is part of libunwind. |
| 52 | |
| 53 | Permission is hereby granted, free of charge, to any person obtaining |
| 54 | a copy of this software and associated documentation files (the |
| 55 | "Software"), to deal in the Software without restriction, including |
| 56 | without limitation the rights to use, copy, modify, merge, publish, |
| 57 | distribute, sublicense, and/or sell copies of the Software, and to |
| 58 | permit persons to whom the Software is furnished to do so, subject to |
| 59 | the following conditions: |
| 60 | |
| 61 | The above copyright notice and this permission notice shall be |
| 62 | included in all copies or substantial portions of the Software. |
| 63 | |
| 64 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 65 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 66 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 67 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 68 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 69 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 70 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 71 | |
| 72 | struct ia64_script_insn |
| 73 | { |
| 74 | unsigned int opc; |
| 75 | unsigned int dst; |
| 76 | unw_word_t val; |
| 77 | }; |
| 78 | |
| 79 | /* Preserved general static registers (r4-r7) give rise to two script |
| 80 | instructions; everything else yields at most one instruction; at |
| 81 | the end of the script, the psp gets popped, accounting for one more |
| 82 | instruction. */ |
| 83 | #define IA64_MAX_SCRIPT_LEN (IA64_NUM_PREGS + 5) |
| 84 | |
| 85 | struct ia64_script |
| 86 | { |
| 87 | unw_word_t ip; /* ip this script is for */ |
| 88 | unw_word_t pr_mask; /* mask of predicates script depends on */ |
| 89 | unw_word_t pr_val; /* predicate values this script is for */ |
| 90 | unw_proc_info_t pi; /* info about underlying procedure */ |
| 91 | unsigned short lru_chain; /* used for least-recently-used chain */ |
| 92 | unsigned short coll_chain; /* used for hash collisions */ |
| 93 | unsigned short hint; /* hint for next script to try (or -1) */ |
| 94 | unsigned short count; /* number of instructions in script */ |
| 95 | struct ia64_script_insn insn[IA64_MAX_SCRIPT_LEN]; |
| 96 | }; |
| 97 | |
| 98 | struct ia64_script_cache |
| 99 | { |
| 100 | unsigned short lru_head; /* index of lead-recently used script */ |
| 101 | unsigned short lru_tail; /* index of most-recently used script */ |
| 102 | |
| 103 | /* hash table that maps instruction pointer to script index: */ |
| 104 | unsigned short hash[IA64_UNW_HASH_SIZE]; |
| 105 | |
| 106 | uint32_t generation; /* generation number */ |
| 107 | |
| 108 | /* script cache: */ |
| 109 | struct ia64_script buckets[IA64_UNW_CACHE_SIZE]; |
| 110 | }; |
| 111 | |
| 112 | #define ia64_script_lookup UNW_OBJ(ia64_script_lookup) |
| 113 | |
| 114 | struct cursor; /* forward declaration */ |
| 115 | |
| 116 | extern struct ia64_script *ia64_script_lookup (struct cursor *c); |