summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-10-22 17:04:32 -0400
committerRuss Cox <rsc@golang.org>2010-10-22 17:04:32 -0400
commitb3bbc7b4653729bdccb43fc54162931b0641b0b8 (patch)
treed6ba62436bfe2baadb0b838d52f7e819ed3de7f9
parent92d7435c3ffce030510678b6c0b86939ae191144 (diff)
downloadgo-b3bbc7b4653729bdccb43fc54162931b0641b0b8.tar.gz
runtime: print unknown types in panic
R=r CC=golang-dev http://codereview.appspot.com/2683041
-rw-r--r--src/pkg/runtime/error.go4
-rw-r--r--src/pkg/runtime/print.c8
2 files changed, 11 insertions, 1 deletions
diff --git a/src/pkg/runtime/error.go b/src/pkg/runtime/error.go
index 673e77b2c..289d78f49 100644
--- a/src/pkg/runtime/error.go
+++ b/src/pkg/runtime/error.go
@@ -111,6 +111,8 @@ type stringer interface {
String() string
}
+func typestring(interface{}) string
+
// For calling from C.
// Prints an argument passed to panic.
// There's room for arbitrary complexity here, but we keep it
@@ -126,6 +128,6 @@ func printany(i interface{}) {
case string:
print(v)
default:
- print(i)
+ print("(", typestring(i), ") ", i)
}
}
diff --git a/src/pkg/runtime/print.c b/src/pkg/runtime/print.c
index aa207e312..cf3788618 100644
--- a/src/pkg/runtime/print.c
+++ b/src/pkg/runtime/print.c
@@ -348,3 +348,11 @@ void
{
write(fd, "\n", 1);
}
+
+void
+·typestring(Eface e, String s)
+{
+ s = *e.type->string;
+ FLUSH(&s);
+}
+