Skip to content

Commit 54245cb

Browse files
committed
runtime: show frames for exported runtime functions
The current Windows build failure happens because by default runtime frames are excluded from stack traces. Apparently the Windows breakpoint path dies with an ordinary panic, while the Unix path dies with a throw. Breakpoint is a strange function and I don't mind that it's a little different on the two operating systems. The panic squelches runtime frames but the throw shows them, because throw is considered something that shouldn't have happened at all, so as much detail as possible is wanted. The runtime exclusion is meant to prevents printing too much noise about internal runtime details. But exported functions are not internal details, so show exported functions. If the program dies because you called runtime.Breakpoint, it's okay to see that frame. This makes the Breakpoint test show Breakpoint in the stack trace no matter how it is handled. Should fix Windows build. Tested on Unix by changing Breakpoint to fault instead of doing a breakpoint. TBR=brainman CC=golang-codereviews https://golang.org/cl/143300043
1 parent 5a40b56 commit 54245cb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/runtime/traceback.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,14 @@ func showframe(f *_func, gp *g) bool {
499499
return true
500500
}
501501

502-
return traceback > 1 || f != nil && contains(name, ".") && !hasprefix(name, "runtime.")
502+
return traceback > 1 || f != nil && contains(name, ".") && (!hasprefix(name, "runtime.") || isExportedRuntime(name))
503+
}
504+
505+
// isExportedRuntime reports whether name is an exported runtime function.
506+
// It is only for runtime functions, so ASCII A-Z is fine.
507+
func isExportedRuntime(name string) bool {
508+
const n = len("runtime.")
509+
return len(name) > n && name[:n] == "runtime." && 'A' <= name[n] && name[n] <= 'Z'
503510
}
504511

505512
var gStatusStrings = [...]string{

0 commit comments

Comments
 (0)