JDWP: do not report start/end events for thread without peer

To report start/end thread events, we need the JDWP id of the thread.
To create a JDWP id, we need its java.lang.Thread peer. In the case
there is no Java peer, we can't report the event.

Follow-up https://android-review.googlesource.com/118548 where the
runtime attaches the current thread without Java peer when shutting
down.

Change-Id: Icc2d50f3d2eedd1e0e3c5a21affd2261aaf7a862
diff --git a/runtime/jdwp/jdwp_event.cc b/runtime/jdwp/jdwp_event.cc
index 1bf16b2..cb28ff0 100644
--- a/runtime/jdwp/jdwp_event.cc
+++ b/runtime/jdwp/jdwp_event.cc
@@ -1015,6 +1015,14 @@
     return;
   }
 
+  // We need the java.lang.Thread object associated to the starting/ending
+  // thread to get its JDWP id. Therefore we can't report event if there
+  // is no Java peer. This happens when the runtime shuts down and re-attaches
+  // the current thread without creating a Java peer.
+  if (thread->GetPeer() == nullptr) {
+    return;
+  }
+
   ModBasket basket;
   basket.thread = thread;