This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] PR26792: use _Unwind_GetIP when HAVE_GETIPINFO not defined
- From: howarth at bromo dot msbb dot uc dot edu (Jack Howarth)
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Sep 2006 00:31:01 -0400 (EDT)
- Subject: [patch] PR26792: use _Unwind_GetIP when HAVE_GETIPINFO not defined
The attached patch restores the previous code, which used
_Unwind_GetIP, for the case when HAVE_GETIPINFO is undefined
by configure. I have verified on powerpc-apple-darwin8
that this eliminates the introduction of the _Unwind_GetIPInfo
symbol into libgcj when either MACOSX_DEPLOYMENT_TARGET is
unset or is set to 10.4. This is because the configure test
uses the static libgcc.a on Darwin which always lacks the
_Unwind_GetIPInfo symbol (although libgcc_s.1.dylib will
have it but not libgcc_s.10.4.dylib or libgcc_s.10.5.dylib).
This is the behavior we want on Darwin (to never add
_Unwind_GetIPInfo to libstdc++ or libgcj) as to do
so would cause linkage problems when MACOSX_DEPLOYMENT_TARGET
was set to 10.4 or 10.5. Okay for trunk?
Jack
ps I would note that my contribution to this patch was the
10 preprocessor statements and that the remaining code was
simple cut and paste from the diff when _Unwind_GetIPInfo
was introduced into these files.
2006-09-20 Jack Howarth <howarth@bromo.med.uc.edu>
PR target/26792
* exception.cc (PERSONALITY_FUNCTION): use _Unwind_GetIP
if HAVE_GETIPINFO not defined.
* stacktrace.cc (_Jv_StackTrace::UnwindTraceFn): Likewise.
(_Jv_StackTrace::getLineNumberForFrame): Likewise.
Index: exception.cc
===================================================================
--- exception.cc (revision 116995)
+++ exception.cc (working copy)
@@ -231,7 +231,11 @@ PERSONALITY_FUNCTION (int version,
// Parse the LSDA header.
p = parse_lsda_header (context, language_specific_data, &info);
+ #ifdef HAVE_GETIPINFO
ip = _Unwind_GetIPInfo (context, &ip_before_insn);
+ #else
+ ip = _Unwind_GetIP (context) - 1;
+ #endif
if (! ip_before_insn)
--ip;
landing_pad = 0;
Index: stacktrace.cc
===================================================================
--- stacktrace.cc (revision 116995)
+++ stacktrace.cc (working copy)
@@ -131,6 +131,7 @@ _Jv_StackTrace::UnwindTraceFn (struct _U
else
#endif
{
+#ifdef HAVE_GETIPINFO
_Unwind_Ptr ip;
int ip_before_insn = 0;
ip = _Unwind_GetIPInfo (context, &ip_before_insn);
@@ -139,9 +140,13 @@ _Jv_StackTrace::UnwindTraceFn (struct _U
// to ensure we get the correct line number for the call itself.
if (! ip_before_insn)
--ip;
-
+#endif
state->frames[pos].type = frame_native;
+#ifdef HAVE_GETIPINFO
state->frames[pos].ip = (void *) ip;
+#else
+ state->frames[pos].ip = (void *) _Unwind_GetIP (context);
+#endif
state->frames[pos].start_ip = func_addr;
}
@@ -217,6 +222,12 @@ _Jv_StackTrace::getLineNumberForFrame(_J
else
offset = (_Unwind_Ptr) ip - (_Unwind_Ptr) info.base;
+#ifndef HAVE_GETIPINFO
+ // The unwinder gives us the return address. In order to get the right
+ // line number for the stack trace, roll it back a little.
+ offset -= 1;
+#endif
+
finder->lookup (binaryName, (jlong) offset);
*sourceFileName = finder->getSourceFile();
*lineNum = finder->getLineNum();