Disable class unloading when tracing is active

Tracing keeps a lot of pointers to ArtMethods that could belong to
classes that we are going to unload. A quick fix for this is to
disable class unloading when tracing is active.

Bug: 24414774
Bug: 22720414
Change-Id: Ia5619cbd7c9fd558eaa2a5000871d287213c4a76
diff --git a/runtime/trace.cc b/runtime/trace.cc
index eb0ea68..745aa63 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -1058,4 +1058,9 @@
   return the_trace_->buffer_size_;
 }
 
+bool Trace::IsTracingEnabled() {
+  MutexLock mu(Thread::Current(), *Locks::trace_lock_);
+  return the_trace_ != nullptr;
+}
+
 }  // namespace art