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]

libgo patch committed: Stop backtrace at recognized functions


This patch to libgo stop a backtrace at a few recognized functions.

On x86_64 Solaris the makecontext function does not properly indicate
that it is at the top of the stack.  Attempting to unwind the stack past
a call to makecontext tends to crash.  This patch changes libgo to look
for certain functions that are always found at the top of the stack, and
to stop unwinding when it reaches one of those functions.  There is
never anything interesting past these functions--that is, there is never
any code written by the user.

This is PR go/52583.

Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.  Ran a
couple of tests on x86_64-sun-solaris2.11.  Committed to mainline.

Ian

diff -r 20ec6ca8d43f libgo/runtime/go-callers.c
--- a/libgo/runtime/go-callers.c	Fri Jun 13 06:48:36 2014 -0700
+++ b/libgo/runtime/go-callers.c	Fri Jun 13 06:50:22 2014 -0700
@@ -93,6 +93,32 @@
 
   loc->lineno = lineno;
   ++arg->index;
+
+  /* There is no point to tracing past certain runtime functions.
+     Stopping the backtrace here can avoid problems on systems that
+     don't provide proper unwind information for makecontext, such as
+     Solaris (http://gcc.gnu.org/PR52583 comment #21).  */
+  if (function != NULL)
+    {
+      if (__builtin_strcmp (function, "makecontext") == 0)
+	return 1;
+      if (filename != NULL)
+	{
+	  const char *p;
+
+	  p = strrchr (filename, '/');
+	  if (p == NULL)
+	    p = filename;
+	  if (__builtin_strcmp (p, "/proc.c") == 0)
+	    {
+	      if (__builtin_strcmp (function, "kickoff") == 0
+		  || __builtin_strcmp (function, "runtime_mstart") == 0
+		  || __builtin_strcmp (function, "runtime_main") == 0)
+		return 1;
+	    }
+	}
+    }
+
   return arg->index >= arg->max;
 }
 

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