blob: 98e5e5241783ed36e2ce9d40ee061050dc88abc4 [file] [log] [blame]
mostang.com!davidmdb59d4f2002-12-19 07:16:50 +00001/* 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
5This file is part of libunwind.
6
7Permission is hereby granted, free of charge, to any person obtaining
8a copy of this software and associated documentation files (the
9"Software"), to deal in the Software without restriction, including
10without limitation the rights to use, copy, modify, merge, publish,
11distribute, sublicense, and/or sell copies of the Software, and to
12permit persons to whom the Software is furnished to do so, subject to
13the following conditions:
14
15The above copyright notice and this permission notice shall be
16included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24WITH 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
32typedef unsigned char unw_hash_index_t;
33
34enum ia64_script_insn_opcode
35 {
36 IA64_INSN_SET, /* s[dst] = val */
mostang.com!davidm78a7c5a2003-04-23 05:56:59 +000037 IA64_INSN_SET_REG, /* s[dst] = REG(val) */
mostang.com!davidmdb59d4f2002-12-19 07:16:50 +000038 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 */
mostang.com!davidm78a7c5a2003-04-23 05:56:59 +000044 IA64_INSN_INC_PSP, /* psp += val */
45 IA64_INSN_LOAD_PSP /* psp = *psp_loc */
mostang.com!davidmdb59d4f2002-12-19 07:16:50 +000046 };
47
mostang.com!davidmdb59d4f2002-12-19 07:16:50 +000048struct ia64_script_insn
49 {
50 unsigned int opc;
51 unsigned int dst;
52 unw_word_t val;
53 };
54
55/* Preserved general static registers (r4-r7) give rise to two script
56 instructions; everything else yields at most one instruction; at
57 the end of the script, the psp gets popped, accounting for one more
58 instruction. */
59#define IA64_MAX_SCRIPT_LEN (IA64_NUM_PREGS + 5)
60
61struct ia64_script
62 {
63 unw_word_t ip; /* ip this script is for */
64 unw_word_t pr_mask; /* mask of predicates script depends on */
65 unw_word_t pr_val; /* predicate values this script is for */
66 unw_proc_info_t pi; /* info about underlying procedure */
67 unsigned short lru_chain; /* used for least-recently-used chain */
68 unsigned short coll_chain; /* used for hash collisions */
69 unsigned short hint; /* hint for next script to try (or -1) */
70 unsigned short count; /* number of instructions in script */
mostang.com!davidm78a7c5a2003-04-23 05:56:59 +000071 unsigned short abi_marker;
mostang.com!davidmdb59d4f2002-12-19 07:16:50 +000072 struct ia64_script_insn insn[IA64_MAX_SCRIPT_LEN];
73 };
74
75struct ia64_script_cache
76 {
hp.com!davidmd61f3002003-11-24 23:53:25 +000077#ifdef HAVE_ATOMIC_OPS_H
mostang.com!davidmcd7dcba2004-01-20 23:50:00 +000078 AO_TS_t busy; /* is the script-cache busy? */
hp.com!davidmd61f3002003-11-24 23:53:25 +000079#else
mostang.com!davidm57bdcfe2003-03-06 06:14:36 +000080 pthread_mutex_t lock;
hp.com!davidmd61f3002003-11-24 23:53:25 +000081#endif
mostang.com!davidmdb59d4f2002-12-19 07:16:50 +000082 unsigned short lru_head; /* index of lead-recently used script */
83 unsigned short lru_tail; /* index of most-recently used script */
84
85 /* hash table that maps instruction pointer to script index: */
86 unsigned short hash[IA64_UNW_HASH_SIZE];
87
88 uint32_t generation; /* generation number */
89
90 /* script cache: */
91 struct ia64_script buckets[IA64_UNW_CACHE_SIZE];
92 };
93
mostang.com!davidm57bdcfe2003-03-06 06:14:36 +000094#define ia64_get_cached_proc_info UNW_OBJ(ia64_get_cached_proc_info)
mostang.com!davidmdb59d4f2002-12-19 07:16:50 +000095
96struct cursor; /* forward declaration */
97
mostang.com!davidm57bdcfe2003-03-06 06:14:36 +000098extern int ia64_get_cached_proc_info (struct cursor *c);