aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/print.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/runtime/print.go')
-rw-r--r--libgo/go/runtime/print.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/libgo/go/runtime/print.go b/libgo/go/runtime/print.go
index 7729ddc..e42023f 100644
--- a/libgo/go/runtime/print.go
+++ b/libgo/go/runtime/print.go
@@ -6,6 +6,7 @@ package runtime
import (
"runtime/internal/atomic"
+ "runtime/internal/sys"
"unsafe"
)
@@ -276,3 +277,56 @@ func printeface(e eface) {
func printiface(i iface) {
print("(", i.tab, ",", i.data, ")")
}
+
+// hexdumpWords prints a word-oriented hex dump of [p, end).
+//
+// If mark != nil, it will be called with each printed word's address
+// and should return a character mark to appear just before that
+// word's value. It can return 0 to indicate no mark.
+func hexdumpWords(p, end uintptr, mark func(uintptr) byte) {
+ p1 := func(x uintptr) {
+ var buf [2 * sys.PtrSize]byte
+ for i := len(buf) - 1; i >= 0; i-- {
+ if x&0xF < 10 {
+ buf[i] = byte(x&0xF) + '0'
+ } else {
+ buf[i] = byte(x&0xF) - 10 + 'a'
+ }
+ x >>= 4
+ }
+ gwrite(buf[:])
+ }
+
+ printlock()
+ var markbuf [1]byte
+ markbuf[0] = ' '
+ for i := uintptr(0); p+i < end; i += sys.PtrSize {
+ if i%16 == 0 {
+ if i != 0 {
+ println()
+ }
+ p1(p + i)
+ print(": ")
+ }
+
+ if mark != nil {
+ markbuf[0] = mark(p + i)
+ if markbuf[0] == 0 {
+ markbuf[0] = ' '
+ }
+ }
+ gwrite(markbuf[:])
+ val := *(*uintptr)(unsafe.Pointer(p + i))
+ p1(val)
+ print(" ")
+
+ // Can we symbolize val?
+ name, _, _, _ := funcfileline(val, -1, false)
+ if name != "" {
+ entry := funcentry(val)
+ print("<", name, "+", val-entry, "> ")
+ }
+ }
+ println()
+ printunlock()
+}