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

print pc on faults

SVN=123030
This commit is contained in:
Rob Pike 2008-06-16 17:04:30 -07:00
parent bb57a5bc2c
commit 88a3371a91
4 changed files with 37 additions and 11 deletions

View File

@ -84,3 +84,8 @@ TEXT sys_memclr(SB),1,$-8
REP REP
STOSQ STOSQ
RET RET
TEXT sys_getcallerpc+0(SB),0,$0
MOVQ x+0(FP),AX
MOVQ -8(AX),AX
RET

View File

@ -94,3 +94,8 @@ TEXT sys_memclr(SB),1,$-8
REP REP
STOSQ STOSQ
RET RET
TEXT sys_getcallerpc+0(SB),0,$0
MOVQ x+0(FP),AX
MOVQ -8(AX),AX
RET

View File

@ -70,15 +70,6 @@ sys_printpointer(void *p)
sys_write(1, buf+i, nelem(buf)-i); sys_write(1, buf+i, nelem(buf)-i);
} }
void
sys_panicl(int32 lno)
{
prints("\npanic on line ");
sys_printint(lno);
prints("\n");
*(int32*)0 = 0;
}
void void
sys_printstring(string v) sys_printstring(string v)
{ {
@ -101,6 +92,24 @@ prints(int8 *s)
sys_write(1, s, strlen(s)); sys_write(1, s, strlen(s));
} }
void
sys_printpc(void *p)
{
prints("PC=0x");
sys_printpointer(sys_getcallerpc(p));
}
void
sys_panicl(int32 lno)
{
prints("\npanic on line ");
sys_printint(lno);
prints(" ");
sys_printpc(&lno);
prints("\n");
*(int32*)0 = 0;
}
dump(byte *p, int32 n) dump(byte *p, int32 n)
{ {
uint32 v; uint32 v;
@ -307,8 +316,11 @@ sys_slicestring(string si, int32 lindex, int32 hindex, string so)
int32 l; int32 l;
if(lindex < 0 || lindex > si->len || if(lindex < 0 || lindex > si->len ||
hindex < lindex || hindex > si->len) hindex < lindex || hindex > si->len) {
sys_printpc(&si);
prints(" ");
prbounds("slice", lindex, si->len, hindex); prbounds("slice", lindex, si->len, hindex);
}
l = hindex-lindex; l = hindex-lindex;
so = mal(sizeof(so->len)+l); so = mal(sizeof(so->len)+l);
@ -320,8 +332,11 @@ sys_slicestring(string si, int32 lindex, int32 hindex, string so)
void void
sys_indexstring(string s, int32 i, byte b) sys_indexstring(string s, int32 i, byte b)
{ {
if(i < 0 || i >= s->len) if(i < 0 || i >= s->len) {
sys_printpc(&s);
prints(" ");
prbounds("index", 0, i, s->len); prbounds("index", 0, i, s->len);
}
b = s->str[i]; b = s->str[i];
FLUSH(&b); FLUSH(&b);

View File

@ -91,6 +91,7 @@ void sys_write(int32, void*, int32);
void sys_breakpoint(void); void sys_breakpoint(void);
uint8* sys_mmap(byte*, uint32, int32, int32, int32, uint32); uint8* sys_mmap(byte*, uint32, int32, int32, int32, uint32);
void sys_memclr(byte*, uint32); void sys_memclr(byte*, uint32);
void* sys_getcallerpc(void*);
/* /*
* runtime * runtime