]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: Add some diagnostic messages printing source of unmarked object
authorRick Hudson <rlh@golang.org>
Tue, 13 Jan 2015 20:36:42 +0000 (15:36 -0500)
committerRick Hudson <rlh@golang.org>
Tue, 20 Jan 2015 19:58:22 +0000 (19:58 +0000)
Print out the object holding the reference to the object
that checkmark detects as not being properly marked.

Change-Id: Ieedbb6fddfaa65714504af9e7230bd9424cd0ae0
Reviewed-on: https://go-review.googlesource.com/2744
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/mgc.go

index 3972d0f2a3696f99a10ba16416ae3c514e37e4d1..32f13d1d4d61ecdefe967e145d4ad596d494cc82 100644 (file)
@@ -276,11 +276,31 @@ func greyobject(obj, base, off uintptr, hbits heapBits, wbuf *workbuf) *workbuf
                        print("runtime:greyobject: checkmarks finds unexpected unmarked object obj=", hex(obj), "\n")
                        print("runtime: found obj at *(", hex(base), "+", hex(off), ")\n")
 
+                       // Dump the source (base) object
+
+                       kb := base >> _PageShift
+                       xb := kb
+                       xb -= mheap_.arena_start >> _PageShift
+                       sb := h_spans[xb]
+                       printlock()
+                       print("runtime:greyobject Span: base=", hex(base), " kb=", hex(kb))
+                       if sb == nil {
+                               print(" sb=nil\n")
+                       } else {
+                               print(" sb.start*_PageSize=", hex(sb.start*_PageSize), " sb.limit=", hex(sb.limit), " sb.sizeclass=", sb.sizeclass, " sb.elemsize=", sb.elemsize, "\n")
+                               // base is (a pointer to) the source object holding the reference to object. Create a pointer to each of the fields
+                               // fields in base and print them out as hex values.
+                               for i := 0; i < int(sb.elemsize/ptrSize); i++ {
+                                       print(" *(base+", i*ptrSize, ") = ", hex(*(*uintptr)(unsafe.Pointer(base + uintptr(i)*ptrSize))), "\n")
+                               }
+                       }
+
+                       // Dump the object
+
                        k := obj >> _PageShift
                        x := k
                        x -= mheap_.arena_start >> _PageShift
                        s := h_spans[x]
-                       printlock()
                        print("runtime:greyobject Span: obj=", hex(obj), " k=", hex(k))
                        if s == nil {
                                print(" s=nil\n")