diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-11-30 20:28:28 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-11-30 20:28:28 +0000 |
commit | 24f1d7f80e0bb3fbb9b845300153d367b0cf2f5f (patch) | |
tree | af388d60fbccb515b0412b2eb67e16a81240830d | |
parent | df3f12771261f378bd250a9869271c37c69682a7 (diff) | |
download | gcc-24f1d7f80e0bb3fbb9b845300153d367b0cf2f5f.zip gcc-24f1d7f80e0bb3fbb9b845300153d367b0cf2f5f.tar.gz gcc-24f1d7f80e0bb3fbb9b845300153d367b0cf2f5f.tar.bz2 |
runtime: print C functions in traceback
Since gccgo can trace back through C code as easily as Go code, we
should print C functions in the traceback.
This worked before https://golang.org/cl/31230 for a dumb reason. The
default value for runtime.traceback_cache was, and is, 2 << 2, meaning
to print all functions. The old C code for runtime_parsedebugvars
would return immediately and do nothing if the environment variable
GODEBUG was not set (if GODEBUG was set it would later call
setTraceback. The new Go code for runtime.parsedebugvars does not
return immediately if GODEBUG is not set, and always calls
setTraceback. Either way, if GOTRACEBACK is not set, setTraceback
would set traceback_cache to 1 << 2, meaning to only print non-runtime
functions and having the effect of not printing plain C functions.
Keep the current handling of GODEBUG/GOTRACEBACK, which matches the gc
library, but add an extra check to print C functions by default.
Reviewed-on: https://go-review.googlesource.com/33717
From-SVN: r243083
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | libgo/go/runtime/traceback_gccgo.go | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index ead134c..323b07c 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -1d3e0ceee45012a1c3b4ff7f5119a72f90bfcf6a +9be198d960e4bc46e21e4da1e3d4a1619266b8ab The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/go/runtime/traceback_gccgo.go b/libgo/go/runtime/traceback_gccgo.go index b102826..f61f9a0 100644 --- a/libgo/go/runtime/traceback_gccgo.go +++ b/libgo/go/runtime/traceback_gccgo.go @@ -89,6 +89,15 @@ func showframe(name string, gp *g) bool { if g.m.throwing > 0 && gp != nil && (gp == g.m.curg || gp == g.m.caughtsig.ptr()) { return true } + + // Gccgo can trace back through C functions called via cgo. + // We want to print those in the traceback. + // But unless GOTRACEBACK > 1 (checked below), still skip + // internal C functions and cgo-generated functions. + if !contains(name, ".") && !hasprefix(name, "__go_") && !hasprefix(name, "_cgo_") { + return true + } + level, _, _ := gotraceback() // Special case: always show runtime.gopanic frame, so that we can |