Remove the useless "suspend count already zero" message for new threads.

We can actually detect the expected case of this warning ourselves, and
not emit it. Then we can upgrade the WARNING to a FATAL.

I also tripped over the fact that the operator<< for Thread::State was out
of date, so I've moved the Thread enums up to namespace scope so the script
can automatically generate correct operator<< implementations for us. (All
the high-numbered thread states have been off by one for a couple of weeks.)

Change-Id: I5de573d33d641e5a3cba87b370e9620c8c66e633
diff --git a/src/debugger.cc b/src/debugger.cc
index 70f9c8e..fbcd420 100644
--- a/src/debugger.cc
+++ b/src/debugger.cc
@@ -418,7 +418,7 @@
   // If a debugger has already attached, send the "welcome" message.
   // This may cause us to suspend all threads.
   if (gJdwpState->IsActive()) {
-    //ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable);
+    //ScopedThreadStateChange tsc(Thread::Current(), kRunnable);
     if (!gJdwpState->PostVMStart()) {
       LOG(WARNING) << "Failed to post 'start' message to debugger";
     }
@@ -532,15 +532,15 @@
 }
 
 int Dbg::ThreadRunning() {
-  return static_cast<int>(Thread::Current()->SetState(Thread::kRunnable));
+  return static_cast<int>(Thread::Current()->SetState(kRunnable));
 }
 
 int Dbg::ThreadWaiting() {
-  return static_cast<int>(Thread::Current()->SetState(Thread::kVmWait));
+  return static_cast<int>(Thread::Current()->SetState(kVmWait));
 }
 
 int Dbg::ThreadContinuing(int new_state) {
-  return static_cast<int>(Thread::Current()->SetState(static_cast<Thread::State>(new_state)));
+  return static_cast<int>(Thread::Current()->SetState(static_cast<ThreadState>(new_state)));
 }
 
 void Dbg::UndoDebuggerSuspensions() {
@@ -1388,15 +1388,15 @@
   // TODO: if we're in Thread.sleep(long), we should return TS_SLEEPING,
   // even if it's implemented using Object.wait(long).
   switch (thread->GetState()) {
-    case Thread::kTerminated:   *pThreadStatus = JDWP::TS_ZOMBIE;   break;
-    case Thread::kRunnable:     *pThreadStatus = JDWP::TS_RUNNING;  break;
-    case Thread::kTimedWaiting: *pThreadStatus = JDWP::TS_WAIT;     break;
-    case Thread::kBlocked:      *pThreadStatus = JDWP::TS_MONITOR;  break;
-    case Thread::kWaiting:      *pThreadStatus = JDWP::TS_WAIT;     break;
-    case Thread::kStarting:     *pThreadStatus = JDWP::TS_ZOMBIE;   break;
-    case Thread::kNative:       *pThreadStatus = JDWP::TS_RUNNING;  break;
-    case Thread::kVmWait:       *pThreadStatus = JDWP::TS_WAIT;     break;
-    case Thread::kSuspended:    *pThreadStatus = JDWP::TS_RUNNING;  break;
+    case kTerminated:   *pThreadStatus = JDWP::TS_ZOMBIE;   break;
+    case kRunnable:     *pThreadStatus = JDWP::TS_RUNNING;  break;
+    case kTimedWaiting: *pThreadStatus = JDWP::TS_WAIT;     break;
+    case kBlocked:      *pThreadStatus = JDWP::TS_MONITOR;  break;
+    case kWaiting:      *pThreadStatus = JDWP::TS_WAIT;     break;
+    case kStarting:     *pThreadStatus = JDWP::TS_ZOMBIE;   break;
+    case kNative:       *pThreadStatus = JDWP::TS_RUNNING;  break;
+    case kVmWait:       *pThreadStatus = JDWP::TS_WAIT;     break;
+    case kSuspended:    *pThreadStatus = JDWP::TS_RUNNING;  break;
     // Don't add a 'default' here so the compiler can spot incompatible enum changes.
   }
 
@@ -1524,7 +1524,7 @@
 }
 
 void Dbg::SuspendVM() {
-  ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable); // TODO: do we really want to change back? should the JDWP thread be Runnable usually?
+  ScopedThreadStateChange tsc(Thread::Current(), kRunnable); // TODO: do we really want to change back? should the JDWP thread be Runnable usually?
   Runtime::Current()->GetThreadList()->SuspendAll(true);
 }
 
@@ -2173,7 +2173,7 @@
      * run out of memory.  It's also a good idea to change it before locking
      * the invokeReq mutex, although that should never be held for long.
      */
-    ScopedThreadStateChange tsc(Thread::Current(), Thread::kVmWait);
+    ScopedThreadStateChange tsc(Thread::Current(), kVmWait);
 
     VLOG(jdwp) << "    Transferring control to event thread";
     {
@@ -2232,7 +2232,7 @@
   SirtRef<Throwable> old_exception(self->GetException());
   self->ClearException();
 
-  ScopedThreadStateChange tsc(self, Thread::kRunnable);
+  ScopedThreadStateChange tsc(self, kRunnable);
 
   // Translate the method through the vtable, unless the debugger wants to suppress it.
   Method* m = pReq->method_;
@@ -2401,7 +2401,7 @@
   VLOG(jdwp) << "Broadcasting DDM " << (connect ? "connect" : "disconnect") << "...";
 
   Thread* self = Thread::Current();
-  if (self->GetState() != Thread::kRunnable) {
+  if (self->GetState() != kRunnable) {
     LOG(ERROR) << "DDM broadcast in thread state " << self->GetState();
     /* try anyway? */
   }