[lib/debugger_utils] Rename ExceptionToString to ExceptionNameAsString

A littler clearer for its intended use.

Tested: CQ
Change-Id: I7cc697f1d85da457ea05c20264a075e8294f6a8f
diff --git a/garnet/bin/debugserver/server.cc b/garnet/bin/debugserver/server.cc
index ade4b23..c4558a4 100644
--- a/garnet/bin/debugserver/server.cc
+++ b/garnet/bin/debugserver/server.cc
@@ -448,10 +448,10 @@
 
   if (ZX_EXCP_IS_ARCH(type)) {
     FXL_VLOG(1) << "Architectural Exception: "
-                << debugger_utils::ExceptionToString(type, context);
+                << debugger_utils::ExceptionNameAsString(type);
   } else {
     FXL_VLOG(1) << "Synthetic Exception: "
-                << debugger_utils::ExceptionToString(type, context);
+                << debugger_utils::ExceptionNameAsString(type);
   }
 
   // TODO(armansito): Fine-tune this check if we ever support multi-processing.
diff --git a/garnet/lib/debugger_utils/util.h b/garnet/lib/debugger_utils/util.h
index 699cc2b..8aa6d2f 100644
--- a/garnet/lib/debugger_utils/util.h
+++ b/garnet/lib/debugger_utils/util.h
@@ -104,11 +104,16 @@
 zx_koid_t GetRelatedKoid(const zx::object_base& object);
 
 // Return the name of exception |type| as a C string.
-const char* ExceptionName(zx_excp_type_t type);
+// Returns nullptr if |type| is invalid.
+// This does not take a |zx_excp_type_t| value because it also handles
+// invalid values.
+const char* ExceptionName(uint32_t type);
 
-// Return the string representation of an exception.
-std::string ExceptionToString(zx_excp_type_t type,
-                              const zx_exception_context_t& context);
+// Return the string form of the exception's name.
+// Returns "UNKNOWN(value)" for bad |type|.
+// This does not take a |zx_excp_type_t| value because it also handles
+// invalid values.
+std::string ExceptionNameAsString(uint32_t type);
 
 bool ReadString(const ByteBlock& m, zx_vaddr_t vaddr, char* ptr, size_t max);
 
diff --git a/garnet/lib/debugger_utils/util_zx.cc b/garnet/lib/debugger_utils/util_zx.cc
index e3c9d8f..7c78d72 100644
--- a/garnet/lib/debugger_utils/util_zx.cc
+++ b/garnet/lib/debugger_utils/util_zx.cc
@@ -51,7 +51,7 @@
   return fxl::StringPrintf("%s(%d)", zx_status_get_string(status), status);
 }
 
-const char* ExceptionName(zx_excp_type_t type) {
+const char* ExceptionName(uint32_t type) {
 #define CASE_TO_STR(x) \
   case x:              \
     return #x
@@ -66,16 +66,17 @@
     CASE_TO_STR(ZX_EXCP_THREAD_EXITING);
     CASE_TO_STR(ZX_EXCP_POLICY_ERROR);
     default:
-      return "UNKNOWN";
+      return nullptr;
   }
 #undef CASE_TO_STR
 }
 
-std::string ExceptionToString(zx_excp_type_t type,
-                              const zx_exception_context_t& context) {
-  std::string result(ExceptionName(type));
-  // TODO(dje): Add more info to the string.
-  return result;
+std::string ExceptionNameAsString(uint32_t type) {
+  const char* name = ExceptionName(type);
+  if (name) {
+    return std::string(name);
+  }
+  return fxl::StringPrintf("UNKNOWN(%u)", type);
 }
 
 bool ReadString(const ByteBlock& m, zx_vaddr_t vaddr, char* ptr, size_t max) {
diff --git a/garnet/lib/inferior_control/exception_port.cc b/garnet/lib/inferior_control/exception_port.cc
index cc1e069..7ca1c8e 100644
--- a/garnet/lib/inferior_control/exception_port.cc
+++ b/garnet/lib/inferior_control/exception_port.cc
@@ -285,7 +285,7 @@
   if (ZX_EXCP_IS_ARCH(type)) {
     fprintf(out, "Thread %s: received exception %s\n",
             thread->GetDebugName().c_str(),
-            debugger_utils::ExceptionToString(type, context).c_str());
+            debugger_utils::ExceptionNameAsString(type).c_str());
     zx_vaddr_t pc = thread->registers()->GetPC();
     fprintf(out, "PC 0x%" PRIxPTR "\n", pc);
   } else {