libunwind_i.h revision 1787a2fd284a786b409af74047a12de02c644cd1
12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* libunwind - a platform-independent unwind library
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   Copyright (C) 2001-2005 Hewlett-Packard Co
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)	Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)This file is part of libunwind.
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)Permission is hereby granted, free of charge, to any person obtaining
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)a copy of this software and associated documentation files (the
95e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)"Software"), to deal in the Software without restriction, including
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)without limitation the rights to use, copy, modify, merge, publish,
1158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)distribute, sublicense, and/or sell copies of the Software, and to
127dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochpermit persons to whom the Software is furnished to do so, subject to
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)the following conditions:
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)The above copyright notice and this permission notice shall be
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)included in all copies or substantial portions of the Software.
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef IA64_LIBUNWIND_I_H
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define IA64_LIBUNWIND_I_H
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* Target-dependent definitions that are internal to libunwind but need
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   to be shared with target-independent code.  */
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
327dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "elf64.h"
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "mempool.h"
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
357dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochenum ia64_pregnum
367dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  {
37c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    /* primary unat: */
38c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    IA64_REG_PRI_UNAT_GR,
39c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    IA64_REG_PRI_UNAT_MEM,
40c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
41c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    /* memory stack (order matters: see build_script() */
42c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    IA64_REG_PSP,			/* previous memory stack pointer */
43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    /* register stack */
44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    IA64_REG_BSP,			/* register stack pointer */
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    IA64_REG_BSPSTORE,
46c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    IA64_REG_PFS,			/* previous function state */
47c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    IA64_REG_RNAT,
487dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    /* instruction pointer: */
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    IA64_REG_IP,
507dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
51c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    /* preserved registers: */
52c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    IA64_REG_R4, IA64_REG_R5, IA64_REG_R6, IA64_REG_R7,
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    IA64_REG_NAT4, IA64_REG_NAT5, IA64_REG_NAT6, IA64_REG_NAT7,
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    IA64_REG_UNAT, IA64_REG_PR, IA64_REG_LC, IA64_REG_FPSR,
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    IA64_REG_B1, IA64_REG_B2, IA64_REG_B3, IA64_REG_B4, IA64_REG_B5,
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    IA64_REG_F2, IA64_REG_F3, IA64_REG_F4, IA64_REG_F5,
57c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    IA64_REG_F16, IA64_REG_F17, IA64_REG_F18, IA64_REG_F19,
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    IA64_REG_F20, IA64_REG_F21, IA64_REG_F22, IA64_REG_F23,
59c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    IA64_REG_F24, IA64_REG_F25, IA64_REG_F26, IA64_REG_F27,
60c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    IA64_REG_F28, IA64_REG_F29, IA64_REG_F30, IA64_REG_F31,
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    IA64_NUM_PREGS
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  };
635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifdef UNW_LOCAL_ONLY
655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
66c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)typedef unw_word_t ia64_loc_t;
67c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
687dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#else /* !UNW_LOCAL_ONLY */
697dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
70c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)typedef struct ia64_loc
71ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  {
72c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    unw_word_t w0, w1;
73c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)ia64_loc_t;
75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
76c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif /* !UNW_LOCAL_ONLY */
77c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
78c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "script.h"
79c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
807dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#define ABI_UNKNOWN			0
81c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define ABI_LINUX			1
82c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define ABI_HPUX			2
83c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define ABI_FREEBSD			3
845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define ABI_OPENVMS			4
855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define ABI_NSK				5	/* Tandem/HP Non-Stop Kernel */
865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define ABI_WINDOWS			6
87c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
88c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)struct unw_addr_space
895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  {
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    struct unw_accessors acc;
912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    int big_endian;
925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    int abi;	/* abi < 0 => unknown, 0 => SysV, 1 => HP-UX, 2 => Windows */
935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    unw_caching_policy_t caching_policy;
945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifdef HAVE_ATOMIC_OPS_H
955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    AO_t cache_generation;
965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#else
97116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    uint32_t cache_generation;
98116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif
9958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)    unw_word_t dyn_generation;
10058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)    unw_word_t dyn_info_list_addr;	/* (cached) dyn_info_list_addr */
101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#ifndef UNW_REMOTE_ONLY
102c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    unsigned long long shared_object_removals;
1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    struct ia64_script_cache global_cache;
1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)   };
107c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)/* Note: The ABI numbers in the ABI-markers (.unwabi directive) are
109c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)   not the same as the above ABI numbers.  */
110c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define ABI_MARKER_OLD_LINUX_SIGTRAMP	((0 << 8) | 's')
111c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define ABI_MARKER_OLD_LINUX_INTERRUPT	((0 << 8) | 'i')
112c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define ABI_MARKER_HP_UX_SIGTRAMP	((1 << 8) | 1)
1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define ABI_MARKER_LINUX_SIGTRAMP	((3 << 8) | 's')
1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define ABI_MARKER_LINUX_INTERRUPT	((3 << 8) | 'i')
1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct cursor
1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  {
11858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)    void *as_arg;		/* argument to address-space callbacks */
119c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    unw_addr_space_t as;	/* reference to per-address-space info */
1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    /* IP, CFM, and predicate cache (these are always equal to the
12258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)       values stored in ip_loc, cfm_loc, and pr_loc,
123c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)       respectively).  */
1245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    unw_word_t ip;		/* instruction pointer value */
1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    unw_word_t cfm;		/* current frame mask */
1265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    unw_word_t pr;		/* current predicate values */
1275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
128c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    /* current frame info: */
129ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    unw_word_t bsp;		/* backing store pointer value */
130ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    unw_word_t sp;		/* stack pointer value */
131ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    unw_word_t psp;		/* previous sp value */
132ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    ia64_loc_t cfm_loc;		/* cfm save location (or NULL) */
133ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    ia64_loc_t ec_loc;		/* ar.ec save location (usually cfm_loc) */
134c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    ia64_loc_t loc[IA64_NUM_PREGS];
1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    unw_word_t eh_args[4];	/* exception handler arguments */
137116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    unw_word_t sigcontext_addr;	/* address of sigcontext or 0 */
138116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    unw_word_t sigcontext_off;	/* sigcontext-offset relative to signal sp */
139116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
140116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    short hint;
141116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    short prev_script;
1427dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
1437dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    uint8_t nat_bitnr[4];	/* NaT bit numbers for r4-r7 */
1447dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    uint16_t abi_marker;	/* abi_marker for current frame (if any) */
1457dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    uint16_t last_abi_marker;	/* last abi_marker encountered so far */
1467dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    uint8_t eh_valid_mask;
1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    unsigned int pi_valid :1;		/* is proc_info valid? */
1495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    unsigned int pi_is_dynamic :1; /* proc_info found via dynamic proc info? */
1505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    unw_proc_info_t pi;		/* info about current procedure */
1515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    /* In case of stack-discontiguities, such as those introduced by
1535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)       signal-delivery on an alternate signal-stack (see
1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)       sigaltstack(2)), we use the following data-structure to keep
1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)       track of the register-backing-store areas across on which the
1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)       current frame may be backed up.  Since there are at most 96
1575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)       stacked registers and since we only have to track the current
1585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)       frame and only areas that are not empty, this puts an upper
1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)       limit on the # of backing-store areas we have to track.
1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)       Note that the rbs-area indexed by rbs_curr identifies the
1625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)       rbs-area that was in effect at the time AR.BSP had the value
1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)       c->bsp.  However, this rbs area may not actually contain the
1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)       value in the register that c->bsp corresponds to because that
1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)       register may not have gotten spilled until much later, when a
166cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)       possibly different rbs-area might have been in effect
167cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)       already.  */
168cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    uint8_t rbs_curr;		/* index of curr. rbs-area (contains c->bsp) */
169cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    uint8_t rbs_left_edge;	/* index of inner-most valid rbs-area */
170cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    struct rbs_area
171cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)      {
172cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)	unw_word_t end;
173cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)	unw_word_t size;
174cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)	ia64_loc_t rnat_loc;
1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      }
1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    rbs_area[96 + 2];	/* 96 stacked regs + 1 extra stack on each side... */
1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct ia64_global_unwind_state
1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  {
1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    pthread_mutex_t lock;		/* global data lock */
182ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch
183ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    volatile char needs_initialization;
184ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch
185ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    /* Table of registers that prologues can save (and order in which
186ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch       they're saved).  */
1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const unsigned char save_order[8];
1887dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
1897dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    /*
1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)     * uc_addr() may return pointers to these variables.  We need to
1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)     * make sure they don't get written via ia64_put() or
1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)     * ia64_putfp().  To make it possible to test for these variables
1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)     * quickly, we collect them in a single sub-structure.
1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)     */
1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    struct
1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      {
1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)	unw_word_t  r0;			/* r0 is byte-order neutral */
1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)	unw_fpreg_t f0;			/* f0 is byte-order neutral */
199c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)	unw_fpreg_t f1_le, f1_be;	/* f1 is byte-order dependent */
2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      }
2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    read_only;
202116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    unw_fpreg_t nat_val_le, nat_val_be;
203116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    unw_fpreg_t int_val_le, int_val_be;
2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    struct mempool reg_state_pool;
2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    struct mempool labeled_state_pool;
2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# if UNW_DEBUG
2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const char *preg_name[IA64_NUM_PREGS];
2105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# endif
2115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  };
2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define tdep_needs_initialization	unw.needs_initialization
2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define tdep_init			UNW_OBJ(init)
2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* Platforms that support UNW_INFO_FORMAT_TABLE need to define
216c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)   tdep_search_unwind_table.  */
217c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define tdep_search_unwind_table	unw_search_ia64_unwind_table
218a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define tdep_find_proc_info		UNW_OBJ(find_proc_info)
219a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define tdep_uc_addr			UNW_OBJ(uc_addr)
220a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define tdep_get_elf_image		UNW_ARCH_OBJ(get_elf_image)
221a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define tdep_access_reg			UNW_OBJ(access_reg)
2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define tdep_access_fpreg		UNW_OBJ(access_fpreg)
22358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#define tdep_fetch_frame(c,ip,n)	do {} while(0)
2245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define tdep_cache_frame(c,rs)		do {} while(0)
2255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define tdep_reuse_frame(c,rs)		do {} while(0)
226c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define tdep_get_as(c)			((c)->as)
227c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define tdep_get_as_arg(c)		((c)->as_arg)
2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define tdep_get_ip(c)			((c)->ip)
2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define tdep_big_endian(as)		((c)->as->big_endian != 0)
2305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef UNW_LOCAL_ONLY
232c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)# define tdep_put_unwind_info		UNW_OBJ(put_unwind_info)
233c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif
234c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
235c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)/* This can't be an UNW_ARCH_OBJ() because we need separate
2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)   unw.initialized flags for the local-only and generic versions of
2375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)   the library.  Also, if we wanted to have a single, shared global
238c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)   data structure, we couldn't declare "unw" as HIDDEN/PROTECTED.  */
23958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#define unw				UNW_OBJ(data)
240f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
241f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)extern void tdep_init (void);
242f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)extern int tdep_find_proc_info (unw_addr_space_t as, unw_word_t ip,
243f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)				unw_proc_info_t *pi, int need_unwind_info,
244f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)				void *arg);
2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)extern void tdep_put_unwind_info (unw_addr_space_t as,
246c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)				  unw_proc_info_t *pi, void *arg);
2475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)extern void *tdep_uc_addr (ucontext_t *uc, unw_regnum_t regnum,
2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)			   uint8_t *nat_bitnr);
249c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
250c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)			       unsigned long *segbase, unsigned long *mapoff,
251c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)			       char *path, size_t pathlen);
252c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
253c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)			    unw_word_t *valp, int write);
254c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
255a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)			      unw_fpreg_t *valp, int write);
256a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
257c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)extern struct ia64_global_unwind_state unw;
258c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* In user-level, we have no reasonable way of determining the base of
260c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)   an arbitrary backing-store.  We default to half the
2612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   address-space.  */
2622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define rbs_get_base(c,bspstore,rbs_basep)				\
2632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)	(*(rbs_basep) = (bspstore) - (((unw_word_t) 1) << 63), 0)
2642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif /* IA64_LIBUNWIND_I_H */
2662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)