delve/_fixtures/examinememory.go
chainhelen a5d9dbee79
pkg,service: add cmd examinemem(x) for examining memory. (#1814)
According to #1800 #1584 #1038, `dlv` should enable the user to dive into
memory. User can print binary data in specific memory address range.
But not support for sepecific variable name or structures temporarily.(Because
I have no idea that modify `print` command.)

Close #1584.
2020-02-13 09:29:21 -08:00

26 lines
308 B
Go

package main
import (
"fmt"
"unsafe"
)
func main() {
l := int(51)
bs := make([]byte, l)
for i := 0; i < l; i++ {
bs[i] = byte(i + int(10))
}
bsp := (*byte)(unsafe.Pointer(&bs[0]))
bspUintptr := uintptr(unsafe.Pointer(bsp))
fmt.Printf("%#x\n", bspUintptr)
_ = *bsp
bs[0] = 255
_ = *bsp
}