aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime.c
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2008-06-16 17:04:30 -0700
committerRob Pike <r@golang.org>2008-06-16 17:04:30 -0700
commit88a3371a91ac01fb8bcc8083c0f32300514846c3 (patch)
tree9cea5906cb62a6ed29c246d386973ad2342895b1 /src/runtime/runtime.c
parentbb57a5bc2c167f82698654419376ce3a4825489f (diff)
downloadgo-88a3371a91ac01fb8bcc8083c0f32300514846c3.tar.xz
print pc on faults
SVN=123030
Diffstat (limited to 'src/runtime/runtime.c')
-rw-r--r--src/runtime/runtime.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c
index 724254a116..9a7efc55b7 100644
--- a/src/runtime/runtime.c
+++ b/src/runtime/runtime.c
@@ -71,15 +71,6 @@ sys_printpointer(void *p)
}
void
-sys_panicl(int32 lno)
-{
- prints("\npanic on line ");
- sys_printint(lno);
- prints("\n");
- *(int32*)0 = 0;
-}
-
-void
sys_printstring(string v)
{
sys_write(1, v->str, v->len);
@@ -101,6 +92,24 @@ prints(int8 *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)
{
uint32 v;
@@ -307,8 +316,11 @@ sys_slicestring(string si, int32 lindex, int32 hindex, string so)
int32 l;
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);
+ }
l = hindex-lindex;
so = mal(sizeof(so->len)+l);
@@ -320,8 +332,11 @@ sys_slicestring(string si, int32 lindex, int32 hindex, string so)
void
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);
+ }
b = s->str[i];
FLUSH(&b);