From b39e15dde5ec7b96c15da9faf4ab5892501c1aae Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 23 Mar 2013 11:28:53 +0100 Subject: Imported Upstream version 1.1~hg20130323 --- src/pkg/runtime/runtime.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/pkg/runtime/runtime.c') diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c index 4d57cbafd..d62408118 100644 --- a/src/pkg/runtime/runtime.c +++ b/src/pkg/runtime/runtime.c @@ -17,21 +17,34 @@ enum { */ void runtime·sigpanic(void); +// The GOTRACEBACK environment variable controls the +// behavior of a Go program that is crashing and exiting. +// GOTRACEBACK=0 suppress all tracebacks +// GOTRACEBACK=1 default behavior - show tracebacks but exclude runtime frames +// GOTRACEBACK=2 show tracebacks including runtime frames +// GOTRACEBACK=crash show tracebacks including runtime frames, then crash (core dump etc) int32 -runtime·gotraceback(void) +runtime·gotraceback(bool *crash) { byte *p; + if(crash != nil) + *crash = false; p = runtime·getenv("GOTRACEBACK"); if(p == nil || p[0] == '\0') return 1; // default is on + if(runtime·strcmp(p, (byte*)"crash") == 0) { + if(crash != nil) + *crash = true; + return 2; // extra information + } return runtime·atoi(p); } int32 -runtime·mcmp(byte *s1, byte *s2, uint32 n) +runtime·mcmp(byte *s1, byte *s2, uintptr n) { - uint32 i; + uintptr i; byte c1, c2; for(i=0; i