libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] [patch] Implement _Unwind_GetIPInfo (GCC PR target/278


From: Jan Kratochvil
Subject: [Libunwind-devel] [patch] Implement _Unwind_GetIPInfo (GCC PR target/27880)
Date: Tue, 31 Mar 2009 23:14:31 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

Hi,

there are various problems that libunwind implements the unwinding ABI but not
completely - _Unwind_GetIPInfo() is missing there.

libgcc contains a stub based on _Unwind_GetIP() by gcc/unwind-compat.c.
Still libstdc++ and libjava can fail as they do not have such emulation.

Based the implementation on gcc/unwind-dw2.c:

/* Retrieve the return address and flag whether that IP is before
   or after first not yet fully executed instruction.  */

inline _Unwind_Ptr
_Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn)
{
  *ip_before_insn = _Unwind_IsSignalFrame (context);
  return (_Unwind_Ptr) context->ra;
}

Based on info by Jakub Jelinek (although he did suggest *ip_before_insn = 0).


Thanks,
Jan


Signed-off-by: Jan Kratochvil <address@hidden>

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..63b8dcc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,7 +66,8 @@ libunwind_la_SOURCES_local_unwind =                           
        \
        unwind/Backtrace.c unwind/DeleteException.c                     \
        unwind/FindEnclosingFunction.c unwind/ForcedUnwind.c            \
        unwind/GetBSP.c unwind/GetCFA.c unwind/GetDataRelBase.c         \
-       unwind/GetGR.c unwind/GetIP.c unwind/GetLanguageSpecificData.c  \
+       unwind/GetGR.c unwind/GetIP.c unwind/GetIPInfo.c                \
+       unwind/GetLanguageSpecificData.c                                \
        unwind/GetRegionStart.c unwind/GetTextRelBase.c                 \
        unwind/RaiseException.c unwind/Resume.c                         \
        unwind/Resume_or_Rethrow.c unwind/SetGR.c unwind/SetIP.c
diff --git a/src/unwind/GetIPInfo.c b/src/unwind/GetIPInfo.c
new file mode 100644
index 0000000..b885ede
--- /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 <address@hidden>
+
+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-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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]