This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] revised PR26792: use _Unwind_GetIP when HAVE_GETIPINFO not defined


>>>>> "Jack" == Jack Howarth <howarth@bromo.msbb.uc.edu> writes:

Jack> Can you check the revised patch...
Jack> http://gcc.gnu.org/ml/gcc-patches/2006-09/msg01206.html
Jack> ...and the matching configure.ac change...
Jack> http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00908.html

Sure.  I'm actually checking in a slight variant of the patch.  I
fixed the indentation of the preprocessor directives in exception.cc
and I updated the ChangeLog.

Tom

Index: ChangeLog
from  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.
	* configure.ac: use GCC_CHECK_UNWIND_GETIPINFO.
	* aclocal.m4, configure, include/config.h.in, Makefile.in:
	Rebuilt.

Index: exception.cc
===================================================================
--- exception.cc	(revision 117258)
+++ exception.cc	(working copy)
@@ -231,9 +231,13 @@
 
   // Parse the LSDA header.
   p = parse_lsda_header (context, language_specific_data, &info);
+#ifdef HAVE_GETIPINFO
   ip = _Unwind_GetIPInfo (context, &ip_before_insn);
   if (! ip_before_insn)
     --ip;
+#else
+  ip = _Unwind_GetIP (context) - 1;
+#endif
   landing_pad = 0;
   action_record = 0;
   handler_switch_value = 0;
Index: configure.ac
===================================================================
--- configure.ac	(revision 117258)
+++ configure.ac	(working copy)
@@ -1480,6 +1480,9 @@
 # See if we support thread-local storage.
 GCC_CHECK_TLS
 
+# For _Unwind_GetIPInfo.
+GCC_CHECK_UNWIND_GETIPINFO
+
 # Check if linker supports static linking on a per library basis
 LD_START_STATIC_SPEC=
 LD_FINISH_STATIC_SPEC=
Index: stacktrace.cc
===================================================================
--- stacktrace.cc	(revision 117258)
+++ stacktrace.cc	(working copy)
@@ -131,6 +131,7 @@
   else
 #endif
     {
+#ifdef HAVE_GETIPINFO
       _Unwind_Ptr ip;
       int ip_before_insn = 0;
       ip = _Unwind_GetIPInfo (context, &ip_before_insn);
@@ -139,9 +140,13 @@
       // 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 @@
       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();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]