1
0
mirror of https://github.com/golang/go synced 2024-11-20 07:24:40 -07:00

fixed bug that cause -g to segfault

R=rsc
APPROVED=rsc
DELTA=48  (30 added, 16 deleted, 2 changed)
OCL=31152
CL=31187
This commit is contained in:
Kai Backman 2009-07-06 06:36:25 -07:00
parent c1edbe9a10
commit a7735f8a16

View File

@ -30,6 +30,8 @@
#include "gg.h" #include "gg.h"
// TODO(kaib): make 5g/list.c congruent with 5l/list.c
static int sconsize; static int sconsize;
void void
listinit(void) listinit(void)
@ -40,6 +42,7 @@ listinit(void)
fmtinstall('D', Dconv); // Addr* fmtinstall('D', Dconv); // Addr*
fmtinstall('Y', Yconv); // sconst fmtinstall('Y', Yconv); // sconst
fmtinstall('R', Rconv); // register fmtinstall('R', Rconv); // register
fmtinstall('M', Mconv); // names
} }
int int
@ -97,27 +100,11 @@ Dconv(Fmt *fp)
snprint(str, sizeof(str), "%d", a->branch->loc); snprint(str, sizeof(str), "%d", a->branch->loc);
break; break;
case D_EXTERN:
snprint(str, sizeof(str), "%S+%d(SB)", a->sym, a->offset);
break;
case D_STATIC:
snprint(str, sizeof(str), "%S<>+%d(SB)", a->sym, a->offset);
break;
case D_AUTO:
snprint(str, sizeof(str), "%S+%d(SP)", a->sym, a->offset);
break;
case D_PARAM:
snprint(str, sizeof(str), "%S+%d(FP)", a->sym, a->offset);
break;
case D_CONST: case D_CONST:
if(a->reg != NREG) if(a->reg != NREG)
sprint(str, "$%N(R%d)", a, a->reg); sprint(str, "$%M(R%d)", a, a->reg);
else else
sprint(str, "$%N", a); sprint(str, "$%M", a);
break; break;
case D_CONST2: case D_CONST2:
@ -210,3 +197,30 @@ Rconv(Fmt *fp)
snprint(str, sizeof(str), "R%d", r); snprint(str, sizeof(str), "R%d", r);
return fmtstrcpy(fp, str); return fmtstrcpy(fp, str);
} }
int
Mconv(Fmt *fp)
{
char str[STRINGSZ];
Addr *a;
a = va_arg(fp->args, Addr*);
switch(a->name) {
case D_EXTERN:
snprint(str, sizeof(str), "%S+%d(SB)", a->sym, a->offset);
break;
case D_STATIC:
snprint(str, sizeof(str), "%S<>+%d(SB)", a->sym, a->offset);
break;
case D_AUTO:
snprint(str, sizeof(str), "%S+%d(SP)", a->sym, a->offset);
break;
case D_PARAM:
snprint(str, sizeof(str), "%S+%d(FP)", a->sym, a->offset);
break;
}
return fmtstrcpy(fp, str);
}