From aed88be021762c590f50ab80f8cc155e2c55c39f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 4 Feb 2015 11:26:22 +0300 Subject: [PATCH] cmd/gc: restore stack frame debugging Dump frames of functions. Add function name and var width to output. Change-Id: Ida06b8def96178fa550ca90836eb4a2509b9e13f Reviewed-on: https://go-review.googlesource.com/3870 Reviewed-by: Russ Cox --- src/cmd/gc/pgen.c | 2 +- src/cmd/gc/subr.c | 29 ++++++++++++----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/cmd/gc/pgen.c b/src/cmd/gc/pgen.c index 0774e061e5b..1665094b73e 100644 --- a/src/cmd/gc/pgen.c +++ b/src/cmd/gc/pgen.c @@ -327,7 +327,7 @@ compile(Node *fn) defframe(ptxt); - if(0) + if(debug['f']) frame(0); // Remove leftover instrumentation from the instruction stream. diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c index fc925bbec32..486e1d8dc92 100644 --- a/src/cmd/gc/subr.c +++ b/src/cmd/gc/subr.c @@ -1703,36 +1703,31 @@ ptrto(Type *t) void frame(int context) { - char *p; NodeList *l; Node *n; - int flag; + vlong w; - p = "stack"; - l = nil; - if(curfn) - l = curfn->dcl; if(context) { - p = "external"; + print("--- external frame ---\n"); l = externdcl; - } + } else if(curfn) { + print("--- %S frame ---\n", curfn->nname->sym); + l = curfn->dcl; + } else + return; - flag = 1; for(; l; l=l->next) { n = l->n; + w = -1; + if(n->type) + w = n->type->width; switch(n->op) { case ONAME: - if(flag) - print("--- %s frame ---\n", p); - print("%O %S G%d %T\n", n->op, n->sym, n->vargen, n->type); - flag = 0; + print("%O %S G%d %T width=%lld\n", n->op, n->sym, n->vargen, n->type, w); break; case OTYPE: - if(flag) - print("--- %s frame ---\n", p); - print("%O %T\n", n->op, n->type); - flag = 0; + print("%O %T width=%lld\n", n->op, n->type, w); break; } }