aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/runtime.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-03-30 10:53:16 -0700
committerRuss Cox <rsc@golang.org>2010-03-30 10:53:16 -0700
commit01eaf780a8d09ce0b41526fa2701cfbba80f2b8b (patch)
tree8b22d716f9984a7f88845cd2c746c175c911fbcf /src/pkg/runtime/runtime.c
parentc7122a3c5888df468a96edd0cb071801030794e6 (diff)
downloadgo-01eaf780a8d09ce0b41526fa2701cfbba80f2b8b.tar.xz
gc: add panic and recover (still unimplemented in runtime)
main semantic change is to enforce single argument to panic. runtime: change to 1-argument panic. use String method on argument if it has one. R=ken2, r CC=golang-dev https://golang.org/cl/812043
Diffstat (limited to 'src/pkg/runtime/runtime.c')
-rw-r--r--src/pkg/runtime/runtime.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c
index aa6d82506e..c6655d9ec0 100644
--- a/src/pkg/runtime/runtime.c
+++ b/src/pkg/runtime/runtime.c
@@ -20,7 +20,7 @@ gotraceback(void)
}
void
-·panicl(int32 lno)
+panic(int32 unused)
{
uint8 *sp;
@@ -31,10 +31,10 @@ void
}
panicking++;
- printf("\npanic PC=%X\n", (uint64)(uintptr)&lno);
- sp = (uint8*)&lno;
+ printf("\npanic PC=%X\n", (uint64)(uintptr)&unused);
+ sp = (uint8*)&unused;
if(gotraceback()){
- traceback(·getcallerpc(&lno), sp, g);
+ traceback(·getcallerpc(&unused), sp, g);
tracebackothers(g);
}
breakpoint(); // so we can grab it in a debugger
@@ -42,6 +42,15 @@ void
}
void
+·panic(Eface e)
+{
+ fd = 2;
+ printf("panic: ");
+ printany(e);
+ panic(0);
+}
+
+void
·throwindex(void)
{
throw("index out of range");
@@ -70,7 +79,7 @@ throw(int8 *s)
{
fd = 2;
printf("throw: %s\n", s);
- ·panicl(-1);
+ panic(-1);
*(int32*)0 = 0; // not reached
exit(1); // even more not reached
}