aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2015-02-06 05:03:22 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-02-06 05:03:22 +0000
commit8c5c44aa7ebe78bf12dc7b9a2f5e71f94feacc30 (patch)
treefb946aefe6bb8d802e6fb91e82ee3439ce470d9f /libgo
parentc4feb478a6c0063b1f4b86d2a5d47b1a6a7f09f4 (diff)
downloadgcc-8c5c44aa7ebe78bf12dc7b9a2f5e71f94feacc30.zip
gcc-8c5c44aa7ebe78bf12dc7b9a2f5e71f94feacc30.tar.gz
gcc-8c5c44aa7ebe78bf12dc7b9a2f5e71f94feacc30.tar.bz2
runtime: Add memprofilerate to GODEBUG
Add memprofilerate as a value recognized in the GODEBUG env var. The value provided is used as the new setting for runtime.MemProfileRate, allowing the user to adjust memory profiling. From-SVN: r220470
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/runtime/extern.go4
-rw-r--r--libgo/runtime/runtime.c16
2 files changed, 19 insertions, 1 deletions
diff --git a/libgo/go/runtime/extern.go b/libgo/go/runtime/extern.go
index 393984c..3c3e427 100644
--- a/libgo/go/runtime/extern.go
+++ b/libgo/go/runtime/extern.go
@@ -39,6 +39,10 @@ a comma-separated list of name=val pairs. Supported names are:
gcdead: setting gcdead=1 causes the garbage collector to clobber all stack slots
that it thinks are dead.
+ memprofilerate: setting memprofilerate=X changes the setting for
+ runtime.MemProfileRate. Refer to the description of this variable for how
+ it is used and its default value.
+
scheddetail: setting schedtrace=X and scheddetail=1 causes the scheduler to emit
detailed multiline info every X milliseconds, describing state of the scheduler,
processors, threads and goroutines.
diff --git a/libgo/runtime/runtime.c b/libgo/runtime/runtime.c
index 6e0d164..e332035 100644
--- a/libgo/runtime/runtime.c
+++ b/libgo/runtime/runtime.c
@@ -22,6 +22,10 @@ enum {
// gotraceback value.
static uint32 traceback_cache = ~(uint32)0;
+extern volatile intgo runtime_MemProfileRate
+ __asm__ (GOSYM_PREFIX "runtime.MemProfileRate");
+
+
// The GOTRACEBACK environment variable controls the
// behavior of a Go program that is crashing and exiting.
// GOTRACEBACK=0 suppress all tracebacks
@@ -315,6 +319,11 @@ runtime_signalstack(byte *p, int32 n)
DebugVars runtime_debug;
+// Holds variables parsed from GODEBUG env var,
+// except for "memprofilerate" since there is an
+// existing var for that value which is int
+// instead of in32 and might have an
+// initial value.
static struct {
const char* name;
int32* value;
@@ -349,7 +358,12 @@ runtime_parsedebugvars(void)
for(;;) {
for(i=0; i<(intgo)nelem(dbgvar); i++) {
n = runtime_findnull((const byte*)dbgvar[i].name);
- if(runtime_mcmp(p, dbgvar[i].name, n) == 0 && p[n] == '=')
+ if(runtime_mcmp(p, "memprofilerate", n) == 0 && p[n] == '=')
+ // Set the MemProfileRate directly since it
+ // is an int, not int32, and should only lbe
+ // set here if specified by GODEBUG
+ runtime_MemProfileRate = runtime_atoi(p+n+1);
+ else if(runtime_mcmp(p, dbgvar[i].name, n) == 0 && p[n] == '=')
*dbgvar[i].value = runtime_atoi(p+n+1);
}
p = (const byte *)runtime_strstr((const char *)p, ",");