1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:04:41 -07:00

[68]l: fix off by one instruction in dwarf frame unwinding.

R=rsc
CC=golang-dev
https://golang.org/cl/2543043
This commit is contained in:
Luuk van Dijk 2010-10-17 21:13:55 +02:00
parent 8abb8e1d20
commit cc9e6b5cdb

View File

@ -747,10 +747,11 @@ writelines(void)
diag("reachable code before seeing any history: %P", p); diag("reachable code before seeing any history: %P", p);
continue; continue;
} }
dwinfo->child = newdie(dwinfo->child, DW_ABRV_FUNCTION); dwinfo->child = newdie(dwinfo->child, DW_ABRV_FUNCTION);
newattr(dwinfo->child, DW_AT_name, DW_CLS_STRING, strlen(s->name), s->name); newattr(dwinfo->child, DW_AT_name, DW_CLS_STRING, strlen(s->name), s->name);
newattr(dwinfo->child, DW_AT_low_pc, DW_CLS_ADDRESS, p->pc, 0); newattr(dwinfo->child, DW_AT_low_pc, DW_CLS_ADDRESS, s->text->pc, 0);
newattr(dwinfo->child, DW_AT_high_pc, DW_CLS_ADDRESS, s->text->pc + s->size, 0);
for(q = p; q != P && (q == p || q->as != ATEXT); q = q->link) { for(q = p; q != P && (q == p || q->as != ATEXT); q = q->link) {
epc = q->pc; epc = q->pc;
@ -780,9 +781,6 @@ writelines(void)
lc = q->line; lc = q->line;
llc = lline; llc = lline;
} }
newattr(dwinfo->child, DW_AT_high_pc, DW_CLS_ADDRESS, epc+1, 0);
} }
flushunit(epc, unitstart); flushunit(epc, unitstart);
@ -795,8 +793,8 @@ writelines(void)
enum enum
{ {
CIERESERVE = 16, CIERESERVE = 16,
DATAALIGNMENTFACTOR = -4, DATAALIGNMENTFACTOR = -4, // TODO -PtrSize?
FAKERETURNCOLUMN = 16 FAKERETURNCOLUMN = 16 // TODO gdb6 doesnt like > 15?
}; };
static void static void
@ -824,7 +822,7 @@ writeframes(void)
{ {
Prog *p, *q; Prog *p, *q;
Sym *s; Sym *s;
vlong fdeo, fdesize, pad, cfa, pc, epc; vlong fdeo, fdesize, pad, cfa, pc;
frameo = cpos(); frameo = cpos();
@ -867,16 +865,14 @@ writeframes(void)
cfa = PtrSize; // CFA starts at sp+PtrSize cfa = PtrSize; // CFA starts at sp+PtrSize
p = s->text; p = s->text;
pc = p->pc; pc = p->pc;
epc = p->pc;
for(q = p; q != P; q = q->link) { for(q = p; q->link != P; q = q->link) {
epc = q->pc;
if (q->spadj == 0) if (q->spadj == 0)
continue; continue;
cfa += q->spadj; cfa += q->spadj;
putpccfadelta(q->pc - pc, cfa); putpccfadelta(q->link->pc - pc, cfa);
pc = q->pc; pc = q->link->pc;
} }
fdesize = cpos() - fdeo - 4; // exclude the length field. fdesize = cpos() - fdeo - 4; // exclude the length field.
@ -890,7 +886,7 @@ writeframes(void)
LPUT(fdesize); LPUT(fdesize);
LPUT(0); LPUT(0);
addrput(p->pc); addrput(p->pc);
addrput(epc - p->pc); addrput(s->size);
cflush(); cflush();
seek(cout, fdeo + 4 + fdesize, 0); seek(cout, fdeo + 4 + fdesize, 0);