runtime: add page tracer

This change adds a new GODEBUG flag called pagetrace that writes a
low-overhead trace of how pages of memory are managed by the Go runtime.

The page tracer is kept behind a GOEXPERIMENT flag due to a potential
security risk for setuid binaries.

Change-Id: I6f4a2447d02693c25214400846a5d2832ad6e5c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/444157
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Michael Knyszek 2022-10-19 14:51:15 -04:00
parent 0613418c98
commit e4435cb844
51 changed files with 636 additions and 29 deletions

View file

@ -0,0 +1,25 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build unix
package runtime_test
import (
"runtime"
"syscall"
"testing"
)
func TestSyscallFlagAlignment(t *testing.T) {
// TODO(mknyszek): Check other flags.
check := func(name string, got, want int) {
if got != want {
t.Errorf("flag %s does not line up: got %d, want %d", name, got, want)
}
}
check("O_WRONLY", runtime.O_WRONLY, syscall.O_WRONLY)
check("O_CREAT", runtime.O_CREAT, syscall.O_CREAT)
check("O_TRUNC", runtime.O_TRUNC, syscall.O_TRUNC)
}