Add more systracing everywhere

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

(cherry picked from commit dabdc0fe183d4684f3cf4d70cb09d318cff81b42)

Change-Id: Ifaeff8913d79eefc797380987d13cc00456266f8
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index e5be2a4..1545cb7 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -20,6 +20,7 @@
 
 #include "art_method-inl.h"
 #include "base/stl_util.h"
+#include "base/systrace.h"
 #include "base/time_utils.h"
 #include "debugger_interface.h"
 #include "entrypoints/runtime_asm_entrypoints.h"
@@ -52,6 +53,7 @@
                                    size_t max_capacity,
                                    bool generate_debug_info,
                                    std::string* error_msg) {
+  ScopedTrace trace(__PRETTY_FUNCTION__);
   CHECK_GE(max_capacity, initial_capacity);
 
   // Generating debug information is mostly for using the 'perf' tool, which does
@@ -255,6 +257,7 @@
 }
 
 void JitCodeCache::RemoveMethodsIn(Thread* self, const LinearAlloc& alloc) {
+  ScopedTrace trace(__PRETTY_FUNCTION__);
   MutexLock mu(self, lock_);
   // We do not check if a code cache GC is in progress, as this method comes
   // with the classlinker_classes_lock_ held, and suspending ourselves could
@@ -452,6 +455,7 @@
       : code_cache_(code_cache), barrier_(barrier) {}
 
   void Run(Thread* thread) OVERRIDE SHARED_REQUIRES(Locks::mutator_lock_) {
+    ScopedTrace trace(__PRETTY_FUNCTION__);
     DCHECK(thread == Thread::Current() || thread->IsSuspended());
     MarkCodeVisitor visitor(thread, code_cache_);
     visitor.WalkStack();
@@ -552,6 +556,7 @@
 }
 
 void JitCodeCache::GarbageCollectCache(Thread* self) {
+  ScopedTrace trace(__FUNCTION__);
   if (!garbage_collect_code_) {
     MutexLock mu(self, lock_);
     IncreaseCodeCacheCapacity();
@@ -640,6 +645,7 @@
 }
 
 void JitCodeCache::RemoveUnmarkedCode(Thread* self) {
+  ScopedTrace trace(__FUNCTION__);
   MutexLock mu(self, lock_);
   ScopedCodeCacheWrite scc(code_map_.get());
   // Iterate over all compiled code and remove entries that are not marked.
@@ -661,6 +667,7 @@
 }
 
 void JitCodeCache::DoCollection(Thread* self, bool collect_profiling_info) {
+  ScopedTrace trace(__FUNCTION__);
   {
     MutexLock mu(self, lock_);
     if (collect_profiling_info) {
@@ -737,6 +744,7 @@
 }
 
 bool JitCodeCache::CheckLiveCompiledCodeHasProfilingInfo() {
+  ScopedTrace trace(__FUNCTION__);
   // Check that methods we have compiled do have a ProfilingInfo object. We would
   // have memory leaks of compiled code otherwise.
   for (const auto& it : method_code_map_) {
@@ -867,6 +875,7 @@
 
 void JitCodeCache::GetCompiledArtMethods(const std::set<std::string>& dex_base_locations,
                                          std::vector<ArtMethod*>& methods) {
+  ScopedTrace trace(__FUNCTION__);
   MutexLock mu(Thread::Current(), lock_);
   for (auto it : method_code_map_) {
     if (ContainsElement(dex_base_locations, it.second->GetDexFile()->GetBaseLocation())) {
diff --git a/runtime/jit/offline_profiling_info.cc b/runtime/jit/offline_profiling_info.cc
index 67c9b5f..ecf34f5 100644
--- a/runtime/jit/offline_profiling_info.cc
+++ b/runtime/jit/offline_profiling_info.cc
@@ -26,6 +26,7 @@
 #include "base/mutex.h"
 #include "base/scoped_flock.h"
 #include "base/stl_util.h"
+#include "base/systrace.h"
 #include "base/unix_file/fd_file.h"
 #include "jit/profiling_info.h"
 #include "os.h"
@@ -57,6 +58,7 @@
     return true;
   }
 
+  ScopedTrace trace(__PRETTY_FUNCTION__);
   ScopedFlock flock;
   std::string error;
   if (!flock.Init(filename.c_str(), O_RDWR | O_NOFOLLOW | O_CLOEXEC, /* block */ false, &error)) {
@@ -132,6 +134,7 @@
  *    app.apk:classes5.dex,218490184,39,13,49,1
  **/
 bool ProfileCompilationInfo::Save(int fd) {
+  ScopedTrace trace(__PRETTY_FUNCTION__);
   DCHECK_GE(fd, 0);
   // TODO(calin): Profile this and see how much memory it takes. If too much,
   // write to file directly.
@@ -298,6 +301,7 @@
 }
 
 bool ProfileCompilationInfo::Load(int fd) {
+  ScopedTrace trace(__PRETTY_FUNCTION__);
   DCHECK_GE(fd, 0);
 
   std::string current_line;
diff --git a/runtime/jit/profile_saver.cc b/runtime/jit/profile_saver.cc
index ab26f6f..bd58157 100644
--- a/runtime/jit/profile_saver.cc
+++ b/runtime/jit/profile_saver.cc
@@ -17,6 +17,7 @@
 #include "profile_saver.h"
 
 #include "art_method-inl.h"
+#include "base/systrace.h"
 #include "scoped_thread_state_change.h"
 #include "oat_file_manager.h"
 
@@ -93,6 +94,7 @@
 }
 
 bool ProfileSaver::ProcessProfilingInfo() {
+  ScopedTrace trace(__PRETTY_FUNCTION__);
   uint64_t last_update_time_ns = jit_code_cache_->GetLastUpdateTimeNs();
   if (!first_profile_ && last_update_time_ns - code_cache_last_update_time_ns_
           < kMinimumTimeBetweenCodeCacheUpdatesNs) {