aboutsummaryrefslogtreecommitdiff
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
commit1dd0319be36ae0b00d14caeb13912c1cc2f13d1f (patch)
tree54d574e79b35b7a446ea0fd3b74a134738985f75
parente5e9211071d5a2437fd4f41f1fec77840d20da1f (diff)
downloadgo-1dd0319be36ae0b00d14caeb13912c1cc2f13d1f.tar.gz
go-1dd0319be36ae0b00d14caeb13912c1cc2f13d1f.zip
runtime: print unknown types in panic
R=r CC=golang-dev https://golang.org/cl/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 673e77b2c1..289d78f49f 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 aa207e3124..cf37886183 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);
+}
+