112f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm/* libunwind - a platform-independent unwind library 212f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm Copyright (C) 2001-2002 Hewlett-Packard Co 312f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm Contributed by David Mosberger-Tang <davidm@hpl.hp.com> 412f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 512f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmThis file is part of libunwind. 612f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 712f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmPermission is hereby granted, free of charge, to any person obtaining 812f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidma copy of this software and associated documentation files (the 912f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm"Software"), to deal in the Software without restriction, including 1012f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmwithout limitation the rights to use, copy, modify, merge, publish, 1112f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmdistribute, sublicense, and/or sell copies of the Software, and to 1212f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmpermit persons to whom the Software is furnished to do so, subject to 1312f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmthe following conditions: 1412f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 1512f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmThe above copyright notice and this permission notice shall be 1612f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmincluded in all copies or substantial portions of the Software. 1712f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 1812f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1912f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2012f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2112f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 2212f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 2312f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 2412f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 2512f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 2612f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm#define IA64_LOG_UNW_CACHE_SIZE 7 2712f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm#define IA64_UNW_CACHE_SIZE (1 << IA64_LOG_UNW_CACHE_SIZE) 2812f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 2912f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm#define IA64_LOG_UNW_HASH_SIZE (IA64_LOG_UNW_CACHE_SIZE + 1) 3012f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm#define IA64_UNW_HASH_SIZE (1 << IA64_LOG_UNW_HASH_SIZE) 3112f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 3212f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmtypedef unsigned char unw_hash_index_t; 3312f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 3412f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmstruct ia64_script_insn 3512f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm { 3612f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unsigned int opc; /* see enum ia64_script_insn_opcode */ 3712f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unsigned int dst; 3812f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unw_word_t val; 3912f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm }; 4012f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 4112f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm/* Updating each preserved register may result in one script 4212f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm instruction each. At the end of the script, psp gets popped, 4312f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm accounting for one more instruction. */ 4412f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm#define IA64_MAX_SCRIPT_LEN (IA64_NUM_PREGS + 1) 4512f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 4612f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmstruct ia64_script 4712f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm { 4812f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unw_word_t ip; /* ip this script is for */ 4912f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unw_word_t pr_mask; /* mask of predicates script depends on */ 5012f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unw_word_t pr_val; /* predicate values this script is for */ 5112f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unw_proc_info_t pi; /* info about underlying procedure */ 5212f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unsigned short lru_chain; /* used for least-recently-used chain */ 5312f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unsigned short coll_chain; /* used for hash collisions */ 5412f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unsigned short hint; /* hint for next script to try (or -1) */ 5512f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unsigned short count; /* number of instructions in script */ 5612f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unsigned short abi_marker; 5712f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm struct ia64_script_insn insn[IA64_MAX_SCRIPT_LEN]; 5812f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm }; 5912f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 6012f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmstruct ia64_script_cache 6112f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm { 6212f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm#ifdef HAVE_ATOMIC_OPS_H 6312f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm AO_TS_t busy; /* is the script-cache busy? */ 6412f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm#else 6512f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm pthread_mutex_t lock; 6612f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm#endif 6712f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unsigned short lru_head; /* index of lead-recently used script */ 6812f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unsigned short lru_tail; /* index of most-recently used script */ 6912f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 7012f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm /* hash table that maps instruction pointer to script index: */ 7112f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm unsigned short hash[IA64_UNW_HASH_SIZE]; 7212f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 7312f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm uint32_t generation; /* generation number */ 7412f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 7512f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm /* script cache: */ 7612f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm struct ia64_script buckets[IA64_UNW_CACHE_SIZE]; 7712f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm }; 7812f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 7912f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm#define ia64_cache_proc_info UNW_OBJ(cache_proc_info) 8012f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm#define ia64_get_cached_proc_info UNW_OBJ(get_cached_proc_info) 8112f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 8212f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmstruct cursor; /* forward declaration */ 8312f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidm 8412f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmextern int ia64_cache_proc_info (struct cursor *c); 8512f0ce1a3988bc81166ec05b473b8f245dff2daahp.com!davidmextern int ia64_get_cached_proc_info (struct cursor *c); 86