ogle/probe: allow zero-sized reads and writes.
Go has zero-sized types, and it would be nice if
validRead(&x, sizeof(x)) was true for any legit variable x.
LGTM=r
R=r
https://golang.org/cl/62000044
diff --git a/probe/addr_test.go b/probe/addr_test.go
index 89c52ae..f35a9f0 100644
--- a/probe/addr_test.go
+++ b/probe/addr_test.go
@@ -90,6 +90,7 @@
func TestReadAddressSpan(t *testing.T) {
spans := []span{
+ {base(), 0, true},
{base(), 1, true},
{base(), 4096, true},
{base(), int(heapStart() - base()), false},
@@ -107,6 +108,7 @@
func TestWriteAddressSpan(t *testing.T) {
spans := []span{
+ {etext(), 0, true},
{etext(), 1, true},
{etext(), 4096, true},
{etext(), int(heapStart() - base()), false},
diff --git a/probe/probe.go b/probe/probe.go
index d932695..264787d 100644
--- a/probe/probe.go
+++ b/probe/probe.go
@@ -22,7 +22,7 @@
// validRead reports whether a read of the specified size can be done at address p.
func validRead(p uintptr, size int) bool {
- if size <= 0 {
+ if size < 0 {
return false
}
// The read must be in a single contiguous valid region.
@@ -40,7 +40,7 @@
// validWrite reports whether a write of the specified size can be done at address p.
func validWrite(p uintptr, size int) bool {
- if size <= 0 {
+ if size < 0 {
return false
}
// The write must be in a single contiguous valid region.