OSDN Git Service

merge in klp-release history after reset to klp-dev
[android-x86/dalvik.git] / vm / Ddm.cpp
index 4bb2bb1..d441ec4 100644 (file)
@@ -61,7 +61,7 @@ bool dvmDdmHandlePacket(const u1* buf, int dataLen, u1** pReplyBuf,
      */
     dataArray = dvmAllocPrimitiveArray('B', dataLen, ALLOC_DEFAULT);
     if (dataArray == NULL) {
-        LOGW("array alloc failed (%d)\n", dataLen);
+        ALOGW("array alloc failed (%d)", dataLen);
         dvmClearException(self);
         goto bail;
     }
@@ -75,7 +75,7 @@ bool dvmDdmHandlePacket(const u1* buf, int dataLen, u1** pReplyBuf,
     length = get4BE((u1*)dataArray->contents + 4);
     offset = kChunkHdrLen;
     if (offset+length > (unsigned int) dataLen) {
-        LOGW("WARNING: bad chunk found (len=%u pktLen=%d)\n", length, dataLen);
+        ALOGW("WARNING: bad chunk found (len=%u pktLen=%d)", length, dataLen);
         goto bail;
     }
 
@@ -86,7 +86,7 @@ bool dvmDdmHandlePacket(const u1* buf, int dataLen, u1** pReplyBuf,
     dvmCallMethod(self, gDvm.methDalvikDdmcServer_dispatch, NULL, &callRes,
         type, dataArray, offset, length);
     if (dvmCheckException(self)) {
-        LOGI("Exception thrown by dispatcher for 0x%08x\n", type);
+        ALOGI("Exception thrown by dispatcher for 0x%08x", type);
         dvmLogExceptionStackTrace();
         dvmClearException(self);
         goto bail;
@@ -118,13 +118,13 @@ bool dvmDdmHandlePacket(const u1* buf, int dataLen, u1** pReplyBuf,
     offset = dvmGetFieldInt(chunk, gDvm.offDalvikDdmcChunk_offset);
     length = dvmGetFieldInt(chunk, gDvm.offDalvikDdmcChunk_length);
 
-    LOGV("DDM reply: type=0x%08x data=%p offset=%d length=%d\n",
+    ALOGV("DDM reply: type=0x%08x data=%p offset=%d length=%d",
         type, replyData, offset, length);
 
     if (length == 0 || replyData == NULL)
         goto bail;
     if (offset + length > replyData->length) {
-        LOGW("WARNING: chunk off=%d len=%d exceeds reply array len %d\n",
+        ALOGW("WARNING: chunk off=%d len=%d exceeds reply array len %d",
             offset, length, replyData->length);
         goto bail;
     }
@@ -132,7 +132,7 @@ bool dvmDdmHandlePacket(const u1* buf, int dataLen, u1** pReplyBuf,
     u1* reply;
     reply = (u1*) malloc(length + kChunkHdrLen);
     if (reply == NULL) {
-        LOGW("malloc %d failed\n", length+kChunkHdrLen);
+        ALOGW("malloc %d failed", length+kChunkHdrLen);
         goto bail;
     }
     set4BE(reply + 0, type);
@@ -143,7 +143,7 @@ bool dvmDdmHandlePacket(const u1* buf, int dataLen, u1** pReplyBuf,
     *pReplyLen = length + kChunkHdrLen;
     result = true;
 
-    LOGV("dvmHandleDdm returning type=%.4s buf=%p len=%d\n",
+    ALOGV("dvmHandleDdm returning type=%.4s buf=%p len=%d",
         (char*) reply, reply, length);
 
 bail:
@@ -164,7 +164,7 @@ static void broadcast(int event)
     Thread* self = dvmThreadSelf();
 
     if (self->status != THREAD_RUNNING) {
-        LOGE("ERROR: DDM broadcast with thread status=%d\n", self->status);
+        ALOGE("ERROR: DDM broadcast with thread status=%d", self->status);
         /* try anyway? */
     }
 
@@ -180,7 +180,7 @@ static void broadcast(int event)
     dvmCallMethod(self, gDvm.methDalvikDdmcServer_broadcast, NULL, &unused,
         event);
     if (dvmCheckException(self)) {
-        LOGI("Exception thrown by broadcast(%d)\n", event);
+        ALOGI("Exception thrown by broadcast(%d)", event);
         dvmLogExceptionStackTrace();
         dvmClearException(self);
         return;
@@ -196,7 +196,7 @@ void dvmDdmConnected()
 {
     // TODO: any init
 
-    LOGV("Broadcasting DDM connect\n");
+    ALOGV("Broadcasting DDM connect");
     broadcast(CONNECTED);
 }
 
@@ -207,7 +207,7 @@ void dvmDdmConnected()
  */
 void dvmDdmDisconnected()
 {
-    LOGV("Broadcasting DDM disconnect\n");
+    ALOGV("Broadcasting DDM disconnect");
     broadcast(DISCONNECTED);
 
     gDvm.ddmThreadNotification = false;
@@ -230,7 +230,7 @@ void dvmDdmSetThreadNotification(bool enable)
     if (enable) {
         Thread* thread;
         for (thread = gDvm.threadList; thread != NULL; thread = thread->next) {
-            //LOGW("notify %d\n", thread->threadId);
+            //ALOGW("notify %d", thread->threadId);
             dvmDdmSendThreadNotification(thread, true);
         }
     }
@@ -246,8 +246,9 @@ void dvmDdmSetThreadNotification(bool enable)
  */
 void dvmDdmSendThreadNotification(Thread* thread, bool started)
 {
-    if (!gDvm.ddmThreadNotification)
+    if (!gDvm.ddmThreadNotification) {
         return;
+    }
 
     StringObject* nameObj = NULL;
     Object* threadObj = thread->threadObj;
@@ -268,16 +269,17 @@ void dvmDdmSendThreadNotification(Thread* thread, bool started)
         type = CHUNK_TYPE("THCR");
 
         if (nameObj != NULL) {
-            stringLen = dvmStringLen(nameObj);
-            chars = dvmStringChars(nameObj);
+            stringLen = nameObj->length();
+            chars = nameObj->chars();
         } else {
             stringLen = 0;
             chars = NULL;
         }
 
         /* leave room for the two integer fields */
-        if (stringLen > (sizeof(buf) - sizeof(u4)*2) / 2)
+        if (stringLen > (sizeof(buf) - sizeof(u4)*2) / 2) {
             stringLen = (sizeof(buf) - sizeof(u4)*2) / 2;
+        }
         len = stringLen*2 + sizeof(u4)*2;
 
         set4BE(&buf[0x00], thread->threadId);
@@ -285,8 +287,9 @@ void dvmDdmSendThreadNotification(Thread* thread, bool started)
 
         /* copy the UTF-16 string, transforming to big-endian */
         outChars = (u2*)(void*)&buf[0x08];
-        while (stringLen--)
+        while (stringLen--) {
             set2BE((u1*) (outChars++), *chars++);
+        }
     } else {
         type = CHUNK_TYPE("THDE");
 
@@ -303,11 +306,12 @@ void dvmDdmSendThreadNotification(Thread* thread, bool started)
  */
 void dvmDdmSendThreadNameChange(int threadId, StringObject* newName)
 {
-    if (!gDvm.ddmThreadNotification)
+    if (!gDvm.ddmThreadNotification) {
         return;
+    }
 
-    size_t stringLen = dvmStringLen(newName);
-    const u2* chars = dvmStringChars(newName);
+    size_t stringLen = newName->length();
+    const u2* chars = newName->chars();
 
     /*
      * Output format:
@@ -321,8 +325,9 @@ void dvmDdmSendThreadNameChange(int threadId, StringObject* newName)
     set4BE(&buf[0x00], threadId);
     set4BE(&buf[0x04], stringLen);
     u2* outChars = (u2*)(void*)&buf[0x08];
-    while (stringLen--)
+    while (stringLen--) {
         set2BE((u1*) (outChars++), *chars++);
+    }
 
     dvmDbgDdmSendChunk(CHUNK_TYPE("THNM"), bufLen, buf);
 }
@@ -431,7 +436,7 @@ ArrayObject* dvmDdmGetStackTraceById(u4 threadId)
             break;
     }
     if (thread == NULL) {
-        LOGI("dvmDdmGetStackTraceById: threadid=%d not found\n", threadId);
+        ALOGI("dvmDdmGetStackTraceById: threadid=%d not found", threadId);
         dvmUnlockThreadList();
         return NULL;
     }