commit 2bb0660844a9b56d811779055a1298ba228a1622 Author: Arun Sharma Date: Thu Apr 2 15:49:37 2009 -0700 Implement _Unwind_GetIPInfo() as required by the C++ ABI Provide a special implementation for ia64, because the unwind information is such that an IP adjustment is not necessary before looking up unwind info. Bad things happen if libunwind only provides parts of the ABI and the rest come from libgcc. Signed-off-by: Jan Kratochvil diff --git a/configure.in b/configure.in index 7ea5eb4..0bc2e61 100644 --- a/configure.in +++ b/configure.in @@ -123,6 +123,8 @@ AC_ARG_ENABLE(cxx_exceptions, # C++ exception handling doesn't work too well on x86 case $target_arch in x86*) enable_cxx_exceptions=no;; + arm*) enable_cxx_exceptions=no;; + mips*) enable_cxx_exceptions=no;; *) enable_cxx_exceptions=yes;; esac ]) diff --git a/include/unwind.h b/include/unwind.h index 1f94a0d..d9a767d 100644 --- a/include/unwind.h +++ b/include/unwind.h @@ -88,6 +88,7 @@ extern void _Unwind_DeleteException (struct _Unwind_Exception *); extern unsigned long _Unwind_GetGR (struct _Unwind_Context *, int); extern void _Unwind_SetGR (struct _Unwind_Context *, int, unsigned long); extern unsigned long _Unwind_GetIP (struct _Unwind_Context *); +extern unsigned long _Unwind_GetIPInfo (struct _Unwind_Context *, int *); extern void _Unwind_SetIP (struct _Unwind_Context *, unsigned long); extern unsigned long _Unwind_GetLanguageSpecificData (struct _Unwind_Context*); extern unsigned long _Unwind_GetRegionStart (struct _Unwind_Context *); diff --git a/src/Makefile.am b/src/Makefile.am index 883e019..c08fb4a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -71,6 +71,12 @@ libunwind_la_SOURCES_local_unwind = \ unwind/RaiseException.c unwind/Resume.c \ unwind/Resume_or_Rethrow.c unwind/SetGR.c unwind/SetIP.c +if ARCH_IA64 +libunwind_la_SOURCES_local_unwind += ia64/unwind_GetIPInfo.c +else +libunwind_la_SOURCES_local_unwind += unwind/GetIPInfo.c +endif # ARCH_IA64 + # _ReadULEB()/_ReadSLEB() are needed for Intel C++ 8.0 compatibility libunwind_la_SOURCES_os_linux_local = mi/_ReadULEB.c mi/_ReadSLEB.c endif @@ -88,21 +94,9 @@ libunwind_la_SOURCES_local_nounwind = \ mi/Lget_fpreg.c mi/Lset_fpreg.c \ mi/Lset_caching_policy.c -# On some platforms, defining _Unwind replacements really upsets -# exception-handling. Turn off those functions for those platforms. -if ARCH_ARM -libunwind_la_SOURCES_local = \ - $(libunwind_la_SOURCES_local_nounwind) -else -if ARCH_MIPS -libunwind_la_SOURCES_local = \ - $(libunwind_la_SOURCES_local_nounwind) -else libunwind_la_SOURCES_local = \ $(libunwind_la_SOURCES_local_nounwind) \ $(libunwind_la_SOURCES_local_unwind) -endif # ARCH_MIPS -endif # ARCH_ARM libunwind_la_SOURCES_os_linux = os-linux.h os-linux.c diff --git a/src/ia64/unwind_GetIPInfo.c b/src/ia64/unwind_GetIPInfo.c new file mode 100644 index 0000000..dfdf5e8 --- /dev/null +++ b/src/ia64/unwind_GetIPInfo.c @@ -0,0 +1,43 @@ +/* libunwind - a platform-independent unwind library + Copyright (C) 2009 Red Hat + Contributed by Jan Kratochvil + +This file is part of libunwind. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#include "../unwind/unwind-internal.h" + +/* gcc/unwind-dw2.c: Retrieve the return address and flag whether that IP is + before or after first not yet fully executed instruction. + IP_BEFORE_INSN ensures leaving IP intact as was designed for ia64. */ + +PROTECTED unsigned long +_Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn) +{ + unw_word_t val; + + unw_get_reg (&context->cursor, UNW_REG_IP, &val); + *ip_before_insn = 1; + return val; +} + +unsigned long __libunwind_Unwind_GetIPInfo (struct _Unwind_Context *, int *) + ALIAS (_Unwind_GetIPInfo); diff --git a/src/unwind/GetIPInfo.c b/src/unwind/GetIPInfo.c new file mode 100644 index 0000000..c81db27 --- /dev/null +++ b/src/unwind/GetIPInfo.c @@ -0,0 +1,42 @@ +/* libunwind - a platform-independent unwind library + Copyright (C) 2009 Red Hat + Contributed by Jan Kratochvil + +This file is part of libunwind. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#include "../unwind/unwind-internal.h" + +/* gcc/unwind-dw2.c: Retrieve the return address and flag whether that IP is + before or after first not yet fully executed instruction. */ + +PROTECTED unsigned long +_Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn) +{ + unw_word_t val; + + unw_get_reg (&context->cursor, UNW_REG_IP, &val); + *ip_before_insn = unw_is_signal_frame (&context->cursor); + return val; +} + +unsigned long __libunwind_Unwind_GetIPInfo (struct _Unwind_Context *, int *) + ALIAS (_Unwind_GetIPInfo); diff --git a/tests/check-namespace.sh.in b/tests/check-namespace.sh.in index 007ba43..66078a1 100644 --- a/tests/check-namespace.sh.in +++ b/tests/check-namespace.sh.in @@ -197,6 +197,7 @@ check_cxx_abi () { match _Unwind_GetDataRelBase match _Unwind_GetGR match _Unwind_GetIP + match _Unwind_GetIPInfo match _Unwind_GetLanguageSpecificData match _Unwind_GetRegionStart match _Unwind_GetTextRelBase @@ -214,6 +215,7 @@ check_cxx_abi () { match __libunwind_Unwind_GetDataRelBase match __libunwind_Unwind_GetGR match __libunwind_Unwind_GetIP + match __libunwind_Unwind_GetIPInfo match __libunwind_Unwind_GetLanguageSpecificData match __libunwind_Unwind_GetRegionStart match __libunwind_Unwind_GetTextRelBase