ibm.com!masbock | a766efd | 2004-08-19 13:39:10 +0000 | [diff] [blame] | 1 | /* libunwind - a platform-independent unwind library |
| 2 | Copyright (C) 2002-2004 Hewlett-Packard Co |
| 3 | Contributed by David Mosberger-Tang <davidm@hpl.hp.com> |
| 4 | |
| 5 | Modified for x86_64 by Max Asbock <masbock@us.ibm.com> |
| 6 | |
| 7 | This file is part of libunwind. |
| 8 | |
| 9 | Permission is hereby granted, free of charge, to any person obtaining |
| 10 | a copy of this software and associated documentation files (the |
| 11 | "Software"), to deal in the Software without restriction, including |
| 12 | without limitation the rights to use, copy, modify, merge, publish, |
| 13 | distribute, sublicense, and/or sell copies of the Software, and to |
| 14 | permit persons to whom the Software is furnished to do so, subject to |
| 15 | the following conditions: |
| 16 | |
| 17 | The above copyright notice and this permission notice shall be |
| 18 | included in all copies or substantial portions of the Software. |
| 19 | |
| 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 21 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 22 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 23 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 25 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 26 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 27 | |
| 28 | #ifndef LIBUNWIND_H |
| 29 | #define LIBUNWIND_H |
| 30 | |
| 31 | #if defined(__cplusplus) || defined(c_plusplus) |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | |
| 35 | #include <inttypes.h> |
| 36 | #include <ucontext.h> |
| 37 | |
| 38 | #define UNW_TARGET x86_64 |
| 39 | #define UNW_TARGET_X86_64 1 |
| 40 | |
| 41 | #define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ |
| 42 | |
| 43 | /* This needs to be big enough to accommodate "struct cursor", while |
| 44 | leaving some slack for future expansion. Changing this value will |
| 45 | require recompiling all users of this library. Stack allocation is |
| 46 | relatively cheap and unwind-state copying is relatively rare, so we |
| 47 | want to err on making it rather too big than too small. */ |
| 48 | #define UNW_TDEP_CURSOR_LEN 127 |
| 49 | |
| 50 | typedef uint64_t unw_word_t; |
| 51 | |
| 52 | typedef long double unw_tdep_fpreg_t; |
| 53 | |
| 54 | typedef enum |
| 55 | { |
| 56 | UNW_X86_64_RAX, |
| 57 | UNW_X86_64_RDX, |
| 58 | UNW_X86_64_RCX, |
| 59 | UNW_X86_64_RBX, |
| 60 | UNW_X86_64_RSI, |
| 61 | UNW_X86_64_RDI, |
| 62 | UNW_X86_64_RBP, |
| 63 | UNW_X86_64_RSP, |
| 64 | UNW_X86_64_R8, |
| 65 | UNW_X86_64_R9, |
| 66 | UNW_X86_64_R10, |
| 67 | UNW_X86_64_R11, |
| 68 | UNW_X86_64_R12, |
| 69 | UNW_X86_64_R13, |
| 70 | UNW_X86_64_R14, |
| 71 | UNW_X86_64_R15, |
| 72 | UNW_X86_64_RIP, |
| 73 | |
| 74 | /* XXX Add other regs here */ |
| 75 | |
| 76 | /* frame info (read-only) */ |
| 77 | UNW_X86_64_CFA, |
| 78 | |
| 79 | UNW_TDEP_LAST_REG = UNW_X86_64_RIP, |
| 80 | |
| 81 | UNW_TDEP_IP = UNW_X86_64_RIP, |
| 82 | UNW_TDEP_SP = UNW_X86_64_RSP, |
| 83 | UNW_TDEP_BP = UNW_X86_64_RBP, |
| 84 | UNW_TDEP_EH = UNW_X86_64_RAX |
| 85 | } |
| 86 | x86_64_regnum_t; |
| 87 | |
| 88 | #define UNW_TDEP_NUM_EH_REGS 2 /* XXX Not sure what this means */ |
| 89 | |
| 90 | typedef struct unw_tdep_save_loc |
| 91 | { |
| 92 | /* Additional target-dependent info on a save location. */ |
| 93 | } |
| 94 | unw_tdep_save_loc_t; |
| 95 | |
| 96 | /* On x86_64, we can directly use ucontext_t as the unwind context. */ |
| 97 | typedef ucontext_t unw_tdep_context_t; |
| 98 | |
| 99 | /* XXX this is not ideal: an application should not be prevented from |
| 100 | using the "getcontext" name just because it's using libunwind. We |
| 101 | can't just use __getcontext() either, because that isn't exported |
| 102 | by glibc... */ |
| 103 | #define unw_tdep_getcontext(uc) (getcontext (uc), 0) |
| 104 | |
| 105 | #include "libunwind-dynamic.h" |
| 106 | |
| 107 | typedef struct |
| 108 | { |
| 109 | unw_dyn_dwarf_fde_info_t dwarf_info; |
| 110 | } |
| 111 | unw_tdep_proc_info_t; |
| 112 | |
| 113 | #include "libunwind-common.h" |
| 114 | |
| 115 | #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) |
| 116 | extern int unw_tdep_is_fpreg (int); |
| 117 | |
| 118 | #if defined(__cplusplus) || defined(c_plusplus) |
| 119 | } |
| 120 | #endif |
| 121 | |
| 122 | #endif /* LIBUNWIND_H */ |