harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r597138 [7/15] - in /harmony/enhanced/drlvm/trunk: build/make/ build/make/components/vm/ vm/include/ vm/include/open/ vm/jitrino/src/codegenerator/ia32/ vm/port/src/encoder/ia32_em64t/ vm/port/src/lil/ia32/pim/ vm/tests/ncai/ vm/tests/ncai/...
Date Wed, 21 Nov 2007 16:29:54 GMT
Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01/GetThreadInfo01.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01/GetThreadInfo01.cpp?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01/GetThreadInfo01.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01/GetThreadInfo01.cpp Wed Nov 21 08:29:40 2007
@@ -0,0 +1,270 @@
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+
+/* *********************************************************************** */
+
+#include "events.h"
+#include "utils.h"
+#include "ncai.h"
+
+#ifdef POSIX
+#include <stdlib.h>
+#include <time.h>
+#else
+#include <windows.h>
+#include <CRTDBG.H>
+#endif
+
+#ifdef POSIX
+#define SLEEP_UNIVERSAL(_x_)  { timespec delay = {(_x_)/1000, 1000000*((_x_)%1000)}; nanosleep(&delay, NULL); }
+#else // #ifdef POSIX
+#define SLEEP_UNIVERSAL(_x_)  Sleep((_x_))
+#endif // #ifdef POSIX
+
+static int g_stop_thread = 0;
+static volatile int g_resume_agent_thread = 0;
+
+static bool test = false;
+static bool util = false;
+static bool flag = false;
+
+const char test_case_name[] = "GetThreadInfo01";
+
+
+extern "C" JNIEXPORT void JNICALL
+Java_ncai_funcs_GetThreadInfo01_resumeagent(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    g_resume_agent_thread = 1;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+Java_ncai_funcs_GetThreadInfo01_stopsignal(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    return g_stop_thread ? true : false;
+}
+
+extern "C" JNIEXPORT void JNICALL Java_ncai_funcs_GetThreadInfo01_TestFunction1
+  (JNIEnv *env, jobject obj)
+{
+    fprintf(stderr, "thread - native TestFunction1\n");
+
+    //warning fix
+    int w_fix = sizeof(obj);
+    w_fix += sizeof(env);
+    //
+
+    g_resume_agent_thread = 1;
+    while(!g_stop_thread)
+    {
+        fprintf(stderr, "thread... \n");
+        SLEEP_UNIVERSAL(100);
+    }
+
+    return;
+}
+
+void JNICALL ThreadStart(jvmtiEnv *jvmti_env,
+            JNIEnv* jni_env,
+            jthread thread)
+{
+    //warning fix
+    int w_fix = 0;
+    w_fix += sizeof(jni_env);
+    //
+
+    jvmtiPhase phase;
+    jvmtiError result;
+    jvmtiThreadInfo tinfo;
+
+    result = jvmti_env->GetPhase(&phase);
+    if (result != JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE)
+        return;
+
+    result = jvmti_env->GetThreadInfo(thread, &tinfo);
+    if (result != JVMTI_ERROR_NONE)
+        return;
+
+    if (strcmp(tinfo.name, "java_thread") != 0)
+        return;
+
+    printf("ThreadStart: java_thread\n");
+    //g_thread_jthread = jni_env->NewGlobalRef(thread);
+}
+
+/* *********************************************************************** */
+
+JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD)
+{
+
+    Callbacks CB;
+    CB.cbThreadStart = &ThreadStart;
+    check_AGENT_ONLOAD;
+    jvmtiEvent events[] = { JVMTI_EVENT_EXCEPTION, JVMTI_EVENT_THREAD_START, JVMTI_EVENT_VM_DEATH };
+    cb_exc;
+    cb_death;
+    return func_for_Agent_OnLoad(vm, options, reserved, &CB,
+        events, sizeof(events)/sizeof(jvmtiEvent), test_case_name, DEBUG_OUT);
+}
+
+/* *********************************************************************** */
+
+void JNICALL callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+                               jthread thread, jmethodID method,
+                               jlocation location, jobject exception,
+                               jmethodID catch_method, jlocation catch_location)
+{
+    check_EXCPT;
+    if (flag) return;
+
+    /*
+     * Function separate all other exceptions in all other method
+     */
+    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
+                "special_method", DEBUG_OUT)) return;
+
+    flag = true;
+    util = true;
+
+    fprintf(stderr, "agent... \n");
+    SLEEP_UNIVERSAL(300);
+    ////////////////////ncai env get
+    jvmtiError err;
+    ncaiError ncai_err;
+
+    jvmtiExtensionFunctionInfo* ext_info = NULL;
+    jint ext_count = 0;
+
+    err = jvmti_env->GetExtensionFunctions(&ext_count, &ext_info);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    fprintf(stderr, "agent... \n");
+    if (ext_count == 0 || ext_info == NULL)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned no extensions\n");
+        test = false;
+        return;
+    }
+
+    jvmtiExtensionFunction get_ncai_func = NULL;
+
+    fprintf(stderr, "agent... \n");
+    for (int k = 0; k < ext_count; k++)
+    {
+        if (strcmp(ext_info[k].id, "org.apache.harmony.vm.GetExtensionEnv") == 0)
+        {
+            get_ncai_func = ext_info[k].func;
+            break;
+        }
+    }
+
+    fprintf(stderr, "agent... \n");
+    if (get_ncai_func == NULL)
+    {
+        fprintf(stderr, "test_function: GetNCAIEnvironment() nas not been found among JVMTI extensions\n");
+        test = false;
+        return;
+    }
+
+    ncaiEnv* ncai_env = NULL;
+
+    fprintf(stderr, "agent... \n");
+    err = get_ncai_func(jvmti_env, &ncai_env, NCAI_VERSION_1_0);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ncai_env == NULL)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned NULL environment\n");
+        test = false;
+        return;
+    }
+    fprintf(stderr, "agent... \n");
+    ///////////////////////////////////
+
+/*
+    fprintf(stderr, "calling ncai->GetThreadHandle()...\n");
+    ncai_err = ncai_env->GetThreadHandle(g_thread_jthread, &ncai_thread);
+    if (ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr, "ncai->GetThreadHandle() returned error: %d", ncai_err);
+        test = false;
+        return;
+    }
+*/
+    ncaiThread* threads;
+    jint threads_returned;
+
+    while(!g_resume_agent_thread)
+            SLEEP_UNIVERSAL(200);
+
+    g_resume_agent_thread = 0;
+
+    test = true;
+
+    ncai_err = ncai_env->GetAllThreads(&threads_returned, &threads);
+    if (ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr, "ncai->GetAllThreads() returned error: %d,\n", ncai_err);
+        test = false;
+        g_stop_thread = 1;
+        return;
+    }
+
+    for(int h = 0; h < threads_returned; h++)
+    {
+        ncaiThreadInfo info;
+        ncai_err = ncai_env->GetThreadInfo(threads[h], &info);
+        if (ncai_err != NCAI_ERROR_NONE)
+        {
+            fprintf(stderr, "ncai->GetThreadInfo() returned error: %d,\n", ncai_err);
+            test = false;
+            g_stop_thread = 1;
+            return;
+        }
+        fprintf(stderr, "\nthreads: %d - %s(%d)",
+            h, info.name, info.kind);
+        if(info.name == NULL || info.kind > NCAI_THREAD_OTHER)
+        {
+            fprintf(stderr, " !!!error!!!");
+            test = false;
+            break;
+        }
+    }
+
+    g_stop_thread = 1;
+    SLEEP_UNIVERSAL(500);
+}
+
+void JNICALL callbackVMDeath(prms_VMDEATH)
+{
+    check_VMDEATH;
+    func_for_callback_VMDeath(jni_env, jvmti_env, test_case_name, test, util);
+}
+
+/* *********************************************************************** */

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01/GetThreadInfo01.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01/GetThreadInfo01.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01/GetThreadInfo01.java?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01/GetThreadInfo01.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01/GetThreadInfo01.java Wed Nov 21 08:29:40 2007
@@ -0,0 +1,68 @@
+package ncai.funcs;
+
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+public class GetThreadInfo01 extends Thread{
+    public native void TestFunction();
+    public native void TestFunction1();
+    public static native boolean stopsignal();
+    public static native void resumeagent();
+
+    static boolean NoLibrary = false;
+    static {
+        try{
+            System.loadLibrary("GetThreadInfo01");
+        }
+        catch(Throwable e){
+            NoLibrary = true;
+        }
+    }
+
+    GetThreadInfo01(String name)
+    {
+        super(name);
+    }
+
+    static public void main(String args[]) {
+        if(NoLibrary) return;
+        new GetThreadInfo01("java_thread1").start();
+        new GetThreadInfo01("java_thread2").start();
+        new GetThreadInfo01("java_thread3").start();
+        special_method();
+        return;
+    }
+
+    public void test_java_func1(){
+        System.out.println("thread - java func1\n");
+        TestFunction1();
+    }
+
+    public void test_java_func2(){
+        System.out.println("thread - java func2\n");
+        test_java_func3();
+    }
+
+    public void test_java_func3(){
+        System.out.println("thread - java func3\n");
+    }
+
+    static public void special_method() {
+        /*
+         * Transfer control to native part.
+         */
+        try {
+            throw new InterruptedException();
+        } catch (Throwable tex) { }
+        return;
+    }
+
+    public void run() {
+        System.out.println("thread - java run\n");
+        test_java_func1();
+    }
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01/GetThreadInfo01.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01n/GetThreadInfo01n.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01n/GetThreadInfo01n.cpp?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01n/GetThreadInfo01n.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01n/GetThreadInfo01n.cpp Wed Nov 21 08:29:40 2007
@@ -0,0 +1,304 @@
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+
+/* *********************************************************************** */
+
+#include "events.h"
+#include "utils.h"
+#include "ncai.h"
+
+#ifdef POSIX
+#include <stdlib.h>
+#include <time.h>
+#else
+#include <windows.h>
+#include <CRTDBG.H>
+#endif
+
+#ifdef POSIX
+#define SLEEP_UNIVERSAL(_x_)  { timespec delay = {(_x_)/1000, 1000000*((_x_)%1000)}; nanosleep(&delay, NULL); }
+#else // #ifdef POSIX
+#define SLEEP_UNIVERSAL(_x_)  Sleep((_x_))
+#endif // #ifdef POSIX
+
+static int g_stop_thread = 0;
+static volatile int g_resume_agent_thread = 0;
+//static jthread g_thread_jthread;
+//static jthread g_agent_thread;
+
+static bool test = false;
+static bool util = false;
+static bool flag = false;
+
+const char test_case_name[] = "GetThreadInfo01n";
+/*
+static void Test1(JNIEnv *env, jobject obj);
+static void Test2(JNIEnv *env, jobject obj);
+static void Test3(JNIEnv *env, jobject obj);
+//void JNICALL test_function(jvmtiEnv*, JNIEnv*, void*);
+static bool CheckSuspend(ncaiEnv*, ncaiThread);
+*/
+extern "C" JNIEXPORT void JNICALL
+Java_ncai_funcs_GetThreadInfo01n_resumeagent(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    g_resume_agent_thread = 1;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+Java_ncai_funcs_GetThreadInfo01n_stopsignal(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    return g_stop_thread ? true : false;
+}
+
+extern "C" JNIEXPORT void JNICALL Java_ncai_funcs_GetThreadInfo01n_TestFunction1
+  (JNIEnv *env, jobject obj)
+{
+    //warning fix
+    int w_fix = sizeof(obj);
+    w_fix += sizeof(env);
+    //
+
+    fprintf(stderr, "thread - native TestFunction1\n");
+
+    g_resume_agent_thread = 1;
+    while(!g_stop_thread)
+    {
+        fprintf(stderr, "thread... \n");
+        SLEEP_UNIVERSAL(100);
+    }
+
+    return;
+}
+
+void JNICALL ThreadStart(jvmtiEnv *jvmti_env,
+            JNIEnv* jni_env,
+            jthread thread)
+{
+    jvmtiPhase phase;
+    jvmtiError result;
+    jvmtiThreadInfo tinfo;
+
+    //warning fix
+    int w_fix = 0;
+    w_fix += sizeof(jni_env);
+    //
+
+    result = jvmti_env->GetPhase(&phase);
+    if (result != JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE)
+        return;
+
+    result = jvmti_env->GetThreadInfo(thread, &tinfo);
+    if (result != JVMTI_ERROR_NONE)
+        return;
+
+    if (strcmp(tinfo.name, "java_thread") != 0)
+        return;
+
+    printf("ThreadStart: java_thread\n");
+/*  g_thread_jthread = jni_env->NewGlobalRef(thread);
+
+    jclass clazz = jni_env->FindClass("java/lang/Thread");
+    if (!clazz)
+    {
+        fprintf(stderr, "\tnative: JNI: FindClass failed\n");
+        return;
+    }
+
+    jmethodID mid = jni_env->GetMethodID(clazz, "<init>", "()V");
+    if (!mid)
+    {
+        fprintf(stderr, "\tnative: JNI: GetMethodID failed\n");
+        return;
+    }
+
+    g_agent_thread = jni_env->NewObject(clazz, mid, "native_agent_thread");
+    if (!g_agent_thread)
+    {
+        fprintf(stderr, "\tnative: JNI: NewObject failed\n");
+        return;
+    }
+
+    g_agent_thread = jni_env->NewGlobalRef(g_agent_thread);
+    result = jvmti_env->GetThreadInfo(g_agent_thread, &tinfo);
+    if (result != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "\tnative: JNI: GetThreadInfo failed\n");
+    }
+
+    result = jvmti_env->RunAgentThread(g_agent_thread, test_function, NULL, JVMTI_THREAD_NORM_PRIORITY);
+    if (result != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "\tnative: jvmti: RunAgentThread failed\n");
+        return;
+    }*/
+}
+
+/* *********************************************************************** */
+
+JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD)
+{
+
+    Callbacks CB;
+    CB.cbThreadStart = &ThreadStart;
+    check_AGENT_ONLOAD;
+    jvmtiEvent events[] = { JVMTI_EVENT_EXCEPTION, JVMTI_EVENT_THREAD_START, JVMTI_EVENT_VM_DEATH };
+    cb_exc;
+    cb_death;
+    return func_for_Agent_OnLoad(vm, options, reserved, &CB,
+        events, sizeof(events)/sizeof(jvmtiEvent), test_case_name, DEBUG_OUT);
+}
+
+/* *********************************************************************** */
+
+void JNICALL callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+                               jthread thread, jmethodID method,
+                               jlocation location, jobject exception,
+                               jmethodID catch_method, jlocation catch_location)
+{
+    check_EXCPT;
+    if (flag) return;
+
+    /*
+     * Function separate all other exceptions in all other method
+     */
+    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
+                "special_method", DEBUG_OUT)) return;
+
+    flag = true;
+    util = true;
+
+    fprintf(stderr, "agent... \n");
+    SLEEP_UNIVERSAL(300);
+    ////////////////////ncai env get
+    jvmtiError err;
+    ncaiError ncai_err;
+
+    jvmtiExtensionFunctionInfo* ext_info = NULL;
+    jint ext_count = 0;
+
+    err = jvmti_env->GetExtensionFunctions(&ext_count, &ext_info);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    fprintf(stderr, "agent... \n");
+    if (ext_count == 0 || ext_info == NULL)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned no extensions\n");
+        test = false;
+        return;
+    }
+
+    jvmtiExtensionFunction get_ncai_func = NULL;
+
+    fprintf(stderr, "agent... \n");
+    for (int k = 0; k < ext_count; k++)
+    {
+        if (strcmp(ext_info[k].id, "org.apache.harmony.vm.GetExtensionEnv") == 0)
+        {
+            get_ncai_func = ext_info[k].func;
+            break;
+        }
+    }
+
+    fprintf(stderr, "agent... \n");
+    if (get_ncai_func == NULL)
+    {
+        fprintf(stderr, "test_function: GetNCAIEnvironment() nas not been found among JVMTI extensions\n");
+        test = false;
+        return;
+    }
+
+    ncaiEnv* ncai_env = NULL;
+
+    fprintf(stderr, "agent... \n");
+    err = get_ncai_func(jvmti_env, &ncai_env, NCAI_VERSION_1_0);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ncai_env == NULL)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned NULL environment\n");
+        test = false;
+        return;
+    }
+    fprintf(stderr, "agent... \n");
+    ///////////////////////////////////
+/*
+    fprintf(stderr, "calling ncai->GetThreadHandle()...\n");
+    ncai_err = ncai_env->GetThreadHandle(g_thread_jthread, &ncai_thread);
+    if (ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr, "ncai->GetThreadHandle() returned error: %d", ncai_err);
+        test = false;
+        return;
+    }
+*/
+    ncaiThread* threads;
+    jint threads_returned;
+
+    while(!g_resume_agent_thread)
+            SLEEP_UNIVERSAL(200);
+
+    g_resume_agent_thread = 0;
+
+    test = true;
+
+    ncai_err = ncai_env->GetAllThreads(&threads_returned, &threads);
+    if (ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr, "ncai->GetAllThreads() returned error: %d,\n", ncai_err);
+        test = false;
+        g_stop_thread = 1;
+        return;
+    }
+
+    for(int h = 0; h < threads_returned; h++)
+    {
+        ncai_err = ncai_env->GetThreadInfo(threads[h], NULL);
+        if (ncai_err != NCAI_ERROR_NULL_POINTER)
+        {
+            fprintf(stderr, "ncai->GetThreadInfo() returned invalid error: %d,\n", ncai_err);
+            test = false;
+            g_stop_thread = 1;
+            return;
+        }
+    }
+
+
+    g_stop_thread = 1;
+    SLEEP_UNIVERSAL(500);
+}
+
+void JNICALL callbackVMDeath(prms_VMDEATH)
+{
+    check_VMDEATH;
+    func_for_callback_VMDeath(jni_env, jvmti_env, test_case_name, test, util);
+}
+
+/* *********************************************************************** */
+

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01n/GetThreadInfo01n.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01n/GetThreadInfo01n.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01n/GetThreadInfo01n.java?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01n/GetThreadInfo01n.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01n/GetThreadInfo01n.java Wed Nov 21 08:29:40 2007
@@ -0,0 +1,68 @@
+package ncai.funcs;
+
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+public class GetThreadInfo01n extends Thread{
+    public native void TestFunction();
+    public native void TestFunction1();
+    public static native boolean stopsignal();
+    public static native void resumeagent();
+
+    static boolean NoLibrary = false;
+    static {
+        try{
+            System.loadLibrary("GetThreadInfo01n");
+        }
+        catch(Throwable e){
+            NoLibrary = true;
+        }
+    }
+
+    GetThreadInfo01n(String name)
+    {
+        super(name);
+    }
+
+    static public void main(String args[]) {
+        if(NoLibrary) return;
+        new GetThreadInfo01n("java_thread1").start();
+        new GetThreadInfo01n("java_thread2").start();
+        new GetThreadInfo01n("java_thread3").start();
+        special_method();
+        return;
+    }
+
+    public void test_java_func1(){
+        System.out.println("thread - java func1\n");
+        TestFunction1();
+    }
+
+    public void test_java_func2(){
+        System.out.println("thread - java func2\n");
+        test_java_func3();
+    }
+
+    public void test_java_func3(){
+        System.out.println("thread - java func3\n");
+    }
+
+    static public void special_method() {
+        /*
+         * Transfer control to native part.
+         */
+        try {
+            throw new InterruptedException();
+        } catch (Throwable tex) { }
+        return;
+    }
+
+    public void run() {
+        System.out.println("thread - java run\n");
+        test_java_func1();
+    }
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo01n/GetThreadInfo01n.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02/GetThreadInfo02.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02/GetThreadInfo02.cpp?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02/GetThreadInfo02.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02/GetThreadInfo02.cpp Wed Nov 21 08:29:40 2007
@@ -0,0 +1,337 @@
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+
+/* *********************************************************************** */
+
+#include "events.h"
+#include "utils.h"
+#include "ncai.h"
+
+#ifdef POSIX
+#include <stdlib.h>
+#include <time.h>
+#else
+#include <windows.h>
+#include <CRTDBG.H>
+#endif
+
+#ifdef POSIX
+#define SLEEP_UNIVERSAL(_x_)  { timespec delay = {(_x_)/1000, 1000000*((_x_)%1000)}; nanosleep(&delay, NULL); }
+#else // #ifdef POSIX
+#define SLEEP_UNIVERSAL(_x_)  Sleep((_x_))
+#endif // #ifdef POSIX
+
+static int g_stop_thread = 0;
+static volatile int g_resume_agent_thread = 0;
+//static jthread g_thread_jthread;
+//static jthread g_agent_thread;
+
+static bool test = false;
+static bool util = false;
+static bool flag = false;
+
+const char test_case_name[] = "GetThreadInfo02";
+/*
+static void Test1(JNIEnv *env, jobject obj);
+static void Test2(JNIEnv *env, jobject obj);
+static void Test3(JNIEnv *env, jobject obj);
+//void JNICALL test_function(jvmtiEnv*, JNIEnv*, void*);
+static bool CheckSuspend(ncaiEnv*, ncaiThread);
+*/
+extern "C" JNIEXPORT void JNICALL
+Java_ncai_funcs_GetThreadInfo02_resumeagent(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    g_resume_agent_thread = 1;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+Java_ncai_funcs_GetThreadInfo02_stopsignal(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    return g_stop_thread ? true : false;
+}
+
+extern "C" JNIEXPORT void JNICALL Java_ncai_funcs_GetThreadInfo02_TestFunction1
+  (JNIEnv *env, jobject obj)
+{
+    fprintf(stderr, "thread - native TestFunction1\n");
+
+    //warning fix
+    int w_fix = sizeof(obj);
+    w_fix += sizeof(env);
+    //
+
+    g_resume_agent_thread = 1;
+    while(!g_stop_thread)
+    {
+        fprintf(stderr, "thread... \n");
+        SLEEP_UNIVERSAL(100);
+    }
+
+    return;
+}
+
+void JNICALL ThreadStart(jvmtiEnv *jvmti_env,
+            JNIEnv* jni_env,
+            jthread thread)
+{
+    jvmtiPhase phase;
+    jvmtiError result;
+    jvmtiThreadInfo tinfo;
+
+    //warning fix
+    int w_fix = 0;
+    w_fix += sizeof(jni_env);
+    //
+
+    result = jvmti_env->GetPhase(&phase);
+    if (result != JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE)
+        return;
+
+    result = jvmti_env->GetThreadInfo(thread, &tinfo);
+    if (result != JVMTI_ERROR_NONE)
+        return;
+
+    if (strcmp(tinfo.name, "java_thread") != 0)
+        return;
+
+    printf("ThreadStart: java_thread\n");
+    //g_thread_jthread = jni_env->NewGlobalRef(thread);
+}
+
+/* *********************************************************************** */
+
+JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD)
+{
+
+    Callbacks CB;
+    CB.cbThreadStart = &ThreadStart;
+    check_AGENT_ONLOAD;
+    jvmtiEvent events[] = { JVMTI_EVENT_EXCEPTION, JVMTI_EVENT_THREAD_START, JVMTI_EVENT_VM_DEATH };
+    cb_exc;
+    cb_death;
+    return func_for_Agent_OnLoad(vm, options, reserved, &CB,
+        events, sizeof(events)/sizeof(jvmtiEvent), test_case_name, DEBUG_OUT);
+}
+
+/* *********************************************************************** */
+
+void JNICALL callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+                               jthread thread, jmethodID method,
+                               jlocation location, jobject exception,
+                               jmethodID catch_method, jlocation catch_location)
+{
+    check_EXCPT;
+    if (flag) return;
+
+    /*
+     * Function separate all other exceptions in all other method
+     */
+    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
+                "special_method", DEBUG_OUT)) return;
+
+    flag = true;
+    util = true;
+
+    fprintf(stderr, "agent... \n");
+    SLEEP_UNIVERSAL(300);
+    ////////////////////ncai env get
+    jvmtiError err;
+    ncaiError ncai_err;
+
+    jvmtiExtensionFunctionInfo* ext_info = NULL;
+    jint ext_count = 0;
+
+    err = jvmti_env->GetExtensionFunctions(&ext_count, &ext_info);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    fprintf(stderr, "agent... \n");
+    if (ext_count == 0 || ext_info == NULL)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned no extensions\n");
+        test = false;
+        return;
+    }
+
+    jvmtiExtensionFunction get_ncai_func = NULL;
+
+    fprintf(stderr, "agent... \n");
+    for (int k = 0; k < ext_count; k++)
+    {
+        if (strcmp(ext_info[k].id, "org.apache.harmony.vm.GetExtensionEnv") == 0)
+        {
+            get_ncai_func = ext_info[k].func;
+            break;
+        }
+    }
+
+    fprintf(stderr, "agent... \n");
+    if (get_ncai_func == NULL)
+    {
+        fprintf(stderr, "test_function: GetNCAIEnvironment() nas not been found among JVMTI extensions\n");
+        test = false;
+        return;
+    }
+
+    ncaiEnv* ncai_env = NULL;
+
+    fprintf(stderr, "agent... \n");
+    err = get_ncai_func(jvmti_env, &ncai_env, NCAI_VERSION_1_0);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ncai_env == NULL)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned NULL environment\n");
+        test = false;
+        return;
+    }
+    fprintf(stderr, "agent... \n");
+    ///////////////////////////////////
+/*
+    fprintf(stderr, "calling ncai->GetThreadHandle()...\n");
+    ncai_err = ncai_env->GetThreadHandle(g_thread_jthread, &ncai_thread);
+    if (ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr, "ncai->GetThreadHandle() returned error: %d", ncai_err);
+        test = false;
+        return;
+    }
+*/
+    ncaiThread* threads;
+    jint threads_returned;
+
+    while(!g_resume_agent_thread)
+            SLEEP_UNIVERSAL(200);
+
+    g_resume_agent_thread = 0;
+
+    test = true;
+
+    ncai_err = ncai_env->GetAllThreads(&threads_returned, &threads);
+    if (ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr, "ncai->GetAllThreads() returned error: %d,\n", ncai_err);
+        test = false;
+        g_stop_thread = 1;
+        return;
+    }
+
+    int check = 0;
+    ncaiThread j_threads[3];
+    ncaiThreadInfo j_info[3];
+    for(int h = 0; h < threads_returned; h++)
+    {
+        ncaiThreadInfo info;
+        ncai_err = ncai_env->GetThreadInfo(threads[h], &info);
+        if (ncai_err != NCAI_ERROR_NONE)
+        {
+            fprintf(stderr, "ncai->GetThreadInfo() returned error: %d,\n", ncai_err);
+            test = false;
+            g_stop_thread = 1;
+            return;
+        }
+        if((strcmp(info.name, "java_thread1") == 0) ||
+            (strcmp(info.name, "java_thread2") == 0) ||
+            (strcmp(info.name, "java_thread3") == 0))
+        {
+            j_threads[check] = threads[h];
+            j_info[check] = info;
+            check++;
+        }
+    }
+
+    if(check != 3)
+        test = false;
+
+    for(int g = 0; g < 3; g++)
+    {
+        ncai_err = ncai_env->SuspendThread(j_threads[g]);
+        if (ncai_err != NCAI_ERROR_NONE)
+        {
+            fprintf(stderr, "ncai->SuspendThread() returned error: %d,\n", ncai_err);
+            test = false;
+            g_stop_thread = 1;
+            return;
+        }
+
+        fprintf(stderr, "\nthreads: %d - %s(%d) suspended",
+                g, j_info[g].name, j_info[g].kind);
+    }
+
+    fprintf(stderr, "\n-----");
+
+    for(int r = 0; r < threads_returned; r++)
+    {
+        ncaiThreadInfo info;
+        ncai_err = ncai_env->GetThreadInfo(threads[r], &info);
+        if (ncai_err != NCAI_ERROR_NONE)
+        {
+            fprintf(stderr, "ncai->GetThreadInfo() returned error: %d,\n", ncai_err);
+            test = false;
+            g_stop_thread = 1;
+            return;
+        }
+        fprintf(stderr, "\nthreads: %d - %s(%d)",
+            r, info.name, info.kind);
+        if(info.name == NULL || info.kind > NCAI_THREAD_OTHER)
+        {
+            fprintf(stderr, " !!!error!!!");
+            test = false;
+            break;
+        }
+    }
+
+    fprintf(stderr, "\n-----");
+
+    for(int l = 0; l < 3; l++)
+    {
+        ncai_err = ncai_env->ResumeThread(j_threads[l]);
+        if (ncai_err != NCAI_ERROR_NONE)
+        {
+            fprintf(stderr, "ncai->ResumeThread() returned error: %d,\n", ncai_err);
+            test = false;
+            g_stop_thread = 1;
+            return;
+        }
+
+        fprintf(stderr, "\nthreads: %d - %s(%d) resumed",
+                l, j_info[l].name, j_info[l].kind);
+    }
+
+    g_stop_thread = 1;
+    SLEEP_UNIVERSAL(500);
+}
+
+void JNICALL callbackVMDeath(prms_VMDEATH)
+{
+    check_VMDEATH;
+    func_for_callback_VMDeath(jni_env, jvmti_env, test_case_name, test, util);
+}
+
+/* *********************************************************************** */

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02/GetThreadInfo02.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02/GetThreadInfo02.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02/GetThreadInfo02.java?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02/GetThreadInfo02.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02/GetThreadInfo02.java Wed Nov 21 08:29:40 2007
@@ -0,0 +1,68 @@
+package ncai.funcs;
+
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+public class GetThreadInfo02 extends Thread{
+    public native void TestFunction();
+    public native void TestFunction1();
+    public static native boolean stopsignal();
+    public static native void resumeagent();
+
+    static boolean NoLibrary = false;
+    static {
+        try{
+            System.loadLibrary("GetThreadInfo02");
+        }
+        catch(Throwable e){
+            NoLibrary = true;
+        }
+    }
+
+    GetThreadInfo02(String name)
+    {
+        super(name);
+    }
+
+    static public void main(String args[]) {
+        if(NoLibrary) return;
+        new GetThreadInfo02("java_thread1").start();
+        new GetThreadInfo02("java_thread2").start();
+        new GetThreadInfo02("java_thread3").start();
+        special_method();
+        return;
+    }
+
+    public void test_java_func1(){
+        System.out.println("thread - java func1\n");
+        TestFunction1();
+    }
+
+    public void test_java_func2(){
+        System.out.println("thread - java func2\n");
+        test_java_func3();
+    }
+
+    public void test_java_func3(){
+        System.out.println("thread - java func3\n");
+    }
+
+    static public void special_method() {
+        /*
+         * Transfer control to native part.
+         */
+        try {
+            throw new InterruptedException();
+        } catch (Throwable tex) { }
+        return;
+    }
+
+    public void run() {
+        System.out.println("thread - java run\n");
+        test_java_func1();
+    }
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02/GetThreadInfo02.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02n/GetThreadInfo02n.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02n/GetThreadInfo02n.cpp?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02n/GetThreadInfo02n.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02n/GetThreadInfo02n.cpp Wed Nov 21 08:29:40 2007
@@ -0,0 +1,303 @@
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+
+/* *********************************************************************** */
+
+#include "events.h"
+#include "utils.h"
+#include "ncai.h"
+
+#ifdef POSIX
+#include <stdlib.h>
+#include <time.h>
+#else
+#include <windows.h>
+#include <CRTDBG.H>
+#endif
+
+#ifdef POSIX
+#define SLEEP_UNIVERSAL(_x_)  { timespec delay = {(_x_)/1000, 1000000*((_x_)%1000)}; nanosleep(&delay, NULL); }
+#else // #ifdef POSIX
+#define SLEEP_UNIVERSAL(_x_)  Sleep((_x_))
+#endif // #ifdef POSIX
+
+static int g_stop_thread = 0;
+static volatile int g_resume_agent_thread = 0;
+//static jthread g_thread_jthread;
+//static jthread g_agent_thread;
+
+static bool test = false;
+static bool util = false;
+static bool flag = false;
+
+const char test_case_name[] = "GetThreadInfo02n";
+/*
+static void Test1(JNIEnv *env, jobject obj);
+static void Test2(JNIEnv *env, jobject obj);
+static void Test3(JNIEnv *env, jobject obj);
+//void JNICALL test_function(jvmtiEnv*, JNIEnv*, void*);
+static bool CheckSuspend(ncaiEnv*, ncaiThread);
+*/
+extern "C" JNIEXPORT void JNICALL
+Java_ncai_funcs_GetThreadInfo02n_resumeagent(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    g_resume_agent_thread = 1;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+Java_ncai_funcs_GetThreadInfo02n_stopsignal(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    return g_stop_thread ? true : false;
+}
+
+extern "C" JNIEXPORT void JNICALL Java_ncai_funcs_GetThreadInfo02n_TestFunction1
+  (JNIEnv *env, jobject obj)
+{
+    fprintf(stderr, "thread - native TestFunction1\n");
+
+    //warning fix
+    int w_fix = sizeof(obj);
+    w_fix += sizeof(env);
+    //
+
+    g_resume_agent_thread = 1;
+    while(!g_stop_thread)
+    {
+        fprintf(stderr, "thread... \n");
+        SLEEP_UNIVERSAL(100);
+    }
+
+    return;
+}
+
+void JNICALL ThreadStart(jvmtiEnv *jvmti_env,
+            JNIEnv* jni_env,
+            jthread thread)
+{
+    //warning fix
+    int w_fix = 0;
+    w_fix += sizeof(jni_env);
+    //
+
+    jvmtiPhase phase;
+    jvmtiError result;
+    jvmtiThreadInfo tinfo;
+
+    result = jvmti_env->GetPhase(&phase);
+    if (result != JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE)
+        return;
+
+    result = jvmti_env->GetThreadInfo(thread, &tinfo);
+    if (result != JVMTI_ERROR_NONE)
+        return;
+
+    if (strcmp(tinfo.name, "java_thread") != 0)
+        return;
+
+    printf("ThreadStart: java_thread\n");
+//    g_thread_jthread = jni_env->NewGlobalRef(thread);
+/*
+    jclass clazz = jni_env->FindClass("java/lang/Thread");
+    if (!clazz)
+    {
+        fprintf(stderr, "\tnative: JNI: FindClass failed\n");
+        return;
+    }
+
+    jmethodID mid = jni_env->GetMethodID(clazz, "<init>", "()V");
+    if (!mid)
+    {
+        fprintf(stderr, "\tnative: JNI: GetMethodID failed\n");
+        return;
+    }
+
+    g_agent_thread = jni_env->NewObject(clazz, mid, "native_agent_thread");
+    if (!g_agent_thread)
+    {
+        fprintf(stderr, "\tnative: JNI: NewObject failed\n");
+        return;
+    }
+
+    g_agent_thread = jni_env->NewGlobalRef(g_agent_thread);
+    result = jvmti_env->GetThreadInfo(g_agent_thread, &tinfo);
+    if (result != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "\tnative: JNI: GetThreadInfo failed\n");
+    }
+
+    result = jvmti_env->RunAgentThread(g_agent_thread, test_function, NULL, JVMTI_THREAD_NORM_PRIORITY);
+    if (result != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "\tnative: jvmti: RunAgentThread failed\n");
+        return;
+    }*/
+}
+
+/* *********************************************************************** */
+
+JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD)
+{
+
+    Callbacks CB;
+    CB.cbThreadStart = &ThreadStart;
+    check_AGENT_ONLOAD;
+    jvmtiEvent events[] = { JVMTI_EVENT_EXCEPTION, JVMTI_EVENT_THREAD_START, JVMTI_EVENT_VM_DEATH };
+    cb_exc;
+    cb_death;
+    return func_for_Agent_OnLoad(vm, options, reserved, &CB,
+        events, sizeof(events)/sizeof(jvmtiEvent), test_case_name, DEBUG_OUT);
+}
+
+/* *********************************************************************** */
+
+void JNICALL callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+                               jthread thread, jmethodID method,
+                               jlocation location, jobject exception,
+                               jmethodID catch_method, jlocation catch_location)
+{
+    check_EXCPT;
+    if (flag) return;
+
+    /*
+     * Function separate all other exceptions in all other method
+     */
+    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
+                "special_method", DEBUG_OUT)) return;
+
+    flag = true;
+    util = true;
+
+    fprintf(stderr, "agent... \n");
+    SLEEP_UNIVERSAL(300);
+    ////////////////////ncai env get
+    jvmtiError err;
+    ncaiError ncai_err;
+
+    jvmtiExtensionFunctionInfo* ext_info = NULL;
+    jint ext_count = 0;
+
+    err = jvmti_env->GetExtensionFunctions(&ext_count, &ext_info);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    fprintf(stderr, "agent... \n");
+    if (ext_count == 0 || ext_info == NULL)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned no extensions\n");
+        test = false;
+        return;
+    }
+
+    jvmtiExtensionFunction get_ncai_func = NULL;
+
+    fprintf(stderr, "agent... \n");
+    for (int k = 0; k < ext_count; k++)
+    {
+        if (strcmp(ext_info[k].id, "org.apache.harmony.vm.GetExtensionEnv") == 0)
+        {
+            get_ncai_func = ext_info[k].func;
+            break;
+        }
+    }
+
+    fprintf(stderr, "agent... \n");
+    if (get_ncai_func == NULL)
+    {
+        fprintf(stderr, "test_function: GetNCAIEnvironment() nas not been found among JVMTI extensions\n");
+        test = false;
+        return;
+    }
+
+    ncaiEnv* ncai_env = NULL;
+
+    fprintf(stderr, "agent... \n");
+    err = get_ncai_func(jvmti_env, &ncai_env, NCAI_VERSION_1_0);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ncai_env == NULL)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned NULL environment\n");
+        test = false;
+        return;
+    }
+    fprintf(stderr, "agent... \n");
+    ///////////////////////////////////
+/*
+    fprintf(stderr, "calling ncai->GetThreadHandle()...\n");
+    ncai_err = ncai_env->GetThreadHandle(g_thread_jthread, &ncai_thread);
+    if (ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr, "ncai->GetThreadHandle() returned error: %d", ncai_err);
+        test = false;
+        return;
+    }
+*/
+    ncaiThread* threads;
+    jint threads_returned;
+
+    while(!g_resume_agent_thread)
+            SLEEP_UNIVERSAL(200);
+
+    g_resume_agent_thread = 0;
+
+    test = true;
+
+    ncai_err = ncai_env->GetAllThreads(&threads_returned, &threads);
+    if (ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr, "ncai->GetAllThreads() returned error: %d,\n", ncai_err);
+        test = false;
+        g_stop_thread = 1;
+        return;
+    }
+
+    for(int h = 0; h < threads_returned; h++)
+    {
+        ncaiThreadInfo info;
+        ncai_err = ncai_env->GetThreadInfo(NULL, &info);
+        if (ncai_err != NCAI_ERROR_INVALID_THREAD)
+        {
+            fprintf(stderr, "ncai->GetThreadInfo() returned invalid error: %d,\n", ncai_err);
+            test = false;
+            g_stop_thread = 1;
+            return;
+        }
+    }
+
+    g_stop_thread = 1;
+    SLEEP_UNIVERSAL(500);
+}
+
+void JNICALL callbackVMDeath(prms_VMDEATH)
+{
+    check_VMDEATH;
+    func_for_callback_VMDeath(jni_env, jvmti_env, test_case_name, test, util);
+}
+
+/* *********************************************************************** */

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02n/GetThreadInfo02n.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02n/GetThreadInfo02n.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02n/GetThreadInfo02n.java?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02n/GetThreadInfo02n.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02n/GetThreadInfo02n.java Wed Nov 21 08:29:40 2007
@@ -0,0 +1,68 @@
+package ncai.funcs;
+
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+public class GetThreadInfo02n extends Thread{
+    public native void TestFunction();
+    public native void TestFunction1();
+    public static native boolean stopsignal();
+    public static native void resumeagent();
+
+    static boolean NoLibrary = false;
+    static {
+        try{
+            System.loadLibrary("GetThreadInfo02n");
+        }
+        catch(Throwable e){
+            NoLibrary = true;
+        }
+    }
+
+    GetThreadInfo02n(String name)
+    {
+        super(name);
+    }
+
+    static public void main(String args[]) {
+        if(NoLibrary) return;
+        new GetThreadInfo02n("java_thread1").start();
+        new GetThreadInfo02n("java_thread2").start();
+        new GetThreadInfo02n("java_thread3").start();
+        special_method();
+        return;
+    }
+
+    public void test_java_func1(){
+        System.out.println("thread - java func1\n");
+        TestFunction1();
+    }
+
+    public void test_java_func2(){
+        System.out.println("thread - java func2\n");
+        test_java_func3();
+    }
+
+    public void test_java_func3(){
+        System.out.println("thread - java func3\n");
+    }
+
+    static public void special_method() {
+        /*
+         * Transfer control to native part.
+         */
+        try {
+            throw new InterruptedException();
+        } catch (Throwable tex) { }
+        return;
+    }
+
+    public void run() {
+        System.out.println("thread - java run\n");
+        test_java_func1();
+    }
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/GetThreadInfo/GetThreadInfo02n/GetThreadInfo02n.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory01/ReadMemory01.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory01/ReadMemory01.cpp?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory01/ReadMemory01.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory01/ReadMemory01.cpp Wed Nov 21 08:29:40 2007
@@ -0,0 +1,137 @@
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+
+/* *********************************************************************** */
+
+#include "events.h"
+#include "utils.h"
+#include "ncai.h"
+
+static bool test = false;
+static bool util = false;
+static bool flag = false;
+
+const char test_case_name[] = "ReadMemory01";
+
+/* *********************************************************************** */
+
+
+JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD)
+{
+    Callbacks CB;
+    check_AGENT_ONLOAD;
+    jvmtiEvent events[] = { JVMTI_EVENT_EXCEPTION, JVMTI_EVENT_VM_DEATH };
+    cb_exc;
+    cb_death;
+    return func_for_Agent_OnLoad(vm, options, reserved, &CB,
+        events, sizeof(events)/sizeof(jvmtiEvent), test_case_name, DEBUG_OUT);
+}
+
+/* *********************************************************************** */
+
+void JNICALL callbackException(prms_EXCPT)
+{
+    check_EXCPT;
+    if (flag) return;
+
+    /*
+     * Function separate all other exceptions in all other method
+     */
+    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
+                "special_method", DEBUG_OUT)) return;
+
+    flag = true;
+    util = true;
+
+    jvmtiError err;
+    ncaiError ncai_err;
+
+    jvmtiExtensionFunctionInfo* ext_info = NULL;
+    jint ext_count = 0;
+
+    err = jvmti_env->GetExtensionFunctions(&ext_count, &ext_info);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ext_count == 0 || ext_info == NULL)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned no extensions\n");
+        test = false;
+        return;
+    }
+
+    jvmtiExtensionFunction get_ncai_func = NULL;
+
+    for (int i = 0; i < ext_count; i++)
+    {
+        if (strcmp(ext_info[i].id, "org.apache.harmony.vm.GetExtensionEnv") == 0)
+        {
+            get_ncai_func = ext_info[i].func;
+            break;
+        }
+    }
+
+    if (get_ncai_func == NULL)
+    {
+        fprintf(stderr, "test_function: GetNCAIEnvironment() nas not been found among JVMTI extensions\n");
+        test = false;
+        return;
+    }
+
+    ncaiEnv* ncai_env = NULL;
+
+    err = get_ncai_func(jvmti_env, &ncai_env, NCAI_VERSION_1_0);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ncai_env == NULL)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned NULL environment\n");
+        test = false;
+        return;
+    }
+
+    char buf[] = "1234567890qwerty";
+    char out_buf[100];
+
+    ncai_err = ncai_env->ReadMemory(&buf, 16, &out_buf);
+    if(ncai_err != NCAI_ERROR_NONE)
+    {
+        test = false;
+        return;
+    }
+
+    for(int k = 0; k < 16; k++)
+    {
+        if(out_buf[k] != buf[k])
+        {
+            test = false;
+            return;
+        }
+    }
+
+    test = true;
+}
+
+void JNICALL callbackVMDeath(prms_VMDEATH)
+{
+    check_VMDEATH;
+    func_for_callback_VMDeath(jni_env, jvmti_env, test_case_name, test, util);
+}
+
+/* *********************************************************************** */

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory01/ReadMemory01.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory01/ReadMemory01.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory01/ReadMemory01.java?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory01/ReadMemory01.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory01/ReadMemory01.java Wed Nov 21 08:29:40 2007
@@ -0,0 +1,26 @@
+package ncai.funcs;
+
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+public class ReadMemory01 {
+
+    static public void main(String args[]) {
+        special_method();
+        return;
+    }
+
+    static public void special_method() {
+        /*
+         * Transfer control to native part.
+         */
+        try {
+            throw new InterruptedException();
+        } catch (Throwable tex) { }
+        return;
+    }
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory01/ReadMemory01.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory02/ReadMemory02.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory02/ReadMemory02.cpp?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory02/ReadMemory02.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory02/ReadMemory02.cpp Wed Nov 21 08:29:40 2007
@@ -0,0 +1,138 @@
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+
+/* *********************************************************************** */
+
+#include "events.h"
+#include "utils.h"
+#include "ncai.h"
+
+static bool test = false;
+static bool util = false;
+static bool flag = false;
+
+const char test_case_name[] = "ReadMemory02";
+static char buf[] = "1234567890qwerty";
+
+/* *********************************************************************** */
+
+
+JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD)
+{
+    Callbacks CB;
+    check_AGENT_ONLOAD;
+    jvmtiEvent events[] = { JVMTI_EVENT_EXCEPTION, JVMTI_EVENT_VM_DEATH };
+    cb_exc;
+    cb_death;
+    return func_for_Agent_OnLoad(vm, options, reserved, &CB,
+        events, sizeof(events)/sizeof(jvmtiEvent), test_case_name, DEBUG_OUT);
+}
+
+/* *********************************************************************** */
+
+void JNICALL callbackException(prms_EXCPT)
+{
+    check_EXCPT;
+    if (flag) return;
+
+    /*
+     * Function separate all other exceptions in all other method
+     */
+    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
+                "special_method", DEBUG_OUT)) return;
+
+    flag = true;
+    util = true;
+
+    jvmtiError err;
+    ncaiError ncai_err;
+
+    jvmtiExtensionFunctionInfo* ext_info = NULL;
+    jint ext_count = 0;
+
+    err = jvmti_env->GetExtensionFunctions(&ext_count, &ext_info);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ext_count == 0 || ext_info == NULL)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned no extensions\n");
+        test = false;
+        return;
+    }
+
+    jvmtiExtensionFunction get_ncai_func = NULL;
+
+    for (int i = 0; i < ext_count; i++)
+    {
+        if (strcmp(ext_info[i].id, "org.apache.harmony.vm.GetExtensionEnv") == 0)
+        {
+            get_ncai_func = ext_info[i].func;
+            break;
+        }
+    }
+
+    if (get_ncai_func == NULL)
+    {
+        fprintf(stderr, "test_function: GetNCAIEnvironment() nas not been found among JVMTI extensions\n");
+        test = false;
+        return;
+    }
+
+    ncaiEnv* ncai_env = NULL;
+
+    err = get_ncai_func(jvmti_env, &ncai_env, NCAI_VERSION_1_0);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ncai_env == NULL)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned NULL environment\n");
+        test = false;
+        return;
+    }
+
+    char out_buf[100];
+
+    ncai_err = ncai_env->ReadMemory(&buf, 16, &out_buf);
+    if(ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr, "ReadMemory returned error: %d\n", ncai_err);
+        test = false;
+        return;
+    }
+
+    for(int k = 0; k < 16; k++)
+    {
+        if(out_buf[k] != buf[k])
+        {
+            test = false;
+            return;
+        }
+    }
+
+    test = true;
+}
+
+void JNICALL callbackVMDeath(prms_VMDEATH)
+{
+    check_VMDEATH;
+    func_for_callback_VMDeath(jni_env, jvmti_env, test_case_name, test, util);
+}
+
+/* *********************************************************************** */

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory02/ReadMemory02.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory02/ReadMemory02.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory02/ReadMemory02.java?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory02/ReadMemory02.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory02/ReadMemory02.java Wed Nov 21 08:29:40 2007
@@ -0,0 +1,26 @@
+package ncai.funcs;
+
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+public class ReadMemory02 {
+
+    static public void main(String args[]) {
+        special_method();
+        return;
+    }
+
+    static public void special_method() {
+        /*
+         * Transfer control to native part.
+         */
+        try {
+            throw new InterruptedException();
+        } catch (Throwable tex) { }
+        return;
+    }
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory02/ReadMemory02.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory03/ReadMemory03.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory03/ReadMemory03.cpp?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory03/ReadMemory03.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory03/ReadMemory03.cpp Wed Nov 21 08:29:40 2007
@@ -0,0 +1,139 @@
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+
+/* *********************************************************************** */
+
+#include "events.h"
+#include "utils.h"
+#include "ncai.h"
+
+static bool test = false;
+static bool util = false;
+static bool flag = false;
+
+const char test_case_name[] = "ReadMemory03";
+
+/* *********************************************************************** */
+
+
+JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD)
+{
+    Callbacks CB;
+    check_AGENT_ONLOAD;
+    jvmtiEvent events[] = { JVMTI_EVENT_EXCEPTION, JVMTI_EVENT_VM_DEATH };
+    cb_exc;
+    cb_death;
+    return func_for_Agent_OnLoad(vm, options, reserved, &CB,
+        events, sizeof(events)/sizeof(jvmtiEvent), test_case_name, DEBUG_OUT);
+}
+
+/* *********************************************************************** */
+
+void JNICALL callbackException(prms_EXCPT)
+{
+    check_EXCPT;
+    if (flag) return;
+
+    /*
+     * Function separate all other exceptions in all other method
+     */
+    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
+                "special_method", DEBUG_OUT)) return;
+
+    flag = true;
+    util = true;
+
+    jvmtiError err;
+    ncaiError ncai_err;
+
+    jvmtiExtensionFunctionInfo* ext_info = NULL;
+    jint ext_count = 0;
+
+    err = jvmti_env->GetExtensionFunctions(&ext_count, &ext_info);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ext_count == 0 || ext_info == NULL)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned no extensions\n");
+        test = false;
+        return;
+    }
+
+    jvmtiExtensionFunction get_ncai_func = NULL;
+
+    for (int i = 0; i < ext_count; i++)
+    {
+        if (strcmp(ext_info[i].id, "org.apache.harmony.vm.GetExtensionEnv") == 0)
+        {
+            get_ncai_func = ext_info[i].func;
+            break;
+        }
+    }
+
+    if (get_ncai_func == NULL)
+    {
+        fprintf(stderr, "test_function: GetNCAIEnvironment() nas not been found among JVMTI extensions\n");
+        test = false;
+        return;
+    }
+
+    ncaiEnv* ncai_env = NULL;
+
+    err = get_ncai_func(jvmti_env, &ncai_env, NCAI_VERSION_1_0);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ncai_env == NULL)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned NULL environment\n");
+        test = false;
+        return;
+    }
+
+    char* buf;
+    buf = new char[50];
+    strcpy(buf, "dsjgkhdafjkghdfkjghsdfkjghsd");
+    char out_buf[100];
+
+    ncai_err = ncai_env->ReadMemory(buf, 50, &out_buf);
+    if(ncai_err != NCAI_ERROR_NONE)
+    {
+        test = false;
+        return;
+    }
+
+    for(int k = 0; k < 50; k++)
+    {
+        if(out_buf[k] != buf[k])
+        {
+            test = false;
+            return;
+        }
+    }
+
+    test = true;
+}
+
+void JNICALL callbackVMDeath(prms_VMDEATH)
+{
+    check_VMDEATH;
+    func_for_callback_VMDeath(jni_env, jvmti_env, test_case_name, test, util);
+}
+
+/* *********************************************************************** */

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory03/ReadMemory03.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory03/ReadMemory03.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory03/ReadMemory03.java?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory03/ReadMemory03.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory03/ReadMemory03.java Wed Nov 21 08:29:40 2007
@@ -0,0 +1,26 @@
+package ncai.funcs;
+
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+public class ReadMemory03 {
+
+    static public void main(String args[]) {
+        special_method();
+        return;
+    }
+
+    static public void special_method() {
+        /*
+         * Transfer control to native part.
+         */
+        try {
+            throw new InterruptedException();
+        } catch (Throwable tex) { }
+        return;
+    }
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory03/ReadMemory03.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory04/ReadMemory04.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory04/ReadMemory04.cpp?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory04/ReadMemory04.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory04/ReadMemory04.cpp Wed Nov 21 08:29:40 2007
@@ -0,0 +1,158 @@
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+
+/* *********************************************************************** */
+
+#include "events.h"
+#include "utils.h"
+#include "ncai.h"
+
+static bool test = false;
+static bool util = false;
+static bool flag = false;
+
+const char test_case_name[] = "ReadMemory04";
+typedef void (*functionPtr)(void);
+static void Test();
+
+/* *********************************************************************** */
+
+extern "C" JNIEXPORT void JNICALL Java_ncai_funcs_ReadMemory04_TestFunction
+  (JNIEnv *env, jclass clazz)
+{
+    fprintf(stderr, "JNI TestFunction: run\n");
+    return;
+}
+
+
+JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD)
+{
+    Callbacks CB;
+    check_AGENT_ONLOAD;
+    jvmtiEvent events[] = { JVMTI_EVENT_EXCEPTION, JVMTI_EVENT_VM_DEATH };
+    cb_exc;
+    cb_death;
+    return func_for_Agent_OnLoad(vm, options, reserved, &CB,
+        events, sizeof(events)/sizeof(jvmtiEvent), test_case_name, DEBUG_OUT);
+}
+
+/* *********************************************************************** */
+
+void JNICALL callbackException(prms_EXCPT)
+{
+    check_EXCPT;
+    if (flag) return;
+
+    /*
+     * Function separate all other exceptions in all other method
+     */
+    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
+                "special_method", DEBUG_OUT)) return;
+
+    flag = true;
+    util = true;
+
+    jvmtiError err;
+    ncaiError ncai_err;
+
+    jvmtiExtensionFunctionInfo* ext_info = NULL;
+    jint ext_count = 0;
+
+    err = jvmti_env->GetExtensionFunctions(&ext_count, &ext_info);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ext_count == 0 || ext_info == NULL)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned no extensions\n");
+        test = false;
+        return;
+    }
+
+    jvmtiExtensionFunction get_ncai_func = NULL;
+
+    for (int i = 0; i < ext_count; i++)
+    {
+        if (strcmp(ext_info[i].id, "org.apache.harmony.vm.GetExtensionEnv") == 0)
+        {
+            get_ncai_func = ext_info[i].func;
+            break;
+        }
+    }
+
+    if (get_ncai_func == NULL)
+    {
+        fprintf(stderr, "test_function: GetNCAIEnvironment() nas not been found among JVMTI extensions\n");
+        test = false;
+        return;
+    }
+
+    ncaiEnv* ncai_env = NULL;
+
+    err = get_ncai_func(jvmti_env, &ncai_env, NCAI_VERSION_1_0);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ncai_env == NULL)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned NULL environment\n");
+        test = false;
+        return;
+    }
+
+    char buf[200];
+    functionPtr func = Test;
+
+    ncai_err = ncai_env->ReadMemory((void *)func, 1, &buf);
+    if(ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr,
+            "test_function: ncai_env->ReadMemory(%p, 1, (void*)%p) has returned %d\n",
+            (void*)func, &buf, ncai_err);
+        test = false;
+        return;
+    }
+
+    test = true;
+}
+
+void JNICALL callbackVMDeath(prms_VMDEATH)
+{
+    check_VMDEATH;
+    func_for_callback_VMDeath(jni_env, jvmti_env, test_case_name, test, util);
+}
+
+/* *********************************************************************** */
+
+void Test()
+{
+    int s = 3;
+    int a = s++;
+    int d = ++a;
+    int f = d--;
+    int g = --f;
+    int h = g-f;
+    int j = s+a;
+    while(s < 30)
+    {
+        s--;
+        if(s <= 0)
+            s = h+j;
+    }
+    return;
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory04/ReadMemory04.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory04/ReadMemory04.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory04/ReadMemory04.java?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory04/ReadMemory04.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory04/ReadMemory04.java Wed Nov 21 08:29:40 2007
@@ -0,0 +1,38 @@
+package ncai.funcs;
+
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+public class ReadMemory04 {
+    public static native void TestFunction();
+    static boolean NoLibrary = false;
+    static {
+        try{
+            System.loadLibrary("ReadMemory04");
+        }
+        catch(Throwable e){
+            NoLibrary = true;
+        }
+    }
+
+    static public void main(String args[]) {
+        if(NoLibrary) return;
+        TestFunction();
+        special_method();
+        return;
+    }
+
+    static public void special_method() {
+        /*
+         * Transfer control to native part.
+         */
+        try {
+            throw new InterruptedException();
+        } catch (Throwable tex) { }
+        return;
+    }
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/ReadMemory/ReadMemory04/ReadMemory04.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/SuspendResumeThread/ResumeThread01/ResumeThread01.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/SuspendResumeThread/ResumeThread01/ResumeThread01.cpp?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/SuspendResumeThread/ResumeThread01/ResumeThread01.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/SuspendResumeThread/ResumeThread01/ResumeThread01.cpp Wed Nov 21 08:29:40 2007
@@ -0,0 +1,404 @@
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+
+/* *********************************************************************** */
+
+#include "events.h"
+#include "utils.h"
+#include "ncai.h"
+
+#ifdef POSIX
+#include <stdlib.h>
+#include <time.h>
+#else
+#include <windows.h>
+#include <CRTDBG.H>
+#endif
+
+#ifdef POSIX
+#define SLEEP_UNIVERSAL(_x_)  { timespec delay = {(_x_)/1000, 1000000*((_x_)%1000)}; nanosleep(&delay, NULL); }
+#else // #ifdef POSIX
+#define SLEEP_UNIVERSAL(_x_)  Sleep((_x_))
+#endif // #ifdef POSIX
+
+static int g_stop_thread = 0;
+static volatile int g_resume_agent_thread = 0;
+static jthread g_thread_jthread;
+//static jthread g_agent_thread;
+
+static volatile int no_opt = 1; //used to prevent inlining;
+
+static int counter = 0;
+
+static bool test = false;
+static bool util = false;
+static bool flag = false;
+
+const char test_case_name[] = "ResumeThread01";
+
+static void Test1(JNIEnv *env, jobject obj);
+static void Test2(JNIEnv *env, jobject obj);
+static void Test3(JNIEnv *env, jobject obj);
+//static void JNICALL test_function(jvmtiEnv*, JNIEnv*, void*);
+static bool CheckResume(ncaiEnv*, ncaiThread);
+
+
+extern "C" JNIEXPORT void JNICALL
+Java_ncai_funcs_ResumeThread01_resumeagent(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    g_resume_agent_thread = 1;
+}
+
+extern "C" JNIEXPORT void JNICALL
+Java_ncai_funcs_ResumeThread01_increment(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    counter++;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+Java_ncai_funcs_ResumeThread01_stopsignal(JNIEnv *env, jclass cls)
+{
+    //warning fix
+    int w_fix = sizeof(cls);
+    w_fix += sizeof(env);
+    //
+
+    return g_stop_thread ? true : false;
+}
+
+extern "C" JNIEXPORT void JNICALL Java_ncai_funcs_ResumeThread01_TestFunction
+  (JNIEnv *env, jobject obj)
+{
+    fprintf(stderr, "thread - native TestFunction\n");
+
+    jclass clazz = env->GetObjectClass(obj);
+    if (!clazz)
+    {
+        fprintf(stderr, "\tnative: native TestFunction: GetObjectClass failed\n");
+        return;
+    }
+
+    jmethodID mid = env->GetMethodID(clazz, "test_java_func2", "()V");
+    if (!mid)
+    {
+        fprintf(stderr, "\tnative: native TestFunction: GetStaticMethodID for 'test_java_func2' failed\n");
+        return;
+    }
+    env->CallVoidMethod(obj, mid);
+    return;
+}
+
+extern "C" JNIEXPORT void JNICALL Java_ncai_funcs_ResumeThread01_TestFunction1
+  (JNIEnv *env, jobject obj)
+{
+    fprintf(stderr, "thread - native TestFunction1\n");
+    Test1(env, obj);
+
+    jclass clazz = env->GetObjectClass(obj);
+    if (!clazz)
+    {
+        fprintf(stderr, "\tnative: native TestFunction1: GetObjectClass failed\n");
+        return;
+    }
+
+    jmethodID mid = env->GetStaticMethodID(clazz, "sleep", "(J)V");
+    if (!mid)
+    {
+        fprintf(stderr, "\tnative: native TestFunction1: GetStaticMethodID for 'sleep' failed\n");
+        return;
+    }
+
+    g_resume_agent_thread = 1;
+    while(g_stop_thread)
+    {
+        SLEEP_UNIVERSAL(100);
+//        env->CallStaticVoidMethod(clazz, mid, 500);
+    }
+
+    counter++;
+    return;
+}
+
+void JNICALL ThreadStart(jvmtiEnv *jvmti_env,
+            JNIEnv* jni_env,
+            jthread thread)
+{
+    jvmtiPhase phase;
+    jvmtiError result;
+    jvmtiThreadInfo tinfo;
+
+    result = jvmti_env->GetPhase(&phase);
+    if (result != JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE)
+        return;
+
+    result = jvmti_env->GetThreadInfo(thread, &tinfo);
+    if (result != JVMTI_ERROR_NONE)
+        return;
+
+    if (strcmp(tinfo.name, "java_thread") != 0)
+        return;
+
+    printf("ThreadStart: java_thread\n");
+    g_thread_jthread = jni_env->NewGlobalRef(thread);
+}
+
+/* *********************************************************************** */
+
+JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD)
+{
+
+    Callbacks CB;
+    CB.cbThreadStart = &ThreadStart;
+    check_AGENT_ONLOAD;
+    jvmtiEvent events[] = { JVMTI_EVENT_EXCEPTION, JVMTI_EVENT_THREAD_START, JVMTI_EVENT_VM_DEATH };
+    cb_exc;
+    cb_death;
+    return func_for_Agent_OnLoad(vm, options, reserved, &CB,
+        events, sizeof(events)/sizeof(jvmtiEvent), test_case_name, DEBUG_OUT);
+}
+
+/* *********************************************************************** */
+
+void JNICALL callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+                               jthread thread, jmethodID method,
+                               jlocation location, jobject exception,
+                               jmethodID catch_method, jlocation catch_location)
+{
+    check_EXCPT;
+    if (flag) return;
+
+    /*
+     * Function separate all other exceptions in all other method
+     */
+    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
+                "special_method", DEBUG_OUT)) return;
+
+    flag = true;
+    util = true;
+
+    fprintf(stderr, "agent... \n");
+
+    ////////////////////ncai env get
+    jvmtiError err;
+    ncaiError ncai_err;
+
+    jvmtiExtensionFunctionInfo* ext_info = NULL;
+    jint ext_count = 0;
+
+    err = jvmti_env->GetExtensionFunctions(&ext_count, &ext_info);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    fprintf(stderr, "agent... \n");
+    if (ext_count == 0 || ext_info == NULL)
+    {
+        fprintf(stderr, "test_function: GetExtensionFunctions() returned no extensions\n");
+        test = false;
+        return;
+    }
+
+    jvmtiExtensionFunction get_ncai_func = NULL;
+
+    fprintf(stderr, "agent... \n");
+    for (int k = 0; k < ext_count; k++)
+    {
+        if (strcmp(ext_info[k].id, "org.apache.harmony.vm.GetExtensionEnv") == 0)
+        {
+            get_ncai_func = ext_info[k].func;
+            break;
+        }
+    }
+
+    fprintf(stderr, "agent... \n");
+    if (get_ncai_func == NULL)
+    {
+        fprintf(stderr, "test_function: GetNCAIEnvironment() nas not been found among JVMTI extensions\n");
+        test = false;
+        return;
+    }
+
+    ncaiEnv* ncai_env = NULL;
+
+    fprintf(stderr, "agent... \n");
+    err = get_ncai_func(jvmti_env, &ncai_env, NCAI_VERSION_1_0);
+
+    if (err != JVMTI_ERROR_NONE)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned error: %d, '%s'\n",
+            err, get_jvmti_eror_text(err));
+        test = false;
+        return;
+    }
+
+    if (ncai_env == NULL)
+    {
+        fprintf(stderr, "test_function: get_ncai_func() returned NULL environment\n");
+        test = false;
+        return;
+    }
+    fprintf(stderr, "agent... \n");
+    ///////////////////////////////////
+    ncaiThread ncai_thread;
+
+    fprintf(stderr, "calling ncai->GetThreadHandle()...\n");
+    ncai_err = ncai_env->GetThreadHandle(g_thread_jthread, &ncai_thread);
+    if (ncai_err != NCAI_ERROR_NONE)
+    {
+        fprintf(stderr, "ncai->GetThreadHandle() returned error: %d", ncai_err);
+        test = false;
+        return;
+    }
+
+
+    fprintf(stderr, "counter... %d\n", counter);
+
+    while (!g_resume_agent_thread) // Waiting for resume signal from Test3
+        SLEEP_UNIVERSAL(100);
+
+    g_resume_agent_thread = 0;
+
+    test = CheckResume(ncai_env, ncai_thread);
+
+    g_stop_thread = 1; // Resume execution of java_thread in Test3
+
+    while (!g_resume_agent_thread) // Waiting for resume signal from TestFunction1
+        SLEEP_UNIVERSAL(100);
+
+    g_resume_agent_thread = 0;
+
+    test = test && CheckResume(ncai_env, ncai_thread);
+
+    g_stop_thread = 0; // Resume execution of java_thread in TestFunction1
+
+    while (!g_resume_agent_thread) // Waiting for resume signal from test_java_func3
+        SLEEP_UNIVERSAL(100);
+
+    g_resume_agent_thread = 0;
+
+    test = test && CheckResume(ncai_env, ncai_thread);
+
+    g_stop_thread = 1; // Resume execution of java_thread in test_java_func3
+
+    while (!g_resume_agent_thread) // Waiting for resume signal from test_java_func3
+        SLEEP_UNIVERSAL(100);
+
+    if(counter != 3)
+        test = false;
+}
+
+void JNICALL callbackVMDeath(prms_VMDEATH)
+{
+    check_VMDEATH;
+    func_for_callback_VMDeath(jni_env, jvmti_env, test_case_name, test, util);
+}
+
+/* *********************************************************************** */
+
+void Test1(JNIEnv *env, jobject obj)
+{
+    if(!no_opt)
+        Test1(env, obj);
+
+    fprintf(stderr, "thread - pure native Test1\n");
+    return Test2(env, obj);
+}
+
+void Test2(JNIEnv *env, jobject obj)
+{
+    if(!no_opt)
+        Test2(env, obj);
+
+    fprintf(stderr, "thread - pure native Test2\n");
+    return Test3(env, obj);
+}
+
+void Test3(JNIEnv *env, jobject obj)
+{
+    if(!no_opt)
+        Test3(env, obj);
+
+    fprintf(stderr, "thread - pure native Test3\n");
+    jclass clazz = env->GetObjectClass(obj);
+    if (!clazz)
+    {
+        fprintf(stderr, "\tnative: pure native Test3: GetObjectClass failed\n");
+        return;
+    }
+
+    jmethodID mid = env->GetStaticMethodID(clazz, "sleep", "(J)V");
+    if (!mid)
+    {
+        fprintf(stderr, "\tnative: pure native Test3: GetStaticMethodID for 'sleep' failed\n");
+        return;
+    }
+
+    g_resume_agent_thread = 1;
+    while(!g_stop_thread)
+    {
+        SLEEP_UNIVERSAL(100);
+//        env->CallStaticVoidMethod(clazz, mid, 500);
+    }
+
+    counter++;
+    return;
+}
+
+bool CheckResume(ncaiEnv *ncai_env, ncaiThread ncai_thread)
+{
+    bool ret = true;
+    for (int i = 0; i < 40; i++)
+    {
+        fprintf(stderr, ".");
+        ncaiError ncai_err = ncai_env->SuspendThread(ncai_thread);
+        if (ncai_err != NCAI_ERROR_NONE)
+        {
+            fprintf(stderr, "ncai->SuspendThread() returned error: %d,\n", ncai_err);
+            ret = false;
+            break;
+        }
+
+        fprintf(stderr, "-");
+        ncai_err = ncai_env->ResumeThread(ncai_thread);
+        if (ncai_err != NCAI_ERROR_NONE)
+        {
+            fprintf(stderr, "ncai->ResumeThread() returned error: %d,\n", ncai_err);
+            ret = false;
+            break;
+        }
+
+        fprintf(stderr, "+");
+        ncai_err = ncai_env->ResumeThread(ncai_thread);
+        if (ncai_err == NCAI_ERROR_NONE)
+        {
+            fprintf(stderr, "ncai->ResumeThread() returned wrong error: %d,\n", ncai_err);
+            ret = false;
+            break;
+        }
+    }
+
+    fprintf(stderr, "\n");
+
+    if (!ret)
+        ncai_env->TerminateThread(ncai_thread);
+
+    return ret;
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/SuspendResumeThread/ResumeThread01/ResumeThread01.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/SuspendResumeThread/ResumeThread01/ResumeThread01.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/SuspendResumeThread/ResumeThread01/ResumeThread01.java?rev=597138&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/SuspendResumeThread/ResumeThread01/ResumeThread01.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/SuspendResumeThread/ResumeThread01/ResumeThread01.java Wed Nov 21 08:29:40 2007
@@ -0,0 +1,75 @@
+package ncai.funcs;
+
+/**
+ * @author Petr Ivanov
+ * @version $Revision: 1.1.1.1 $
+ *
+ */
+public class ResumeThread01 extends Thread{
+    public native void TestFunction();
+    public native void TestFunction1();
+    public static native boolean stopsignal();
+    public static native void resumeagent();
+    public static native void increment();
+
+    static boolean NoLibrary = false;
+    static {
+        try{
+            System.loadLibrary("ResumeThread01");
+        }
+        catch(Throwable e){
+            NoLibrary = true;
+        }
+    }
+
+    ResumeThread01(String name)
+    {
+        super(name);
+    }
+
+    static public void main(String args[]) {
+        if(NoLibrary) return;
+        new ResumeThread01("java_thread").start();
+        special_method();
+    }
+
+    public void test_java_func1(){
+        System.out.println("thread - java func1\n");
+        TestFunction();
+    }
+
+    public void test_java_func2(){
+        System.out.println("thread - java func2\n");
+        test_java_func3();
+    }
+
+    public void test_java_func3(){
+        System.out.println("thread - java func3\n");
+        TestFunction1();
+        resumeagent();
+        while(!stopsignal())
+        {
+            try {
+                sleep(100, 0); // milliseconds
+            } catch (java.lang.InterruptedException ie) {}
+        }
+        increment();
+        resumeagent();
+    }
+
+    static public void special_method() {
+        /*
+         * Transfer control to native part.
+         */
+        try {
+            throw new InterruptedException();
+        } catch (Throwable tex) { }
+    }
+
+    public void run() {
+        System.out.println("thread - java run\n");
+        test_java_func1();
+    }
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/tests/ncai/funcs/SuspendResumeThread/ResumeThread01/ResumeThread01.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message