PR debug/57232
[official-gcc.git] / libjava / testsuite / libjava.jvmti / natgetallthreads.cc
blob9c4d69cde74adedafcff932e5946e515396822ca
1 #include <gcj/cni.h>
3 #include <jvm.h>
4 #include <jvmti.h>
5 #include <stdio.h>
7 #include "jvmti-int.h"
8 #include "getallthreads.h"
10 void
11 getallthreads::natPlaceholder ()
13 ex_frames--;
15 if (ex_frames > 0)
17 if ((getallthreads::thread_num % 2) == 0)
18 placeholder ();
19 else
20 natPlaceholder ();
22 else
23 natRunner ();
26 void
27 getallthreads::natRunner ()
29 done = true;
30 while (done)
31 yield ();
34 void
35 getallthreads::do_getallthreads_tests ()
37 jvmtiEnv *env;
38 JavaVM *vm = _Jv_GetJavaVM ();
39 vm->GetEnv (reinterpret_cast<void **> (&env), JVMTI_VERSION_1_0);
41 jint num_threads;
42 jthread *thread_arr;
44 jvmtiError jerr = env->GetAllThreads (&num_threads, &thread_arr);
45 if (jerr != JVMTI_ERROR_NONE)
47 printf ("Test Failed, JVMTI Error!\n");
48 return;
50 env->Deallocate (reinterpret_cast<unsigned char *> (thread_arr));
52 for (int i = 0; i < num_threads; i++)
53 printf ("Found thread %d\n", i+1 );