aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/runtime.c
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2013-06-28 18:37:06 +0400
committerDmitriy Vyukov <dvyukov@google.com>2013-06-28 18:37:06 +0400
commit4b536a550f1a9edd7be5c777dfb5eb906320eb89 (patch)
treeb372383d0e4c6b715a2baf475d68391f40d1a652 /src/pkg/runtime/runtime.c
parent1e112cd59f560129f4dca5e9af7c3cbc445850b6 (diff)
downloadgo-4b536a550f1a9edd7be5c777dfb5eb906320eb89.tar.xz
runtime: introduce GODEBUG env var
Currently it replaces GOGCTRACE env var (GODEBUG=gctrace=1). The plan is to extend it with other type of debug tracing, e.g. GODEBUG=gctrace=1,schedtrace=100. R=rsc CC=bradfitz, daniel.morsing, gobot, golang-dev https://golang.org/cl/10026045
Diffstat (limited to 'src/pkg/runtime/runtime.c')
-rw-r--r--src/pkg/runtime/runtime.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c
index d62408118b..f59a3f4e80 100644
--- a/src/pkg/runtime/runtime.c
+++ b/src/pkg/runtime/runtime.c
@@ -365,3 +365,34 @@ runtime∕pprof·runtime_cyclesPerSecond(int64 res)
res = runtime·tickspersecond();
FLUSH(&res);
}
+
+DebugVars runtime·debug;
+
+static struct {
+ int8* name;
+ int32* value;
+} dbgvar[] = {
+ {"gctrace", &runtime·debug.gctrace},
+};
+
+void
+runtime·parsedebugvars(void)
+{
+ byte *p;
+ int32 i, n;
+
+ p = runtime·getenv("GODEBUG");
+ if(p == nil)
+ return;
+ for(;;) {
+ for(i=0; i<nelem(dbgvar); i++) {
+ n = runtime·findnull((byte*)dbgvar[i].name);
+ if(runtime·mcmp(p, (byte*)dbgvar[i].name, n) == 0 && p[n] == '=')
+ *dbgvar[i].value = runtime·atoi(p+n+1);
+ }
+ p = runtime·strstr(p, (byte*)",");
+ if(p == nil)
+ break;
+ p++;
+ }
+}