blob: 38664f9a7ad8ab2cca84e16f60ab0805827943e0 [file] [log] [blame]
mostang.com!davidm26f6cf72003-01-21 08:08:32 +00001/* libunwind - a platform-independent unwind library
hp.com!davidmd3725a72004-01-22 08:36:15 +00002 Copyright (C) 2002-2004 Hewlett-Packard Co
mostang.com!davidm26f6cf72003-01-21 08:08:32 +00003 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#ifndef LIBUNWIND_H
27#define LIBUNWIND_H
28
mostang.com!davidm337c0ad2003-03-28 07:43:22 +000029#if defined(__cplusplus) || defined(c_plusplus)
30extern "C" {
31#endif
32
mostang.com!davidm58e0e102003-03-19 19:25:18 +000033#include <inttypes.h>
mostang.com!davidm26f6cf72003-01-21 08:08:32 +000034#include <ucontext.h>
35
36#define UNW_TARGET x86
37#define UNW_TARGET_X86 1
38
hp.com!davidm79f981a2003-04-21 23:14:14 +000039#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
40
mostang.com!davidm26f6cf72003-01-21 08:08:32 +000041/* This needs to be big enough to accommodate "struct cursor", while
42 leaving some slack for future expansion. Changing this value will
43 require recompiling all users of this library. Stack allocation is
44 relatively cheap and unwind-state copying is relatively rare, so we
45 want to err on making it rather too big than too small. */
46#define UNW_TDEP_CURSOR_LEN 127
47
hp.com!davidm468aacc2003-12-20 11:50:00 +000048typedef uint32_t unw_word_t;
Arun Sharma11ea1272006-07-26 22:12:10 -060049typedef int32_t unw_sword_t;
mostang.com!davidm26f6cf72003-01-21 08:08:32 +000050
mostang.com!davidm45ce48f2003-03-06 06:14:36 +000051typedef long double unw_tdep_fpreg_t;
52
mostang.com!davidm26f6cf72003-01-21 08:08:32 +000053typedef enum
54 {
hp.com!davidm34085ca2003-11-22 06:11:18 +000055 /* Note: general registers are expected to start with index 0.
mostang.com!davidm26f6cf72003-01-21 08:08:32 +000056 This convention facilitates architecture-independent
57 implementation of the C++ exception handling ABI. See
hp.com!davidm468aacc2003-12-20 11:50:00 +000058 _Unwind_SetGR() and _Unwind_GetGR() for details.
mostang.com!davidm26f6cf72003-01-21 08:08:32 +000059
hp.com!davidm468aacc2003-12-20 11:50:00 +000060 The described register usage convention is based on "System V
61 Application Binary Interface, Intel386 Architecture Processor
62 Supplement, Fourth Edition" at
63
64 http://www.linuxbase.org/spec/refspecs/elf/abi386-4.pdf
65
66 It would have been nice to use the same register numbering as
67 DWARF, but that doesn't work because the libunwind requires
68 that the exception argument registers be consecutive, which the
69 wouldn't be with the DWARF numbering. */
70 UNW_X86_EAX, /* scratch (exception argument 1) */
71 UNW_X86_EDX, /* scratch (exception argument 2) */
mostang.com!davidm6dcb17c2005-05-03 09:13:17 +000072 UNW_X86_ECX, /* scratch */
hp.com!davidm468aacc2003-12-20 11:50:00 +000073 UNW_X86_EBX, /* preserved */
74 UNW_X86_ESI, /* preserved */
75 UNW_X86_EDI, /* preserved */
76 UNW_X86_EBP, /* (optional) frame-register */
77 UNW_X86_ESP, /* (optional) frame-register */
78 UNW_X86_EIP, /* frame-register */
79 UNW_X86_EFLAGS, /* scratch (except for "direction", which is fixed */
80 UNW_X86_TRAPNO, /* scratch */
81
82 /* MMX/stacked-fp registers */
83 UNW_X86_ST0, /* fp return value */
84 UNW_X86_ST1, /* scratch */
85 UNW_X86_ST2, /* scratch */
86 UNW_X86_ST3, /* scratch */
87 UNW_X86_ST4, /* scratch */
88 UNW_X86_ST5, /* scratch */
89 UNW_X86_ST6, /* scratch */
90 UNW_X86_ST7, /* scratch */
91
92 UNW_X86_FCW, /* scratch */
93 UNW_X86_FSW, /* scratch */
94 UNW_X86_FTW, /* scratch */
95 UNW_X86_FOP, /* scratch */
96 UNW_X86_FCS, /* scratch */
97 UNW_X86_FIP, /* scratch */
98 UNW_X86_FEA, /* scratch */
99 UNW_X86_FDS, /* scratch */
100
101 /* SSE registers */
102 UNW_X86_XMM0_lo, /* scratch */
103 UNW_X86_XMM0_hi, /* scratch */
104 UNW_X86_XMM1_lo, /* scratch */
105 UNW_X86_XMM1_hi, /* scratch */
106 UNW_X86_XMM2_lo, /* scratch */
107 UNW_X86_XMM2_hi, /* scratch */
108 UNW_X86_XMM3_lo, /* scratch */
109 UNW_X86_XMM3_hi, /* scratch */
110 UNW_X86_XMM4_lo, /* scratch */
111 UNW_X86_XMM4_hi, /* scratch */
112 UNW_X86_XMM5_lo, /* scratch */
113 UNW_X86_XMM5_hi, /* scratch */
114 UNW_X86_XMM6_lo, /* scratch */
115 UNW_X86_XMM6_hi, /* scratch */
116 UNW_X86_XMM7_lo, /* scratch */
117 UNW_X86_XMM7_hi, /* scratch */
118
119 UNW_X86_MXCSR, /* scratch */
120
121 /* segment registers */
122 UNW_X86_GS, /* special */
123 UNW_X86_FS, /* special */
124 UNW_X86_ES, /* special */
125 UNW_X86_DS, /* special */
126 UNW_X86_SS, /* special */
127 UNW_X86_CS, /* special */
128 UNW_X86_TSS, /* special */
129 UNW_X86_LDT, /* special */
130
131 /* frame info (read-only) */
132 UNW_X86_CFA,
133
134 UNW_TDEP_LAST_REG = UNW_X86_LDT,
mostang.com!davidm26f6cf72003-01-21 08:08:32 +0000135
136 UNW_TDEP_IP = UNW_X86_EIP,
hp.com!davidm468aacc2003-12-20 11:50:00 +0000137 UNW_TDEP_SP = UNW_X86_CFA,
mostang.com!davidm45ce48f2003-03-06 06:14:36 +0000138 UNW_TDEP_EH = UNW_X86_EAX
mostang.com!davidm26f6cf72003-01-21 08:08:32 +0000139 }
140x86_regnum_t;
141
hp.com!davidm468aacc2003-12-20 11:50:00 +0000142#define UNW_TDEP_NUM_EH_REGS 2 /* eax and edx are exception args */
mostang.com!davidm45ce48f2003-03-06 06:14:36 +0000143
mostang.com!davidm26f6cf72003-01-21 08:08:32 +0000144typedef struct unw_tdep_save_loc
145 {
146 /* Additional target-dependent info on a save location. */
147 }
148unw_tdep_save_loc_t;
149
150/* On x86, we can directly use ucontext_t as the unwind context. */
151typedef ucontext_t unw_tdep_context_t;
152
153/* XXX this is not ideal: an application should not be prevented from
154 using the "getcontext" name just because it's using libunwind. We
155 can't just use __getcontext() either, because that isn't exported
156 by glibc... */
157#define unw_tdep_getcontext(uc) (getcontext (uc), 0)
158
hp.com!davidm468aacc2003-12-20 11:50:00 +0000159#include "libunwind-dynamic.h"
160
161typedef struct
162 {
mostang.com!davidm6dcb17c2005-05-03 09:13:17 +0000163 /* no x86-specific auxiliary proc-info */
hp.com!davidm468aacc2003-12-20 11:50:00 +0000164 }
165unw_tdep_proc_info_t;
166
mostang.com!davidm26f6cf72003-01-21 08:08:32 +0000167#include "libunwind-common.h"
168
hp.com!davidmd3725a72004-01-22 08:36:15 +0000169#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
170extern int unw_tdep_is_fpreg (int);
171
mostang.com!davidm337c0ad2003-03-28 07:43:22 +0000172#if defined(__cplusplus) || defined(c_plusplus)
173}
174#endif
175
mostang.com!davidm26f6cf72003-01-21 08:08:32 +0000176#endif /* LIBUNWIND_H */