From e09f9701ffcd05b097565d15daa87ac1b2d84299 Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Sat, 18 Jun 2011 20:16:13 -0700 Subject: [PATCH] Handle register nums > 16 on x86_64 gcc generates them when using ms-abi. Support disabled by default since it increases the cache footprint of the library. --- configure.in | 11 ++++++++++- include/libunwind-x86_64.h | 24 ++++++++++++++++++++++-- include/tdep-x86_64/dwarf-config.h | 6 +++++- src/x86_64/Gglobal.c | 22 ++++++++++++++++++++-- 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/configure.in b/configure.in index 724b1245..715b2f48 100644 --- a/configure.in +++ b/configure.in @@ -220,7 +220,7 @@ AC_MSG_RESULT([$enable_block_signals]) AC_MSG_CHECKING([whether to validate memory addresses before use]) AC_ARG_ENABLE(conservative_checks, -[ --enable-conservative-checks Validate all memory addresses before use], +[ --enable-conservative-checks Validate all memory addresses before use], [enable_conservative_checks=$enableval], [enable_conservative_checks=yes]) if test x$enable_conservative_checks = xyes; then AC_DEFINE(CONSERVATIVE_CHECKS, 1, @@ -228,6 +228,15 @@ if test x$enable_conservative_checks = xyes; then fi AC_MSG_RESULT([$enable_conservative_checks]) +AC_MSG_CHECKING([whether to enable msabi support]) +AC_ARG_ENABLE(msabi_support, +[ --enable-msabi-support Enables support for Microsoft ABI extensions ], +[enable_msabi_support=$enableval], [enable_msabi_support=no]) +if test x$enable_msabi_support = xyes; then + AC_DEFINE([CONFIG_MSABI_SUPPORT], [], [Support for Microsoft ABI extensions]) +fi +AC_MSG_RESULT([$enable_msabi_support]) + LIBUNWIND___THREAD AC_MSG_CHECKING([for Intel compiler]) diff --git a/include/libunwind-x86_64.h b/include/libunwind-x86_64.h index 50b4de21..c89f0469 100644 --- a/include/libunwind-x86_64.h +++ b/include/libunwind-x86_64.h @@ -32,6 +32,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ extern "C" { #endif +#include #include #include #include @@ -72,14 +73,33 @@ typedef enum UNW_X86_64_R14, UNW_X86_64_R15, UNW_X86_64_RIP, +#ifdef CONFIG_MSABI_SUPPORT + UNW_X86_64_XMM0, + UNW_X86_64_XMM1, + UNW_X86_64_XMM2, + UNW_X86_64_XMM3, + UNW_X86_64_XMM4, + UNW_X86_64_XMM5, + UNW_X86_64_XMM6, + UNW_X86_64_XMM7, + UNW_X86_64_XMM8, + UNW_X86_64_XMM9, + UNW_X86_64_XMM10, + UNW_X86_64_XMM11, + UNW_X86_64_XMM12, + UNW_X86_64_XMM13, + UNW_X86_64_XMM14, + UNW_X86_64_XMM15, + UNW_TDEP_LAST_REG = UNW_X86_64_XMM15, +#else + UNW_TDEP_LAST_REG = UNW_X86_64_RIP, +#endif /* XXX Add other regs here */ /* frame info (read-only) */ UNW_X86_64_CFA, - UNW_TDEP_LAST_REG = UNW_X86_64_RIP, - UNW_TDEP_IP = UNW_X86_64_RIP, UNW_TDEP_SP = UNW_X86_64_RSP, UNW_TDEP_BP = UNW_X86_64_RBP, diff --git a/include/tdep-x86_64/dwarf-config.h b/include/tdep-x86_64/dwarf-config.h index 8023f36f..d3cbe7c2 100644 --- a/include/tdep-x86_64/dwarf-config.h +++ b/include/tdep-x86_64/dwarf-config.h @@ -32,9 +32,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define dwarf_config_h /* XXX need to verify if this value is correct */ +#ifdef CONFIG_MSABI_SUPPORT +#define DWARF_NUM_PRESERVED_REGS 33 +#else #define DWARF_NUM_PRESERVED_REGS 17 +#endif -#define DWARF_REGNUM_MAP_LENGTH 17 +#define DWARF_REGNUM_MAP_LENGTH DWARF_NUM_PRESERVED_REGS /* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ #define dwarf_is_big_endian(addr_space) 0 diff --git a/src/x86_64/Gglobal.c b/src/x86_64/Gglobal.c index 8decf325..8eba27aa 100644 --- a/src/x86_64/Gglobal.c +++ b/src/x86_64/Gglobal.c @@ -33,7 +33,7 @@ HIDDEN int tdep_needs_initialization = 1; /* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */ -HIDDEN uint8_t dwarf_to_unw_regnum_map[17] = +HIDDEN uint8_t dwarf_to_unw_regnum_map[DWARF_NUM_PRESERVED_REGS] = { UNW_X86_64_RAX, UNW_X86_64_RDX, @@ -51,7 +51,25 @@ HIDDEN uint8_t dwarf_to_unw_regnum_map[17] = UNW_X86_64_R13, UNW_X86_64_R14, UNW_X86_64_R15, - UNW_X86_64_RIP + UNW_X86_64_RIP, +#ifdef CONFIG_MSABI_SUPPORT + UNW_X86_64_XMM0, + UNW_X86_64_XMM1, + UNW_X86_64_XMM2, + UNW_X86_64_XMM3, + UNW_X86_64_XMM4, + UNW_X86_64_XMM5, + UNW_X86_64_XMM6, + UNW_X86_64_XMM7, + UNW_X86_64_XMM8, + UNW_X86_64_XMM9, + UNW_X86_64_XMM10, + UNW_X86_64_XMM11, + UNW_X86_64_XMM12, + UNW_X86_64_XMM13, + UNW_X86_64_XMM14, + UNW_X86_64_XMM15 +#endif }; HIDDEN void