harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r429325 - /incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp
Date Mon, 07 Aug 2006 13:01:42 GMT
Author: geirm
Date: Mon Aug  7 06:01:41 2006
New Revision: 429325

URL: http://svn.apache.org/viewvc?rev=429325&view=rev
Log: (empty)

Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp?rev=429325&r1=429324&r2=429325&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp Mon Aug  7
06:01:41 2006
@@ -320,9 +320,13 @@
        return res;
     }
 
-    jvmtiStackInfo *info = (jvmtiStackInfo*)
-        STD_MALLOC(sizeof(jvmtiStackInfo) * count
-                + sizeof(jvmtiFrameInfo) * max_frame_count * count);
+    jvmtiStackInfo *info;
+    res = _allocate(sizeof(jvmtiStackInfo) * count +
+        sizeof(jvmtiFrameInfo) * max_frame_count * count,
+        (unsigned char **)&info);
+
+    if (JVMTI_ERROR_NONE != res)
+        return res;
 
     jthread currentThread = getCurrentThread();
     int i;
@@ -334,6 +338,9 @@
         info[i].thread = threads[i];
         res = jvmtiGetThreadState(env, threads[i], &info[i].state);
 
+        if (JVMTI_ERROR_NONE != res)
+            return res;
+
         // FIXME: suspended thread might be resumed in other jvmti thread?
         if (info[i].state != JVMTI_THREAD_STATE_SUSPENDED) {
             if (IsSameObject(jvmti_test_jenv, currentThread, threads[i]))
@@ -344,9 +351,15 @@
 
     // geting thread states
     for(i = 0; i < count; i++) {
-        info[i].frame_buffer = ((jvmtiFrameInfo*)(info + 1)) + i;
-        jvmtiGetStackTrace(env, info[i].thread, 0, max_frame_count,
+        // Frame_buffer pointer should pointer to the memory right
+        // after the jvmtiStackInfo structures
+        info[i].frame_buffer = ((jvmtiFrameInfo *)&info[count]) +
+            max_frame_count * i;
+        res = jvmtiGetStackTrace(env, info[i].thread, 0, max_frame_count,
             info[i].frame_buffer, &info[i].frame_count);
+
+        if (JVMTI_ERROR_NONE != res)
+            return res;
     }
 
     // unsuspend suspended threads.
@@ -383,6 +396,7 @@
     SuspendEnabledChecker sec;
     jint count = thread_count;
     const jthread *threads = thread_list;
+    jvmtiError res;
 
     /*
      * Check given env & current phase.
@@ -403,12 +417,12 @@
     if (max_frame_count < 0)
         return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 
-    jvmtiStackInfo *info = (jvmtiStackInfo*)
-        STD_MALLOC(sizeof(jvmtiStackInfo) * count
-                + sizeof(jvmtiFrameInfo) * max_frame_count * count);
+    jvmtiStackInfo *info;
+    res = _allocate(sizeof(jvmtiStackInfo) * count +
+        sizeof(jvmtiFrameInfo) * max_frame_count * count,
+        (unsigned char **)&info);
 
     int i;
-
     jthread currentThread = getCurrentThread();
     // stoping all threads
     for(i = 0; i < count; i++) {
@@ -416,7 +430,10 @@
         // event handler for thread death should block thread death
         // until the function end.
         info[i].thread = threads[i];
-        env->GetThreadState(threads[i], &info[i].state);
+        res = jvmtiGetThreadState(env, threads[i], &info[i].state);
+
+        if (JVMTI_ERROR_NONE != res)
+            return res;
 
         // FIXME: suspended thread might be resumed in other jvmti thread?
         if (info[i].state != JVMTI_THREAD_STATE_SUSPENDED) {
@@ -428,9 +445,15 @@
 
     // geting thread states
     for(i = 0; i < count; i++) {
-        info[i].frame_buffer = ((jvmtiFrameInfo*)(info + 1)) + i;
-        env->GetStackTrace(info[i].thread, 0, max_frame_count,
+        // Frame_buffer pointer should pointer to the memory right
+        // after the jvmtiStackInfo structures
+        info[i].frame_buffer = ((jvmtiFrameInfo *)&info[count]) +
+            max_frame_count * i;
+        res = jvmtiGetStackTrace(env, info[i].thread, 0, max_frame_count,
                 info[i].frame_buffer, &info[i].frame_count);
+
+        if (JVMTI_ERROR_NONE != res)
+            return res;
     }
 
     // unsuspend suspended threads.



Mime
View raw message