diff mbox series

Go patch committed: Print runtime.hex in hex

Message ID CAOyqgcV+pQ6zpygufdgwOEpRA2QFEH6rU7pJ5RPu5+KdRYZBZg@mail.gmail.com
State New
Headers show
Series Go patch committed: Print runtime.hex in hex | expand

Commit Message

Ian Lance Taylor Aug. 16, 2019, 10:49 p.m. UTC
This is a patch to the Go frontend by Cherry Zhang.  The gc compiler
recognizes the type runtime.hex and prints values in this type as hex.
Do the same in the Go frontend. This makes debugging runtime crashes
slightly better.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
diff mbox series

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 274169)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-480477ca64c3001b9c7e92ef8b978dc92a5912d2
+0f6d673d5b1a3474c3424cb6994ae8ff9baed255
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===================================================================
--- gcc/go/gofrontend/expressions.cc	(revision 274169)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -10294,7 +10294,13 @@  Builtin_call_expression::do_get_backend(
 		  {
 		    Type* itype = Type::lookup_integer_type("uint64");
 		    arg = Expression::make_cast(itype, arg, location);
-                    code = Runtime::PRINTUINT;
+                    if (gogo->compiling_runtime()
+                        && type->named_type() != NULL
+                        && gogo->unpack_hidden_name(type->named_type()->name())
+                           == "hex")
+                      code = Runtime::PRINTHEX;
+                    else
+                      code = Runtime::PRINTUINT;
 		  }
 		else if (type->integer_type() != NULL)
 		  {
Index: gcc/go/gofrontend/runtime.def
===================================================================
--- gcc/go/gofrontend/runtime.def	(revision 274169)
+++ gcc/go/gofrontend/runtime.def	(working copy)
@@ -384,6 +384,9 @@  DEF_GO_RUNTIME(PRINTSTRING, "runtime.pri
 // Print a uint64 (for print/println).
 DEF_GO_RUNTIME(PRINTUINT, "runtime.printuint", P1(UINT64), R0())
 
+// Print a uint64 in hex (for print/println, used for runtime.hex type).
+DEF_GO_RUNTIME(PRINTHEX, "runtime.printhex", P1(UINT64), R0())
+
 // Print a int64 (for print/println).
 DEF_GO_RUNTIME(PRINTINT, "runtime.printint", P1(INT64), R0())