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 | |
mostang.com!davidm | db59d4f | 2002-12-19 07:16:50 +0000 | [diff] [blame] | 34 | struct ia64_script_insn |
| 35 | { |
mostang.com!davidm | 50f7edc | 2004-02-27 08:54:25 +0000 | [diff] [blame] | 36 | unsigned int opc; /* see enum ia64_script_insn_opcode */ |
mostang.com!davidm | db59d4f | 2002-12-19 07:16:50 +0000 | [diff] [blame] | 37 | unsigned int dst; |
| 38 | unw_word_t val; |
| 39 | }; |
| 40 | |
mostang.com!davidm | 50f7edc | 2004-02-27 08:54:25 +0000 | [diff] [blame] | 41 | /* Updating each preserved register may result in one script |
| 42 | instruction each. At the end of the script, psp gets popped, |
| 43 | accounting for one more instruction. */ |
| 44 | #define IA64_MAX_SCRIPT_LEN (IA64_NUM_PREGS + 1) |
mostang.com!davidm | db59d4f | 2002-12-19 07:16:50 +0000 | [diff] [blame] | 45 | |
| 46 | struct ia64_script |
| 47 | { |
| 48 | unw_word_t ip; /* ip this script is for */ |
| 49 | unw_word_t pr_mask; /* mask of predicates script depends on */ |
| 50 | unw_word_t pr_val; /* predicate values this script is for */ |
| 51 | unw_proc_info_t pi; /* info about underlying procedure */ |
| 52 | unsigned short lru_chain; /* used for least-recently-used chain */ |
| 53 | unsigned short coll_chain; /* used for hash collisions */ |
| 54 | unsigned short hint; /* hint for next script to try (or -1) */ |
| 55 | unsigned short count; /* number of instructions in script */ |
mostang.com!davidm | 78a7c5a | 2003-04-23 05:56:59 +0000 | [diff] [blame] | 56 | unsigned short abi_marker; |
mostang.com!davidm | db59d4f | 2002-12-19 07:16:50 +0000 | [diff] [blame] | 57 | struct ia64_script_insn insn[IA64_MAX_SCRIPT_LEN]; |
| 58 | }; |
| 59 | |
| 60 | struct ia64_script_cache |
| 61 | { |
hp.com!davidm | d61f300 | 2003-11-24 23:53:25 +0000 | [diff] [blame] | 62 | #ifdef HAVE_ATOMIC_OPS_H |
mostang.com!davidm | cd7dcba | 2004-01-20 23:50:00 +0000 | [diff] [blame] | 63 | AO_TS_t busy; /* is the script-cache busy? */ |
hp.com!davidm | d61f300 | 2003-11-24 23:53:25 +0000 | [diff] [blame] | 64 | #else |
mostang.com!davidm | 57bdcfe | 2003-03-06 06:14:36 +0000 | [diff] [blame] | 65 | pthread_mutex_t lock; |
hp.com!davidm | d61f300 | 2003-11-24 23:53:25 +0000 | [diff] [blame] | 66 | #endif |
mostang.com!davidm | db59d4f | 2002-12-19 07:16:50 +0000 | [diff] [blame] | 67 | unsigned short lru_head; /* index of lead-recently used script */ |
| 68 | unsigned short lru_tail; /* index of most-recently used script */ |
| 69 | |
| 70 | /* hash table that maps instruction pointer to script index: */ |
| 71 | unsigned short hash[IA64_UNW_HASH_SIZE]; |
| 72 | |
| 73 | uint32_t generation; /* generation number */ |
| 74 | |
| 75 | /* script cache: */ |
| 76 | struct ia64_script buckets[IA64_UNW_CACHE_SIZE]; |
| 77 | }; |
| 78 | |
mostang.com!davidm | 57bdcfe | 2003-03-06 06:14:36 +0000 | [diff] [blame] | 79 | #define ia64_get_cached_proc_info UNW_OBJ(ia64_get_cached_proc_info) |
mostang.com!davidm | db59d4f | 2002-12-19 07:16:50 +0000 | [diff] [blame] | 80 | |
| 81 | struct cursor; /* forward declaration */ |
| 82 | |
mostang.com!davidm | 57bdcfe | 2003-03-06 06:14:36 +0000 | [diff] [blame] | 83 | extern int ia64_get_cached_proc_info (struct cursor *c); |