Commit 88a3371a authored by Rob Pike's avatar Rob Pike

print pc on faults

SVN=123030
parent bb57a5bc
...@@ -84,3 +84,8 @@ TEXT sys_memclr(SB),1,$-8 ...@@ -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
...@@ -94,3 +94,8 @@ TEXT sys_memclr(SB),1,$-8 ...@@ -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
...@@ -70,15 +70,6 @@ sys_printpointer(void *p) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
......
...@@ -91,6 +91,7 @@ void sys_write(int32, void*, int32); ...@@ -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
......
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