From 01eaf780a8d09ce0b41526fa2701cfbba80f2b8b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 30 Mar 2010 10:53:16 -0700 Subject: 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 --- src/pkg/runtime/runtime.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/pkg/runtime/runtime.c') 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,16 +31,25 @@ 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 exit(2); } +void +·panic(Eface e) +{ + fd = 2; + printf("panic: "); + printany(e); + panic(0); +} + void ·throwindex(void) { @@ -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 } -- cgit v1.3-5-g9baa