Commit af923df8 authored by Keith Randall's avatar Keith Randall

runtime: fix heapdump bugs.

Iterate the right number of times in arrays and channels.
Handle channels with zero-sized objects in them.
Output longer type names if we have them.
Compute argument offset correctly.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/82980043
parent a2a35147
......@@ -186,7 +186,14 @@ dumptype(Type *t)
dumpint(TagType);
dumpint((uintptr)t);
dumpint(t->size);
dumpstr(*t->string);
if(t->x == nil || t->x->pkgPath == nil || t->x->name == nil) {
dumpstr(*t->string);
} else {
dumpint(t->x->pkgPath->len + 1 + t->x->name->len);
write(t->x->pkgPath->str, t->x->pkgPath->len);
write((byte*)".", 1);
write(t->x->name->str, t->x->name->len);
}
dumpbool(t->size > PtrSize || (t->kind & KindNoPointers) == 0);
dumpfields((uintptr*)t->gc + 1);
}
......@@ -375,7 +382,7 @@ dumpframe(Stkframe *s, void *arg)
dumpint(FieldKindEol);
// Record arg info for parent.
child->argoff = s->argp - (byte*)s->sp;
child->argoff = s->argp - (byte*)s->fp;
child->arglen = s->arglen;
child->sp = (byte*)s->sp;
child->depth++;
......@@ -853,11 +860,13 @@ dumpefacetypes(void *obj, uintptr size, Type *type, uintptr kind)
playgcprog(0, (uintptr*)type->gc + 1, dumpeface_callback, obj);
break;
case TypeInfo_Array:
for(i = 0; i < size; i += type->size)
for(i = 0; i <= size - type->size; i += type->size)
playgcprog(i, (uintptr*)type->gc + 1, dumpeface_callback, obj);
break;
case TypeInfo_Chan:
for(i = runtime·Hchansize; i < size; i += type->size)
if(type->size == 0) // channels may have zero-sized objects in them
break;
for(i = runtime·Hchansize; i <= size - type->size; i += type->size)
playgcprog(i, (uintptr*)type->gc + 1, dumpeface_callback, obj);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment