mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 1 | /* libunwind - a platform-independent unwind library |
hp.com!davidm | d3725a7 | 2004-01-22 08:36:15 +0000 | [diff] [blame^] | 2 | Copyright (C) 2002-2004 Hewlett-Packard Co |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 3 | Contributed by David Mosberger-Tang <davidm@hpl.hp.com> |
| 4 | |
| 5 | This file is part of libunwind. |
| 6 | |
| 7 | Permission is hereby granted, free of charge, to any person obtaining |
| 8 | a copy of this software and associated documentation files (the |
| 9 | "Software"), to deal in the Software without restriction, including |
| 10 | without limitation the rights to use, copy, modify, merge, publish, |
| 11 | distribute, sublicense, and/or sell copies of the Software, and to |
| 12 | permit persons to whom the Software is furnished to do so, subject to |
| 13 | the following conditions: |
| 14 | |
| 15 | The above copyright notice and this permission notice shall be |
| 16 | included in all copies or substantial portions of the Software. |
| 17 | |
| 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 22 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 25 | |
| 26 | #ifndef LIBUNWIND_H |
| 27 | #define LIBUNWIND_H |
| 28 | |
mostang.com!davidm | 337c0ad | 2003-03-28 07:43:22 +0000 | [diff] [blame] | 29 | #if defined(__cplusplus) || defined(c_plusplus) |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
mostang.com!davidm | 58e0e10 | 2003-03-19 19:25:18 +0000 | [diff] [blame] | 33 | #include <inttypes.h> |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 34 | #include <ucontext.h> |
| 35 | |
| 36 | #define UNW_TARGET x86 |
| 37 | #define UNW_TARGET_X86 1 |
| 38 | |
hp.com!davidm | 79f981a | 2003-04-21 23:14:14 +0000 | [diff] [blame] | 39 | #define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ |
| 40 | |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 41 | /* 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!davidm | 468aacc | 2003-12-20 11:50:00 +0000 | [diff] [blame] | 48 | typedef uint32_t unw_word_t; |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 49 | |
mostang.com!davidm | 45ce48f | 2003-03-06 06:14:36 +0000 | [diff] [blame] | 50 | typedef long double unw_tdep_fpreg_t; |
| 51 | |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 52 | typedef enum |
| 53 | { |
hp.com!davidm | 34085ca | 2003-11-22 06:11:18 +0000 | [diff] [blame] | 54 | /* Note: general registers are expected to start with index 0. |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 55 | This convention facilitates architecture-independent |
| 56 | implementation of the C++ exception handling ABI. See |
hp.com!davidm | 468aacc | 2003-12-20 11:50:00 +0000 | [diff] [blame] | 57 | _Unwind_SetGR() and _Unwind_GetGR() for details. |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 58 | |
hp.com!davidm | 468aacc | 2003-12-20 11:50:00 +0000 | [diff] [blame] | 59 | The described register usage convention is based on "System V |
| 60 | Application Binary Interface, Intel386 Architecture Processor |
| 61 | Supplement, Fourth Edition" at |
| 62 | |
| 63 | http://www.linuxbase.org/spec/refspecs/elf/abi386-4.pdf |
| 64 | |
| 65 | It would have been nice to use the same register numbering as |
| 66 | DWARF, but that doesn't work because the libunwind requires |
| 67 | that the exception argument registers be consecutive, which the |
| 68 | wouldn't be with the DWARF numbering. */ |
| 69 | UNW_X86_EAX, /* scratch (exception argument 1) */ |
| 70 | UNW_X86_EDX, /* scratch (exception argument 2) */ |
| 71 | UNW_X86_ECX, /* preserved */ |
| 72 | UNW_X86_EBX, /* preserved */ |
| 73 | UNW_X86_ESI, /* preserved */ |
| 74 | UNW_X86_EDI, /* preserved */ |
| 75 | UNW_X86_EBP, /* (optional) frame-register */ |
| 76 | UNW_X86_ESP, /* (optional) frame-register */ |
| 77 | UNW_X86_EIP, /* frame-register */ |
| 78 | UNW_X86_EFLAGS, /* scratch (except for "direction", which is fixed */ |
| 79 | UNW_X86_TRAPNO, /* scratch */ |
| 80 | |
| 81 | /* MMX/stacked-fp registers */ |
| 82 | UNW_X86_ST0, /* fp return value */ |
| 83 | UNW_X86_ST1, /* scratch */ |
| 84 | UNW_X86_ST2, /* scratch */ |
| 85 | UNW_X86_ST3, /* scratch */ |
| 86 | UNW_X86_ST4, /* scratch */ |
| 87 | UNW_X86_ST5, /* scratch */ |
| 88 | UNW_X86_ST6, /* scratch */ |
| 89 | UNW_X86_ST7, /* scratch */ |
| 90 | |
| 91 | UNW_X86_FCW, /* scratch */ |
| 92 | UNW_X86_FSW, /* scratch */ |
| 93 | UNW_X86_FTW, /* scratch */ |
| 94 | UNW_X86_FOP, /* scratch */ |
| 95 | UNW_X86_FCS, /* scratch */ |
| 96 | UNW_X86_FIP, /* scratch */ |
| 97 | UNW_X86_FEA, /* scratch */ |
| 98 | UNW_X86_FDS, /* scratch */ |
| 99 | |
| 100 | /* SSE registers */ |
| 101 | UNW_X86_XMM0_lo, /* scratch */ |
| 102 | UNW_X86_XMM0_hi, /* scratch */ |
| 103 | UNW_X86_XMM1_lo, /* scratch */ |
| 104 | UNW_X86_XMM1_hi, /* scratch */ |
| 105 | UNW_X86_XMM2_lo, /* scratch */ |
| 106 | UNW_X86_XMM2_hi, /* scratch */ |
| 107 | UNW_X86_XMM3_lo, /* scratch */ |
| 108 | UNW_X86_XMM3_hi, /* scratch */ |
| 109 | UNW_X86_XMM4_lo, /* scratch */ |
| 110 | UNW_X86_XMM4_hi, /* scratch */ |
| 111 | UNW_X86_XMM5_lo, /* scratch */ |
| 112 | UNW_X86_XMM5_hi, /* scratch */ |
| 113 | UNW_X86_XMM6_lo, /* scratch */ |
| 114 | UNW_X86_XMM6_hi, /* scratch */ |
| 115 | UNW_X86_XMM7_lo, /* scratch */ |
| 116 | UNW_X86_XMM7_hi, /* scratch */ |
| 117 | |
| 118 | UNW_X86_MXCSR, /* scratch */ |
| 119 | |
| 120 | /* segment registers */ |
| 121 | UNW_X86_GS, /* special */ |
| 122 | UNW_X86_FS, /* special */ |
| 123 | UNW_X86_ES, /* special */ |
| 124 | UNW_X86_DS, /* special */ |
| 125 | UNW_X86_SS, /* special */ |
| 126 | UNW_X86_CS, /* special */ |
| 127 | UNW_X86_TSS, /* special */ |
| 128 | UNW_X86_LDT, /* special */ |
| 129 | |
| 130 | /* frame info (read-only) */ |
| 131 | UNW_X86_CFA, |
| 132 | |
| 133 | UNW_TDEP_LAST_REG = UNW_X86_LDT, |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 134 | |
| 135 | UNW_TDEP_IP = UNW_X86_EIP, |
hp.com!davidm | 468aacc | 2003-12-20 11:50:00 +0000 | [diff] [blame] | 136 | UNW_TDEP_SP = UNW_X86_CFA, |
mostang.com!davidm | 45ce48f | 2003-03-06 06:14:36 +0000 | [diff] [blame] | 137 | UNW_TDEP_EH = UNW_X86_EAX |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 138 | } |
| 139 | x86_regnum_t; |
| 140 | |
hp.com!davidm | 468aacc | 2003-12-20 11:50:00 +0000 | [diff] [blame] | 141 | #define UNW_TDEP_NUM_EH_REGS 2 /* eax and edx are exception args */ |
mostang.com!davidm | 45ce48f | 2003-03-06 06:14:36 +0000 | [diff] [blame] | 142 | |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 143 | typedef struct unw_tdep_save_loc |
| 144 | { |
| 145 | /* Additional target-dependent info on a save location. */ |
| 146 | } |
| 147 | unw_tdep_save_loc_t; |
| 148 | |
| 149 | /* On x86, we can directly use ucontext_t as the unwind context. */ |
| 150 | typedef ucontext_t unw_tdep_context_t; |
| 151 | |
| 152 | /* XXX this is not ideal: an application should not be prevented from |
| 153 | using the "getcontext" name just because it's using libunwind. We |
| 154 | can't just use __getcontext() either, because that isn't exported |
| 155 | by glibc... */ |
| 156 | #define unw_tdep_getcontext(uc) (getcontext (uc), 0) |
| 157 | |
hp.com!davidm | 468aacc | 2003-12-20 11:50:00 +0000 | [diff] [blame] | 158 | #include "libunwind-dynamic.h" |
| 159 | |
| 160 | typedef struct |
| 161 | { |
| 162 | unw_dyn_dwarf_fde_info_t dwarf_info; |
| 163 | } |
| 164 | unw_tdep_proc_info_t; |
| 165 | |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 166 | #include "libunwind-common.h" |
| 167 | |
hp.com!davidm | d3725a7 | 2004-01-22 08:36:15 +0000 | [diff] [blame^] | 168 | #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) |
| 169 | extern int unw_tdep_is_fpreg (int); |
| 170 | |
mostang.com!davidm | 337c0ad | 2003-03-28 07:43:22 +0000 | [diff] [blame] | 171 | #if defined(__cplusplus) || defined(c_plusplus) |
| 172 | } |
| 173 | #endif |
| 174 | |
mostang.com!davidm | 26f6cf7 | 2003-01-21 08:08:32 +0000 | [diff] [blame] | 175 | #endif /* LIBUNWIND_H */ |