1
0
mirror of https://github.com/golang/go synced 2024-11-25 09:07:58 -07:00

runtime: use GOTRACEBACK to decide whether to show runtime frames

Right now, GOTRACEBACK=0 means do not show any stack traces.
Unset means the default behavior (declutter by hiding runtime routines).

This CL makes GOTRACEBACK=2 mean include the runtime routines.
It avoids having to recompile the runtime when you want to see
the runtime in the tracebacks.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5633050
This commit is contained in:
Russ Cox 2012-02-06 11:24:14 -05:00
parent 0b9f090861
commit 48bd13911d

View File

@ -507,6 +507,9 @@ contains(String s, int8 *p)
bool bool
runtime·showframe(Func *f) runtime·showframe(Func *f)
{ {
// return 1; // for debugging - show all frames static int32 traceback = -1;
return contains(f->name, ".") && !hasprefix(f->name, "runtime.");
if(traceback < 0)
traceback = runtime·gotraceback();
return traceback > 1 || contains(f->name, ".") && !hasprefix(f->name, "runtime.");
} }