OSDN Git Service

Reduce logging.
authorAndy McFadden <fadden@android.com>
Tue, 17 Nov 2009 21:13:34 +0000 (13:13 -0800)
committerAndy McFadden <fadden@android.com>
Tue, 17 Nov 2009 21:13:34 +0000 (13:13 -0800)
This cuts out some unnecessarily verbose dalvikvm chatter, notably:

  Trying to load lib /system/lib/librs_jni.so 0x0
  Added shared lib /system/lib/librs_jni.so 0x0

These messages can be useful for people trying to get their apps to
work with the NDK, so I'm only suppressing them when the path starts
with "/system".  The result is that you can boot the system and run all
standard apps without seeing them, but we'll still see app-private libs
being loaded.

Also LOGI->LOGV for "Debugger thread not active, ignoring DDM send",
which seemed to be firing on startup for APp NaMe events.  Ditto for
"Splitting out new zygote heap", which only happens once, but doesn't
strike me as a particularly useful thing to log.

vm/Debugger.c
vm/Native.c
vm/alloc/HeapSource.c

index 4ddf25c..0d8f3f6 100644 (file)
@@ -2949,7 +2949,7 @@ void dvmDbgDdmDisconnected(void)
 void dvmDbgDdmSendChunk(int type, int len, const u1* buf)
 {
     if (gDvm.jdwpState == NULL) {
-        LOGI("Debugger thread not active, ignoring DDM send (t=0x%08x l=%d)\n",
+        LOGV("Debugger thread not active, ignoring DDM send (t=0x%08x l=%d)\n",
             type, len);
         return;
     }
index 31832c2..967482c 100644 (file)
@@ -444,8 +444,13 @@ bool dvmLoadNativeCode(const char* pathName, Object* classLoader)
 {
     SharedLib* pEntry;
     void* handle;
+    bool verbose;
 
-    LOGD("Trying to load lib %s %p\n", pathName, classLoader);
+    /* reduce noise by not chattering about system libraries */
+    verbose = strncmp(pathName, "/system", sizeof("/system")-1) != 0;
+
+    if (verbose)
+        LOGD("Trying to load lib %s %p\n", pathName, classLoader);
 
     /*
      * See if we've already loaded it.  If we have, and the class loader
@@ -458,8 +463,10 @@ bool dvmLoadNativeCode(const char* pathName, Object* classLoader)
                 pathName, pEntry->classLoader, classLoader);
             return false;
         }
-        LOGD("Shared lib '%s' already loaded in same CL %p\n",
-            pathName, classLoader);
+        if (verbose) {
+            LOGD("Shared lib '%s' already loaded in same CL %p\n",
+                pathName, classLoader);
+        }
         if (!checkOnLoadResult(pEntry))
             return false;
         return true;
@@ -473,11 +480,9 @@ bool dvmLoadNativeCode(const char* pathName, Object* classLoader)
      * Failures here are expected when java.library.path has several entries
      * and we have to hunt for the lib.
      *
-     * The current android-arm dynamic linker implementation tends to
-     * return "Cannot find library" from dlerror() regardless of the actual
-     * problem.  A more useful diagnostic may be sent to stdout/stderr if
-     * linker diagnostics are enabled, but that's not usually visible in
-     * Android apps.  Some things to try:
+     * The current version of the dynamic linker prints detailed information
+     * about dlopen() failures.  Some things to check if the message is
+     * cryptic:
      *   - make sure the library exists on the device
      *   - verify that the right path is being opened (the debug log message
      *     above can help with that)
@@ -523,7 +528,8 @@ bool dvmLoadNativeCode(const char* pathName, Object* classLoader)
         freeSharedLibEntry(pNewEntry);
         return checkOnLoadResult(pActualEntry);
     } else {
-        LOGD("Added shared lib %s %p\n", pathName, classLoader);
+        if (verbose)
+            LOGD("Added shared lib %s %p\n", pathName, classLoader);
 
         bool result = true;
         void* vonLoad;
@@ -531,7 +537,8 @@ bool dvmLoadNativeCode(const char* pathName, Object* classLoader)
 
         vonLoad = dlsym(handle, "JNI_OnLoad");
         if (vonLoad == NULL) {
-            LOGD("No JNI_OnLoad found in %s %p\n", pathName, classLoader);
+            LOGD("No JNI_OnLoad found in %s %p, skipping init\n",
+                pathName, classLoader);
         } else {
             /*
              * Call JNI_OnLoad.  We have to override the current class
@@ -746,7 +753,7 @@ static int findMethodInLib(void* vlib, void* vmethod)
     int len;
 
     if (meth->clazz->classLoader != pLib->classLoader) {
-        LOGD("+++ not scanning '%s' for '%s' (wrong CL)\n",
+        LOGV("+++ not scanning '%s' for '%s' (wrong CL)\n",
             pLib->pathName, meth->name);
         return 0;
     } else
index 830e5d7..6e3036b 100644 (file)
@@ -498,7 +498,7 @@ dvmHeapSourceStartupBeforeFork()
         /* Create a new heap for post-fork zygote allocations.  We only
          * try once, even if it fails.
          */
-        LOGI("Splitting out new zygote heap\n");
+        LOGV("Splitting out new zygote heap\n");
         gDvm.newZygoteHeapAllocated = true;
         return addNewHeap(hs, NULL, 0);
     }