16534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* libunwind - a platform-independent unwind library
26534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   Copyright (C) 2001-2004 Hewlett-Packard Co
36534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris	Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
46534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
56534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher FerrisThis file is part of libunwind.
66534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
76534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher FerrisPermission is hereby granted, free of charge, to any person obtaining
86534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisa copy of this software and associated documentation files (the
96534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris"Software"), to deal in the Software without restriction, including
106534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferriswithout limitation the rights to use, copy, modify, merge, publish,
116534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisdistribute, sublicense, and/or sell copies of the Software, and to
126534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrispermit persons to whom the Software is furnished to do so, subject to
136534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristhe following conditions:
146534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
156534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher FerrisThe above copyright notice and this permission notice shall be
166534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisincluded in all copies or substantial portions of the Software.
176534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
186534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher FerrisTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
196534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher FerrisEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
206534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher FerrisMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
216534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher FerrisNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
226534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher FerrisLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
236534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher FerrisOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
246534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher FerrisWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
256534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
2616b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris/* ANDROID support update. */
2716b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris#include <sys/types.h>
2816b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris/* End of ANDROID update. */
2916b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris
306534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_VERSION_MAJOR	1
316534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_VERSION_MINOR	1
326534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_VERSION_EXTRA
336534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
346534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_VERSION_CODE(maj,min)	(((maj) << 16) | (min))
356534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_VERSION	UNW_VERSION_CODE(UNW_VERSION_MAJOR, UNW_VERSION_MINOR)
366534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
376534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_PASTE2(x,y)	x##y
386534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_PASTE(x,y)	UNW_PASTE2(x,y)
396534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_OBJ(fn)	UNW_PASTE(UNW_PREFIX, fn)
406534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_ARCH_OBJ(fn) UNW_PASTE(UNW_PASTE(UNW_PASTE(_U,UNW_TARGET),_), fn)
416534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
426534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#ifdef UNW_LOCAL_ONLY
43d334d4b7ebbc803f61de98bc568a41df3b0e2535Christopher Ferris# ifdef UNW_ADDITIONAL_PREFIX
44d334d4b7ebbc803f61de98bc568a41df3b0e2535Christopher Ferris#  define UNW_PREFIX	UNW_PASTE(UNW_PASTE(_UUL,UNW_TARGET),_)
45d334d4b7ebbc803f61de98bc568a41df3b0e2535Christopher Ferris# else
46d334d4b7ebbc803f61de98bc568a41df3b0e2535Christopher Ferris#  define UNW_PREFIX	UNW_PASTE(UNW_PASTE(_UL,UNW_TARGET),_)
47d334d4b7ebbc803f61de98bc568a41df3b0e2535Christopher Ferris# endif
486534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#else /* !UNW_LOCAL_ONLY */
49d334d4b7ebbc803f61de98bc568a41df3b0e2535Christopher Ferris# ifdef UNW_ADDITIONAL_PREFIX
50d334d4b7ebbc803f61de98bc568a41df3b0e2535Christopher Ferris#  define UNW_PREFIX	UNW_PASTE(UNW_PASTE(_UU,UNW_TARGET),_)
51d334d4b7ebbc803f61de98bc568a41df3b0e2535Christopher Ferris# else
52d334d4b7ebbc803f61de98bc568a41df3b0e2535Christopher Ferris#  define UNW_PREFIX	UNW_PASTE(UNW_PASTE(_U,UNW_TARGET),_)
53d334d4b7ebbc803f61de98bc568a41df3b0e2535Christopher Ferris# endif
546534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#endif /* !UNW_LOCAL_ONLY */
556534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
566534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* Error codes.  The unwind routines return the *negated* values of
576534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   these error codes on error and a non-negative value on success.  */
586534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef enum
596534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  {
606534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_ESUCCESS = 0,		/* no error */
616534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_EUNSPEC,		/* unspecified (general) error */
626534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_ENOMEM,			/* out of memory */
636534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_EBADREG,		/* bad register number */
646534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_EREADONLYREG,		/* attempt to write read-only register */
656534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_ESTOPUNWIND,		/* stop unwinding */
666534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_EINVALIDIP,		/* invalid IP */
676534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_EBADFRAME,		/* bad frame */
686534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_EINVAL,			/* unsupported operation or bad value */
696534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_EBADVERSION,		/* unwind info has unsupported version */
706534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_ENOINFO			/* no unwind info found */
716534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  }
726534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisunw_error_t;
736534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
746534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* The following enum defines the indices for a couple of
756534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   (pseudo-)registers which have the same meaning across all
766534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   platforms.  (RO) means read-only.  (RW) means read-write.  General
776534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   registers (aka "integer registers") are expected to start with
786534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   index 0.  The number of such registers is architecture-dependent.
796534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   The remaining indices can be used as an architecture sees fit.  The
806534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   last valid register index is given by UNW_REG_LAST.  */
816534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef enum
826534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  {
836534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_REG_IP = UNW_TDEP_IP,		/* (rw) instruction pointer (pc) */
846534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_REG_SP = UNW_TDEP_SP,		/* (ro) stack pointer */
856534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_REG_EH = UNW_TDEP_EH,		/* (rw) exception-handling reg base */
866534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_REG_LAST = UNW_TDEP_LAST_REG
876534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  }
886534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisunw_frame_regnum_t;
896534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
906534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* Number of exception-handler argument registers: */
916534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_NUM_EH_REGS		UNW_TDEP_NUM_EH_REGS
926534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
936534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef enum
946534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  {
956534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_CACHE_NONE,			/* no caching */
966534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_CACHE_GLOBAL,			/* shared global cache */
976534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_CACHE_PER_THREAD		/* per-thread caching */
986534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  }
996534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisunw_caching_policy_t;
1006534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1016534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef int unw_regnum_t;
1026534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1036534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* The unwind cursor starts at the youngest (most deeply nested) frame
1046534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   and is used to track the frame state as the unwinder steps from
1056534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   frame to frame.  It is safe to make (shallow) copies of variables
1066534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   of this type.  */
1076534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef struct unw_cursor
1086534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  {
1096534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    unw_word_t opaque[UNW_TDEP_CURSOR_LEN];
1106534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  }
1116534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisunw_cursor_t;
1126534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1136534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* This type encapsulates the entire (preserved) machine-state.  */
1146534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef unw_tdep_context_t unw_context_t;
1156534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1166534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* unw_getcontext() fills the unw_context_t pointed to by UC with the
1176534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   machine state as it exists at the call-site.  For implementation
1186534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   reasons, this needs to be a target-dependent macro.  It's easiest
1196534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   to think of unw_getcontext() as being identical to getcontext(). */
1206534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_getcontext(uc)		unw_tdep_getcontext(uc)
1216534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1226534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* Return 1 if register number R is a floating-point register, zero
1236534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   otherwise.
1246534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   This routine is signal-safe.  */
1256534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_is_fpreg(r)			unw_tdep_is_fpreg(r)
1266534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1276534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef unw_tdep_fpreg_t unw_fpreg_t;
1286534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1296534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef struct unw_addr_space *unw_addr_space_t;
1306534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1316534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* Each target may define it's own set of flags, but bits 0-15 are
1326534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   reserved for general libunwind-use.  */
1336534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_PI_FLAG_FIRST_TDEP_BIT	16
1346534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* The information comes from a .debug_frame section.  */
1356534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define UNW_PI_FLAG_DEBUG_FRAME	32
1366534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1376534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef struct unw_proc_info
1386534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  {
1396534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    unw_word_t start_ip;	/* first IP covered by this procedure */
1406534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    unw_word_t end_ip;		/* first IP NOT covered by this procedure */
1416534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    unw_word_t lsda;		/* address of lang.-spec. data area (if any) */
1426534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    unw_word_t handler;		/* optional personality routine */
1436534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    unw_word_t gp;		/* global-pointer value for this procedure */
1446534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    unw_word_t flags;		/* misc. flags */
1456534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1466534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    int format;			/* unwind-info format (arch-specific) */
1476534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    int unwind_info_size;	/* size of the information (if applicable) */
1486534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    void *unwind_info;		/* unwind-info (arch-specific) */
1496534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    unw_tdep_proc_info_t extra;	/* target-dependent auxiliary proc-info */
1506534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  }
1516534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisunw_proc_info_t;
1526534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1536534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* These are backend callback routines that provide access to the
1546534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   state of a "remote" process.  This can be used, for example, to
1556534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris   unwind another process through the ptrace() interface.  */
1566534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef struct unw_accessors
1576534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  {
1586534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    /* Look up the unwind info associated with instruction-pointer IP.
1596534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris       On success, the routine fills in the PROC_INFO structure.  */
1606534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    int (*find_proc_info) (unw_addr_space_t, unw_word_t, unw_proc_info_t *,
1616534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris			   int, void *);
1626534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1636534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    /* Release any resources (e.g., memory) that were allocated for
1646534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris       the unwind info returned in by a previous call to
1656534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris       find_proc_info() with NEED_UNWIND_INFO set to 1.  */
1666534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    void (*put_unwind_info) (unw_addr_space_t, unw_proc_info_t *, void *);
1676534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1686534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    /* Return the list-head of the dynamically registered unwind
1696534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris       info.  */
1706534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    int (*get_dyn_info_list_addr) (unw_addr_space_t, unw_word_t *, void *);
1716534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1726534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    /* Access aligned word at address ADDR.  The value is returned
1736534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris       according to the endianness of the host (e.g., if the host is
1746534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris       little-endian and the target is big-endian, access_mem() needs
1756534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris       to byte-swap the value before returning it).  */
1766534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    int (*access_mem) (unw_addr_space_t, unw_word_t, unw_word_t *, int,
1776534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris		       void *);
1786534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1796534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    /* Access register number REG at address ADDR.  */
1806534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    int (*access_reg) (unw_addr_space_t, unw_regnum_t, unw_word_t *, int,
1816534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris		       void *);
1826534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1836534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    /* Access register number REG at address ADDR.  */
1846534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    int (*access_fpreg) (unw_addr_space_t, unw_regnum_t,
1856534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris			 unw_fpreg_t *, int, void *);
1866534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1876534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    int (*resume) (unw_addr_space_t, unw_cursor_t *, void *);
1886534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1896534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    /* Optional call back to obtain the name of a (static) procedure.
1906534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris       Dynamically generated procedures are handled automatically by
1916534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris       libunwind.  This callback is optional and may be set to
1926534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris       NULL.  */
1936534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    int (*get_proc_name) (unw_addr_space_t, unw_word_t, char *, size_t,
1946534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris			  unw_word_t *, void *);
1956534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  }
1966534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisunw_accessors_t;
1976534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
1986534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef enum unw_save_loc_type
1996534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  {
2006534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_SLT_NONE,	/* register is not saved ("not an l-value") */
2016534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_SLT_MEMORY,	/* register has been saved in memory */
2026534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    UNW_SLT_REG		/* register has been saved in (another) register */
2036534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  }
2046534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisunw_save_loc_type_t;
2056534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
2066534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferristypedef struct unw_save_loc
2076534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  {
2086534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    unw_save_loc_type_t type;
2096534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    union
2106534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris      {
2116534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris	unw_word_t addr;	/* valid if type==UNW_SLT_MEMORY */
2126534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris	unw_regnum_t regnum;	/* valid if type==UNW_SLT_REG */
2136534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris      }
2146534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    u;
2156534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris    unw_tdep_save_loc_t extra;	/* target-dependent additional information */
2166534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris  }
2176534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisunw_save_loc_t;
2186534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
21916b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris/* ANDROID support update. */
22016b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferristypedef struct unw_map_cursor
22116b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris  {
22216b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris    void *map_list;
22316b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris    void *cur_map;
22416b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris  }
22516b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferrisunw_map_cursor_t;
22616b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris
22716b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferristypedef struct unw_map
22816b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris  {
22916b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris    unw_word_t start;
23016b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris    unw_word_t end;
231d9bcbd4f0e25f5196c5b3e6ec17390529ffb4846Christopher Ferris    unw_word_t offset;
232517b197b9b49fdf65bd9ad8baa66cb374faad997Christopher Ferris    unw_word_t load_base;
23316b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris    char *path;
23416b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris    int flags;
23516b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris  }
23616b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferrisunw_map_t;
23716b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris/* End of ANDROID update. */
23816b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris
2396534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris/* These routines work both for local and remote unwinding.  */
2406534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
2412553e59567aa15e889ab7da963d13a64c3c4cb36Christopher Ferris#define unw_local_access_addr_space_init UNW_OBJ(local_access_addr_space_init)
2426534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_local_addr_space	UNW_OBJ(local_addr_space)
2436534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_create_addr_space	UNW_OBJ(create_addr_space)
2446534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_destroy_addr_space	UNW_OBJ(destroy_addr_space)
2456534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_get_accessors	UNW_ARCH_OBJ(get_accessors)
2466534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_init_local		UNW_OBJ(init_local)
2476534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_init_remote		UNW_OBJ(init_remote)
2486534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_step		UNW_OBJ(step)
2496534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_resume		UNW_OBJ(resume)
2506534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_get_proc_info	UNW_OBJ(get_proc_info)
2516534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_get_proc_info_by_ip	UNW_OBJ(get_proc_info_by_ip)
2526534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_get_reg		UNW_OBJ(get_reg)
2536534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_set_reg		UNW_OBJ(set_reg)
2546534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_get_fpreg		UNW_OBJ(get_fpreg)
2556534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_set_fpreg		UNW_OBJ(set_fpreg)
2566534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_get_save_loc	UNW_OBJ(get_save_loc)
2576534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_is_signal_frame	UNW_OBJ(is_signal_frame)
2586534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_handle_signal_frame	UNW_OBJ(handle_signal_frame)
2596534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_get_proc_name	UNW_OBJ(get_proc_name)
2606534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_get_proc_name_by_ip	UNW_OBJ(get_proc_name_by_ip)
2616534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_set_caching_policy	UNW_OBJ(set_caching_policy)
2626534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_regname		UNW_ARCH_OBJ(regname)
2636534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_flush_cache		UNW_ARCH_OBJ(flush_cache)
2646534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris#define unw_strerror		UNW_ARCH_OBJ(strerror)
2656534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
2662553e59567aa15e889ab7da963d13a64c3c4cb36Christopher Ferrisextern void unw_local_access_addr_space_init (unw_addr_space_t);
2676534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern unw_addr_space_t unw_create_addr_space (unw_accessors_t *, int);
2686534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern void unw_destroy_addr_space (unw_addr_space_t);
2696534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern unw_accessors_t *unw_get_accessors (unw_addr_space_t);
2706534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern void unw_flush_cache (unw_addr_space_t, unw_word_t, unw_word_t);
2716534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_set_caching_policy (unw_addr_space_t, unw_caching_policy_t);
2726534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern const char *unw_regname (unw_regnum_t);
2736534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
2746534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_init_local (unw_cursor_t *, unw_context_t *);
2756534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_init_remote (unw_cursor_t *, unw_addr_space_t, void *);
2766534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_step (unw_cursor_t *);
2776534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_resume (unw_cursor_t *);
2786534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_get_proc_info (unw_cursor_t *, unw_proc_info_t *);
2796534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_get_proc_info_by_ip (unw_addr_space_t, unw_word_t,
2806534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris				    unw_proc_info_t *, void *);
2816534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_get_reg (unw_cursor_t *, int, unw_word_t *);
2826534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_set_reg (unw_cursor_t *, int, unw_word_t);
2836534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_get_fpreg (unw_cursor_t *, int, unw_fpreg_t *);
2846534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_set_fpreg (unw_cursor_t *, int, unw_fpreg_t);
2856534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_get_save_loc (unw_cursor_t *, int, unw_save_loc_t *);
2866534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_is_signal_frame (unw_cursor_t *);
2876534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_handle_signal_frame (unw_cursor_t *);
2886534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_get_proc_name (unw_cursor_t *, char *, size_t, unw_word_t *);
2896534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_get_proc_name_by_ip (unw_addr_space_t, unw_word_t, char *,
2906534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris				    size_t, unw_word_t *, void *);
2916534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern const char *unw_strerror (int);
2926534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern int unw_backtrace (void **, int);
2936534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferris
29416b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris/* ANDROID support update. */
295f4a8df5f4f338f1a12c25213227e98b34b42447fChristopher Ferrisextern int unw_map_local_cursor_valid (unw_map_cursor_t *);
296f4a8df5f4f338f1a12c25213227e98b34b42447fChristopher Ferrisextern void unw_map_local_cursor_get (unw_map_cursor_t *);
297f4a8df5f4f338f1a12c25213227e98b34b42447fChristopher Ferrisextern int unw_map_local_cursor_get_next (unw_map_cursor_t *, unw_map_t *);
298f4a8df5f4f338f1a12c25213227e98b34b42447fChristopher Ferrisextern int unw_map_local_create (void);
299f4a8df5f4f338f1a12c25213227e98b34b42447fChristopher Ferrisextern void unw_map_local_destroy (void);
30016b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferrisextern void unw_map_set (unw_addr_space_t, unw_map_cursor_t *);
30116b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferrisextern void unw_map_cursor_reset (unw_map_cursor_t *);
302f4a8df5f4f338f1a12c25213227e98b34b42447fChristopher Ferrisextern void unw_map_cursor_clear (unw_map_cursor_t *);
30316b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferrisextern int unw_map_cursor_create (unw_map_cursor_t *, pid_t);
30416b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferrisextern void unw_map_cursor_destroy (unw_map_cursor_t *);
305f4a8df5f4f338f1a12c25213227e98b34b42447fChristopher Ferrisextern int unw_map_cursor_get_next (unw_map_cursor_t *, unw_map_t *);
30616b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris/* End of ANDROID update. */
30716b95a68caaa7e021209e2cd6a877ae1e558f740Christopher Ferris
3086534a77195ac6b5059bc9b6a27e8da58f538f55eChristopher Ferrisextern unw_addr_space_t unw_local_addr_space;
309