31 #include <linux/unistd.h>
34 #include <sys/types.h>
55 #include "threads/mutex.h"
59 #include "native/include/java_io_PrintStream.h"
60 #include "native/include/java_io_InputStream.h"
61 #include "native/include/java_lang_Cloneable.h"
62 #include "native/include/java_lang_ThreadGroup.h"
63 #include "native/include/java_lang_VMObject.h"
64 #include "native/include/java_lang_VMSystem.h"
65 #include "native/include/java_lang_VMClass.h"
67 #include "boehm-gc/include/gc.h"
69 #if defined(ENABLE_THREADS)
114 #define CHECK_PHASE_START if (!(false
115 #define CHECK_PHASE(chkphase) || (phase == chkphase)
116 #define CHECK_PHASE_END )) return JVMTI_ERROR_WRONG_PHASE
117 #define CHECK_CAPABILITY(env,CAP) if(((environment*) \
118 env)->capabilities.CAP == 0) \
119 return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
120 #define CHECK_THREAD_IS_ALIVE(t) if(check_thread_is_alive(t) == \
121 JVMTI_ERROR_THREAD_NOT_ALIVE) \
122 return JVMTI_ERROR_THREAD_NOT_ALIVE;
149 fprintf(stderr,
"execcallback called (event: %d)\n",e);
164 ((jvmtiEventClassFileLoadHook)ec) (data->
jvmti_env,
202 ((jvmtiEventNativeMethodBind)ec) (data->
jvmti_env, jni_env,
214 ((jvmtiEventDynamicCodeGenerated)ec) (data->
jvmti_env,
297 ((jvmtiEventCompiledMethodLoad)ec) (data->
jvmti_env,
307 ((jvmtiEventCompiledMethodUnload)ec) (data->
jvmti_env,
315 ((jvmtiEventDataDumpRequest)ec) (data->
jvmti_env);
370 while (env != NULL) {
374 while (evm != NULL) {
435 if(event_thread != NULL) {
445 switch (event_type) {
503 if (event_thread != NULL) {
515 while (ll->
next != NULL) {
551 if ((threads_count_ptr == NULL) || (threads_ptr == NULL))
558 heap_allocate(
sizeof(
jthread*)* (*threads_count_ptr),
true,NULL);
561 (*threads_ptr)[
i] = threads[
i]->o.thread;
634 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
654 #if defined(ENABLE_THREADS)
687 info_ptr->
priority=(jint)th->priority;
688 info_ptr->
is_daemon=(jboolean)th->daemon;
693 info_ptr->
name=(
char*)heap_allocate(
sizeof(
char)*(
UTF_SIZE(name)+1),
true,NULL);
711 java_objectheader **om;
712 lock_record_pool_t* lrp;
720 if ((owned_monitors_ptr == NULL)||(owned_monitor_count_ptr == NULL))
723 if (thread == NULL) {
733 #if defined(ENABLE_THREADS)
735 om=
MNEW(java_objectheader*,size);
737 mutex_lock(&lock_global_pool_lock);
738 lrp=lock_global_pool;
741 while (lrp != NULL) {
743 for (j=0; j<lrp->header.size; j++) {
746 if(lrp->lr[j].owner == t) {
748 MREALLOC(om, java_objectheader*, size, size * 2);
751 om[
i] = lrp->lr[j].obj;
755 lrp=lrp->header.next;
758 mutex_unlock(&lock_global_pool_lock);
760 *owned_monitors_ptr =
761 heap_allocate(
sizeof(java_objectheader*) * i,
true, NULL);
762 memcpy(*owned_monitors_ptr, om, i *
sizeof(java_objectheader*));
763 MFREE(om, java_objectheader*, size);
765 *owned_monitor_count_ptr =
i;
783 lock_record_pool_t* lrp;
785 lock_waiter_t* waiter;
795 if (thread == NULL) {
805 #if defined(ENABLE_THREADS)
807 mutex_lock(&lock_global_pool_lock);
809 lrp=lock_global_pool;
812 while ((lrp != NULL) && (*monitor_ptr == NULL)) {
814 for (j=0; j<lrp->header.size; j++) {
816 waiter = lrp->lr[j].waiters;
817 while (waiter != NULL)
820 if(waiter->waiter == t) {
821 *monitor_ptr=lrp->lr[j].obj;
825 lrp=lrp->header.next;
828 mutex_unlock(&lock_global_pool_lock);
836 jvmtiStartFunction
sf;
857 const void *
arg, jint priority)
859 pthread_attr_t threadattr;
860 struct sched_param sp;
878 rap.arg = (
void*)arg;
881 #if defined(ENABLE_THREADS)
882 pthread_attr_init(&threadattr);
883 pthread_attr_setdetachstate(&threadattr, PTHREAD_CREATE_DETACHED);
885 sp.__sched_priority = sched_get_priority_min(SCHED_FIFO);
888 sp.__sched_priority = sched_get_priority_min(SCHED_FIFO);
890 pthread_attr_setschedparam(&threadattr,&sp);
912 jint threads_count_ptr;
921 if ((groups_ptr == NULL) || (group_count_ptr == NULL))
924 #if defined(ENABLE_THREADS)
930 for (i=0;i<threads_count_ptr;i++){
931 if (threads_ptr[i].o.thread->group == NULL) {
938 while((j<x)&&(tg[j]!=ttgp)) {
952 *groups_ptr = heap_allocate(
sizeof(
jthreadGroup*)*x,
true,NULL);
956 *group_count_ptr = x;
977 java_lang_ThreadGroup* grp;
987 grp = (java_lang_ThreadGroup*)group;
991 (
jclass)grp->header.vftbl->class,
992 (java_lang_Cloneable*) &grp->parent);
996 info_ptr->
name=heap_allocate(size*
sizeof(
char),
true,NULL);
997 strncpy(info_ptr->
name,name,size);
999 info_ptr->
is_daemon= (jboolean)grp->daemon_flag;
1013 jint * thread_count_ptr,
jthread ** threads_ptr,
1016 java_lang_ThreadGroup* tgp;
1022 if ((thread_count_ptr == NULL) || (threads_ptr == NULL) ||
1023 (group_count_ptr == NULL) || (groups_ptr == NULL))
1029 tgp = (java_lang_ThreadGroup*)group;
1031 *thread_count_ptr = (jint)tgp->threads->elementCount;
1034 heap_allocate(
sizeof(
jthread)*(*thread_count_ptr),
true,NULL);
1036 memcpy(*threads_ptr, &tgp->threads->elementData,
1037 (*thread_count_ptr)*
sizeof(java_objectarray*));
1039 *group_count_ptr = (jint) tgp->groups->elementCount;
1042 heap_allocate(
sizeof(
jthreadGroup)*(*group_count_ptr),
true,NULL);
1044 memcpy(*groups_ptr, &tgp->threads->elementData,
1061 if (thread == NULL) {
1063 *trace = stacktrace_create(t);
1090 stacktracebuffer* trace;
1097 if (thread != NULL){
1112 *count_ptr = trace->used;
1140 *thread_state_ptr = 0;
1141 #if defined(ENABLE_THREADS)
1142 if((th->vmThread == NULL)&&(th->group == NULL)) {
1178 jmethodID * method_ptr,
jlocation * location_ptr)
1188 if (thread == NULL) {
1200 if ((method_ptr == NULL)&&(location_ptr == NULL))
1206 while ((sfi != NULL) && (i<
depth)) {
1213 *method_ptr=(jmethodID)sfi->
code->
m;
1234 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
1253 log_text (
"JVMTI-Call: TBD-OPTIONAL IMPLEMENT ME!!!");
1271 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1290 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1310 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1323 jdouble * value_ptr)
1330 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1350 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1370 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1390 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1410 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1430 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1452 if ((name == NULL) || (monitor_ptr == NULL))
1455 #if defined(ENABLE_THREADS)
1458 log_text (
"CreateRawMonitor not supported");
1482 #if defined(ENABLE_THREADS)
1490 log_text (
"DestroyRawMonitor not supported");
1509 #if defined(ENABLE_THREADS)
1512 log_text (
"RawMonitorEnter not supported");
1531 #if defined(ENABLE_THREADS)
1538 log_text (
"RawMonitorExit not supported");
1557 #if defined(ENABLE_THREADS)
1567 log_text (
"RawMonitorWait not supported");
1586 #if defined(ENABLE_THREADS)
1593 log_text (
"RawMonitorNotify not supported");
1612 #if defined(ENABLE_THREADS)
1619 log_text (
"RawMonitorNotifyAll not supported");
1641 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1660 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1679 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1698 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1717 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1736 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
1755 *mem_ptr = heap_allocate(
sizeof(size),
true,NULL);
1756 if (*mem_ptr == NULL)
1799 if (signature_ptr != NULL) {
1800 *signature_ptr = (
char*)
1801 heap_allocate(
sizeof(
char) *
1807 if (generic_ptr!= NULL)
1808 *generic_ptr = NULL;
1831 if (status_ptr == NULL)
1874 if ((klass == NULL)||(source_name_ptr == NULL))
1879 *source_name_ptr = (
char*) heap_allocate(
sizeof(
char)*
size,
true,NULL);
1881 memcpy(*source_name_ptr,(UTF_TEXT((
classinfo*)klass)->sourcefile), size);
1882 (*source_name_ptr)[
size]=
'\0';
1902 if (modifiers_ptr == NULL)
1922 jmethodID ** methods_ptr)
1931 if ((klass == NULL)||(methods_ptr == NULL)||(method_count_ptr == NULL))
1938 *methods_ptr = (jmethodID*)
1939 heap_allocate(
sizeof(jmethodID) * (*method_count_ptr),
true,NULL);
1941 for (i=0; i<*method_count_ptr;i++)
1957 jfieldID ** fields_ptr)
1964 if ((klass == NULL)||(fields_ptr == NULL)||(field_count_ptr == NULL))
1968 *fields_ptr = (jfieldID*)
1969 heap_allocate(
sizeof(jfieldID) * (*field_count_ptr),
true,NULL);
1971 memcpy (*fields_ptr, ((
classinfo*)klass)->fields,
1972 sizeof(jfieldID) * (*field_count_ptr));
1986 jint * interface_count_ptr,
1987 jclass ** interfaces_ptr)
1998 if ((interfaces_ptr == NULL) || (interface_count_ptr == NULL))
2005 *interface_count_ptr = (jint)((
classinfo*)
klass)->interfacescount;
2006 *interfaces_ptr = heap_allocate(
sizeof(
jclass*) * (*interface_count_ptr),
true,NULL);
2008 interfaces = ((
classinfo*)klass)->interfaces;
2009 for (i=0; i<*interface_count_ptr; i++) {
2010 if (interfaces[i].is_classref())
2013 tmp = interfaces[
i].
cls;
2015 *interfaces_ptr[
i]=
tmp;
2036 if ((klass == NULL)||(is_interface_ptr == NULL))
2058 if (is_array_class_ptr == NULL)
2061 *is_array_class_ptr = ((
classinfo*)klass)->vftbl->arraydesc != NULL;
2082 if ((klass == NULL)||(classloader_ptr == NULL))
2130 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
2144 char **name_ptr,
char **signature_ptr,
char **generic_ptr)
2160 if (name_ptr != NULL) {
2162 *name_ptr = (
char*) heap_allocate(
sizeof(
char)*
size,
true,NULL);
2166 if (signature_ptr != NULL) {
2168 *signature_ptr = (
char*) heap_allocate(
sizeof(
char)*
size,
true,NULL);
2173 if (generic_ptr != NULL)
2174 *generic_ptr = NULL;
2190 jclass * declaring_class_ptr)
2221 jint * modifiers_ptr)
2238 *modifiers_ptr = ((
fieldinfo*)field)->flags;
2252 jboolean * is_synthetic_ptr)
2260 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
2274 char **signature_ptr,
char **generic_ptr)
2286 if (name_ptr != NULL) {
2288 heap_allocate(
sizeof(
char) * (
UTF_SIZE(m->
name)+1),
true,NULL);
2292 if (signature_ptr != NULL) {
2293 *signature_ptr = (
char*)
2298 if (generic_ptr != NULL) {
2300 *generic_ptr = NULL;
2315 jclass * declaring_class_ptr)
2322 if ((method == NULL) || (declaring_class_ptr == NULL))
2345 if ((method == NULL) || (modifiers_ptr == NULL))
2348 *modifiers_ptr = (jint) (((
methodinfo*)method)->flags);
2370 if ((method == NULL)||(max_ptr == NULL))
2397 if ((method == NULL)||(size_ptr == NULL))
2427 if ((method == NULL) || (entry_count_ptr == NULL) || (table_ptr == NULL))
2433 if (((
methodinfo*)method)->linenumbers == NULL)
2441 for (i=0; i < *entry_count_ptr; i++) {
2444 (*table_ptr)[
i].line_number =
2477 if ((start_location_ptr == NULL) || (end_location_ptr == NULL))
2487 fprintf(stderr,
"GetMethodLocation *** XXX todo \n");
2509 jint * entry_count_ptr,
2517 log_text (
"JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
2532 jint * bytecode_count_ptr,
unsigned char **bytecodes_ptr)
2542 if ((method == NULL) || (bytecode_count_ptr == NULL) ||
2546 *bytecodes_ptr = (
unsigned char*)heap_allocate(m->
jcodelength,
true,NULL);
2568 if ((method == NULL)||(is_native_ptr == NULL))
2589 jboolean * is_synthetic_ptr)
2597 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
2615 if (class_count_ptr == NULL)
2618 if (classes_ptr == NULL)
2621 classcache_jvmti_GetLoadedClasses(class_count_ptr, classes_ptr);
2636 jint * class_count_ptr,
jclass ** classes_ptr)
2638 log_text(
"GetClassLoaderClasses called");
2644 if ((class_count_ptr == NULL) || (classes_ptr == NULL))
2668 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
2690 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
2724 memcpy(capabilities_ptr, &(((
environment*) env)->capabilities),
sizeof(JVMTI_Capabilities));
2738 char **source_debug_extension_ptr)
2746 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
2759 jboolean * is_obsolete_ptr)
2767 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
2793 if ((request_list == NULL) || (results == NULL))
2798 for (i=0;i<request_count;i++) {
2799 if (request_list[i] == me)
2805 if (suspendme != -1)
2806 results[suspendme]=
SuspendThread(env, request_list[suspendme]);
2830 if ((request_list == NULL) || (results == NULL))
2833 for (i=0;i<request_count;i++)
2851 stacktracebuffer* trace;
2859 if (thread != NULL){
2866 if((count_ptr == NULL)||(frame_buffer == NULL))
2877 if ((trace->used >= start_depth) || ((trace->used * -1) > start_depth))
2880 for (i=start_depth, j=0;i<trace->used;i++,j++) {
2881 frame_buffer[j].
method = (jmethodID)trace->entries[i].method;
2901 jint max_frame_count,
2911 if ((stack_info_ptr == NULL)||(thread_list == NULL))
2919 heap_allocate(
sizeof(
jvmtiStackInfo) * thread_count,
true, NULL);
2921 for(i=0; i<thread_count; i++) {
2922 (*stack_info_ptr)[
i].
thread=thread_list[
i];
2923 GetThreadState(env,thread_list[i],&((*stack_info_ptr)[i].state));
2924 (*stack_info_ptr)[
i].frame_buffer =
2925 heap_allocate(
sizeof(
jvmtiFrameInfo) * max_frame_count,
true,NULL);
2927 (*stack_info_ptr)[i].frame_buffer,
2928 &((*stack_info_ptr)[i].frame_count));
2960 max_frame_count, stack_info_ptr);
2995 while ((tls->
thread != thread) && (tls != NULL)) {
3001 *data_ptr = tls->
data;
3034 if (env->
tls == NULL) {
3038 while ((tls->
thread != thread) && (tls->
next != NULL)) {
3041 if (tls->
thread != thread) {
3048 tls->
data = (
void*)data;
3052 while (pre->
next == tls) pre = pre->
next;
3074 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3093 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3125 jvmtiObjectReferenceCallback
3126 object_reference_callback,
3134 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3148 jvmtiStackReferenceCallback
3150 jvmtiObjectReferenceCallback
3158 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3171 jvmtiHeapObjectCallback heap_object_callback,
3179 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3193 jvmtiHeapObjectCallback
3201 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3214 jint * count_ptr,
jobject ** object_result_ptr,
3215 jlong ** tag_result_ptr)
3222 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3282 jint size_of_callbacks)
3292 if (callbacks == NULL) {
3297 memcpy (&(((
environment* )env)->callbacks),callbacks,size_of_callbacks);
3337 if ((extension_count_ptr == NULL)||(extensions == NULL))
3341 *extension_count_ptr = 0;
3362 if ((extension_count_ptr == NULL)||(extensions == NULL))
3366 *extension_count_ptr = 0;
3380 jvmtiExtensionEvent callback)
3405 if (tenvs != cacao_env) {
3406 while (tenvs->
next != cacao_env) {
3407 tenvs = tenvs->
next;
3413 cacao_env->
env=NULL;
3420 jtls = cacao_env->
tls;
3421 while (jtls != NULL) {
3426 cacao_env->
tls = NULL;
3442 #define COPY_RESPONSE(name_ptr,str) *name_ptr = (char*) heap_allocate(sizeof(str),true,NULL); \
3443 memcpy(*name_ptr, &str, sizeof(str)); \
3463 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_INVALID_ENVIRONMENT");
3471 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_THREAD_NOT_SUSPENDED");
3517 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_MUST_POSSESS_CAPABILITY");
3519 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_INVALID_THREAD_GROUP");
3527 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_UNSUPPORTED_VERSION");
3529 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_INVALID_CLASS_FORMAT");
3531 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION");
3533 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED");
3535 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED");
3539 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED");
3541 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED");
3545 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED");
3547 COPY_RESPONSE (name_ptr,
"JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED");
3578 jmethodID mid, moremid;
3579 classinfo *sysclass, *propclass, *enumclass;
3580 java_objectheader *sysprop, *keys, *obj;
3589 if ((count_ptr == NULL) || (property_ptr == NULL))
3594 if (!sysclass) throw_main_exception_exit();
3599 if (!mid) throw_main_exception_exit();
3603 if (!sysprop) throw_main_exception_exit();
3605 propclass = sysprop->
vftbl->class;
3610 if (!mid) throw_main_exception_exit();
3614 *property_ptr = heap_allocate(
sizeof(
char*) * (*count_ptr) ,
true,NULL);
3619 if (!mid) throw_main_exception_exit();
3622 enumclass = keys->
vftbl->class;
3627 if (!moremid) throw_main_exception_exit();
3632 if (!mid) throw_main_exception_exit();
3638 *property_ptr[
i] = heap_allocate(
sizeof(
char*) * strlen (ch),
true,NULL);
3639 memcpy(*property_ptr[i], ch, strlen (ch));
3640 MFREE(ch,
char,strlen(ch)+1);
3659 java_objectheader *sysprop, *obj;
3667 if ((value_ptr == NULL) || (property == NULL))
3671 if (!sysclass) throw_main_exception_exit();
3676 if (!mid) throw_main_exception_exit();
3680 propclass = sysprop->
vftbl->class;
3685 if (!mid) throw_main_exception_exit();
3692 *value_ptr = heap_allocate(
sizeof(
char*) * strlen (ch),
true,NULL);
3693 memcpy(*value_ptr, ch, strlen (ch));
3694 MFREE(ch,
char,strlen(ch)+1);
3711 java_objectheader *sysprop;
3721 if (!sysclass) throw_main_exception_exit();
3726 if (!mid) throw_main_exception_exit();
3730 propclass = sysprop->
vftbl->class;
3735 if (!mid) throw_main_exception_exit();
3777 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3797 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3816 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3833 log_text (
"JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
3870 if (gettimeofday (&tp, NULL) == -1)
3873 *nanos_ptr = (jlong) tp.tv_sec;
3875 *nanos_ptr += (tp.tv_usec / 1000);
3897 memcpy(capabilities_ptr, &JVMTI_Capabilities,
sizeof(JVMTI_Capabilities));
3903 #define CHECK_ADD_CAPABILITY(env,CAN) \
3904 if (capabilities_ptr->CAN == 1) { \
3905 if (JVMTI_Capabilities.CAN == 0) \
3906 return JVMTI_ERROR_NOT_AVAILABLE; \
3908 env->capabilities.CAN = 1; \
3928 if ((env == NULL) || (capabilities_ptr == NULL))
3972 #define CHECK_DEL_CAPABILITY(env,CAN) \
3973 if (capabilities_ptr->CAN == 1) \
3974 env->capabilities.CAN = 0;
3993 if ((env == NULL) || (capabilities_ptr == NULL))
4051 log_text (
"GetAvailableProcessors IMPLEMENT ME!!!");
4053 *processor_count_ptr = 1;
4069 *data_ptr = ((
environment*)env)->EnvironmentLocalStorage;
4086 ((
environment*)env)->EnvironmentLocalStorage = (
void*) data;
4110 ln = strlen(bootclasspath) + strlen(
":") + strlen(segment);
4111 tmp_bcp =
MNEW(
char, ln);
4112 strcat(tmp_bcp, bootclasspath);
4113 strcat(tmp_bcp,
":");
4114 strcat(tmp_bcp, segment);
4115 MFREE(bootclasspath,
char,ln);
4116 bootclasspath = tmp_bcp;
4168 *size_ptr = ((java_objectheader*)
object)->vftbl->class->instancesize;
4187 #if defined(ENABLE_THREADS)
4389 fprintf (stderr,
"set JVMTI phase %d\n",p);
4415 log_text(
"wrong jvmti phase to be set");
4433 envs = heap_allocate(
sizeof(
environment),
true,NULL);
4437 while (env->
next != NULL) env = env->
next;
4471 len = strlen(opt_arg);
4475 while ((opt_arg[i] !=
'=') && (i < len))
4481 arg = &opt_arg[i + 1];
4488 *libname =
GCMNEW(
char, i);
4490 strcpy(*libname, opt_arg);
4495 len = strlen(
"lib") + i + strlen(
".so") + strlen(
"0");
4497 *libname =
GCMNEW(
char, len);
4499 strcpy(*libname,
"lib");
4500 strcat(*libname, opt_arg);
4501 strcat(*libname,
".so");
4506 if (!(*handle = lt_dlopen(*libname))) {
4507 fprintf(stderr,
"Could not find agent library: %s (%s)\n",*libname,lt_dlerror());
4512 if (!(onload = lt_dlsym(*handle,
"Agent_OnLoad"))) {
4513 fprintf(stderr,
"unable to load Agent_OnLoad function in %s (%s)\n",*libname,lt_dlerror());
4518 unload = lt_dlsym(*handle,
"Agent_Unload");
4521 ((JNIEXPORT jint JNICALL (*) (
JavaVM *vm,
char *options,
void *reserved))
4522 onload) ((
JavaVM *) _Jv_jvm,
arg, NULL);
4524 if (retval != 0) exit (retval);
static jvmtiError SetLocalObject(jvmtiEnv *env, jthread thread, jint depth, jint slot, jobject value)
static jvmtiError RunAgentThread(jvmtiEnv *env, jthread thread, jvmtiStartFunction proc, const void *arg, jint priority)
#define JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT
bool builtin_instanceof(java_handle_t *o, classinfo *c)
jlong jlong jlong jlong jint jmethodID jint slot
static jvmtiError GetMethodModifiers(jvmtiEnv *env, jmethodID method, jint *modifiers_ptr)
static jvmtiError GetObjectsWithTags(jvmtiEnv *env, jint tag_count, const jlong *tags, jint *count_ptr, jobject **object_result_ptr, jlong **tag_result_ptr)
#define GCMNEW(type, num)
static jvmtiError IsMethodNative(jvmtiEnv *env, jmethodID method, jboolean *is_native_ptr)
classinfo * class_java_lang_ThreadGroup
struct JNINativeInterface jniNativeInterface
static jvmtiError IsArrayClass(jvmtiEnv *env, jclass klass, jboolean *is_array_class_ptr)
jlong jlong jlong jlong jint void * user_data
JNIEnv jthread jmethodID jlocation jclass jobject jfieldID field
JNIEXPORT jint JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, jobject obj)
void threads_thread_interrupt(threadobject *t)
const JNIInvokeInterface_ _Jv_JNIInvokeInterface
static jvmtiError GetExtensionEvents(jvmtiEnv *env, jint *extension_count_ptr, jvmtiExtensionEventInfo **extensions)
void jvmti_cacaodbgserver_quit()
static jvmtiError GetMethodLocation(jvmtiEnv *env, jmethodID method, jlocation *start_location_ptr, jlocation *end_location_ptr)
static jvmtiError NotifyFramePop(jvmtiEnv *env, jthread thread, jint depth)
static jvmtiError GetThreadState(jvmtiEnv *env, jthread thread, jint *thread_state_ptr)
void jvmti_set_phase(jvmtiPhase p)
static jvmtiError Allocate(jvmtiEnv *env, jlong size, unsigned char **mem_ptr)
Utf8String to_utf8() const
static jvmtiError GetLocalObject(jvmtiEnv *env, jthread thread, jint depth, jint slot, jobject *value_ptr)
static jvmtiError RedefineClasses(jvmtiEnv *env, jint class_count, const jvmtiClassDefinition *class_definitions)
classinfo * load_class_from_sysloader(Utf8String name)
static jvmtiError GetSourceDebugExtension(jvmtiEnv *env, jclass klass, char **source_debug_extension_ptr)
static jvmtiError SetLocalInt(jvmtiEnv *env, jthread thread, jint depth, jint slot, jint value)
#define JVMTI_CLASS_STATUS_PRIMITIVE
#define JVMTI_CLASS_STATUS_PREPARED
jvmtiThreadLocalStorage * next
static jvmtiError SetLocalFloat(jvmtiEnv *env, jthread thread, jint depth, jint slot, jfloat value)
static jvmtiError GetStackTrace(jvmtiEnv *env, jthread thread, jint start_depth, jint max_frame_count, jvmtiFrameInfo *frame_buffer, jint *count_ptr)
static jvmtiError GetThreadLocalStorage(jvmtiEnv *env, jthread thread, void **data_ptr)
static JavaString from_utf8(Utf8String)
static jvmtiError GetFieldModifiers(jvmtiEnv *env, jclass klass, jfieldID field, jint *modifiers_ptr)
static jvmtiError DisposeEnvironment(jvmtiEnv *env)
static jvmtiError SetEventCallbacks(jvmtiEnv *env, const jvmtiEventCallbacks *callbacks, jint size_of_callbacks)
jvmtiEventMode jvmtiEvent jthread event_thread
JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, jclass klass)
static jvmtiError InterruptThread(jvmtiEnv *env, jthread thread)
static struct jvmtiEnv_struct JVMTI_EnvTable
jthread const void * data
#define JVMTI_THREAD_STATE_SLEEPING
static jvmtiError DestroyRawMonitor(jvmtiEnv *env, jrawMonitorID monitor)
static jvmtiError PopFrame(jvmtiEnv *env, jthread thread)
jvmtiError SetThreadLocalStorage(jvmtiEnv *jenv, jthread thread, const void *data)
static jvmtiError GetThreadInfo(jvmtiEnv *env, jthread t, jvmtiThreadInfo *info_ptr)
static jvmtiError GetClassModifiers(jvmtiEnv *env, jclass klass, jint *modifiers_ptr)
bool lock_monitor_exit(java_handle_t *o)
static jvmtiError GetClassFields(jvmtiEnv *env, jclass klass, jint *field_count_ptr, jfieldID **fields_ptr)
#define COPY_RESPONSE(name_ptr, str)
jthread jvmtiThreadInfo * info_ptr
static jvmtiError StopThread(jvmtiEnv *env, jthread thread, jobject exception)
#define JVMTI_CLASS_STATUS_ARRAY
unsigned char * class_data
classinfo * load_class_bootstrap(Utf8String name)
jvmtiAddrLocationMap * map
static jvmtiError RawMonitorWait(jvmtiEnv *env, jrawMonitorID monitor, jlong millis)
JNIEnv jthread jclass klass
#define JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER
static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv *env, void **data_ptr)
static jvmtiError GetAvailableProcessors(jvmtiEnv *env, jint *processor_count_ptr)
jvmtiEventCallbacks callbacks
jvmtiThreadLocalStorage * tls
static jvmtiError SetEventNotificationMode(jvmtiEnv *env, jvmtiEventMode mode, jvmtiEvent event_type, jthread event_thread,...)
static jvmtiError ForceGarbageCollection(jvmtiEnv *env)
JNIEnv jclass jobject const char * name
static jvmtiError GetJLocationFormat(jvmtiEnv *env, jvmtiJlocationFormat *format_ptr)
classinfo * class_java_lang_Object
static jvmtiError GetMethodDeclaringClass(jvmtiEnv *env, jmethodID method, jclass *declaring_class_ptr)
static jvmtiError RelinquishCapabilities(jvmtiEnv *env, const jvmtiCapabilities *capabilities_ptr)
static jvmtiError IsInterface(jvmtiEnv *env, jclass klass, jboolean *is_interface_ptr)
static jvmtiError GetFieldDeclaringClass(jvmtiEnv *env, jclass klass, jfieldID field, jclass *declaring_class_ptr)
jlong jlong jlong * tag_ptr
JNIEnv jthread jobject jclass jlong size
static jvmtiError SetFieldAccessWatch(jvmtiEnv *env, jclass klass, jfieldID field)
static jvmtiError Deallocate(jvmtiEnv *env, unsigned char *mem)
void vm_shutdown()
Hook point before the VM is actually destroyed.
static jvmtiError CreateRawMonitor(jvmtiEnv *env, const char *name, jrawMonitorID *monitor_ptr)
jthread jvmti_get_current_thread()
static jvmtiError GetTime(jvmtiEnv *env, jlong *nanos_ptr)
static jvmtiError GetLocalLong(jvmtiEnv *env, jthread thread, jint depth, jint slot, jlong *value_ptr)
void(* functionptr)(void)
jvmtiEnv * jvmti_new_environment()
static jvmtiError SuspendThreadList(jvmtiEnv *env, jint request_count, const jthread *request_list, jvmtiError *results)
static jvmtiError check_thread_is_alive(jthread t)
static jvmtiError GetClassSignature(jvmtiEnv *env, jclass klass, char **signature_ptr, char **generic_ptr)
void lock_notify_all_object(java_handle_t *o)
jthreadGroup thread_group
JNINativeInterface_ _Jv_JNINativeInterface
jlong jlong jlong jlong jint depth
static jvmtiError GetMethodName(jvmtiEnv *env, jmethodID method, char **name_ptr, char **signature_ptr, char **generic_ptr)
JNIEnv jthread jmethodID jlocation jobject exception
static jvmtiError IterateOverReachableObjects(jvmtiEnv *env, jvmtiHeapRootCallback heap_root_callback, jvmtiStackReferenceCallback stack_ref_callback, jvmtiObjectReferenceCallback object_ref_callback, void *user_data)
static jvmtiError GetOwnedMonitorInfo(jvmtiEnv *env, jthread thread, jint *owned_monitor_count_ptr, jobject **owned_monitors_ptr)
jthread jobject * monitor_ptr
static jvmtiError GetThreadCpuTime(jvmtiEnv *env, jthread thread, jlong *nanos_ptr)
static jvmtiError GetLocalDouble(jvmtiEnv *env, jthread thread, jint depth, jint slot, jdouble *value_ptr)
static jvmtiError SuspendThread(jvmtiEnv *env, jthread thread)
void jvmti_fireEvent(genericEventData *data)
jboolean may_skip_backward
static jvmtiCapabilities JVMTI_Capabilities
JNIEXPORT jobject JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, jobject _this)
void jvmti_cacao_debug_init()
static jvmtiError RawMonitorNotify(jvmtiEnv *env, jrawMonitorID monitor)
static jvmtiError GenerateEvents(jvmtiEnv *env, jvmtiEvent event_type)
static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv *env, jvmtiTimerInfo *info_ptr)
JNIEnv jthread jmethodID method
static jvmtiError IsMethodSynthetic(jvmtiEnv *env, jmethodID method, jboolean *is_synthetic_ptr)
static jvmtiError ClearFieldAccessWatch(jvmtiEnv *env, jclass klass, jfieldID field)
Instruction::InstID tmp[]
static jvmtiError GetObjectMonitorUsage(jvmtiEnv *env, jobject object, jvmtiMonitorUsage *info_ptr)
#define JVMTI_THREAD_STATE_INTERRUPTED
static jvmtiError GetPotentialCapabilities(jvmtiEnv *env, jvmtiCapabilities *capabilities_ptr)
static jvmtiError GetSystemProperty(jvmtiEnv *env, const char *property, char **value_ptr)
static JNINativeMethod methods[]
static vm_calls_t callbacks
static jvmtiError GetSystemProperties(jvmtiEnv *env, jint *count_ptr, char ***property_ptr)
static jvmtiError GetAllThreads(jvmtiEnv *env, jint *threads_count_ptr, jthread **threads_ptr)
void lock_notify_object(java_handle_t *o)
static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv *env, const void *data)
classinfo * class_java_lang_Class
methodinfo * class_resolvemethod(classinfo *c, Utf8String name, Utf8String desc)
static jvmtiError GetFieldName(jvmtiEnv *env, jclass klass, jfieldID field, char **name_ptr, char **signature_ptr, char **generic_ptr)
#define CHECK_PHASE(chkphase)
#define CHECK_THREAD_IS_ALIVE(t)
jint jthread ** threads_ptr
jvmtiError jvmti_get_all_threads(jint *threads_count_ptr, threadobject ***threads_ptr)
static jvmtiError AddCapabilities(jvmtiEnv *env, const jvmtiCapabilities *capabilities_ptr)
#define JVMTI_CLASS_STATUS_ERROR
static Utf8String from_utf8(const char *, size_t)
static jvmtiError GetLocalFloat(jvmtiEnv *env, jthread thread, jint depth, jint slot, jfloat *value_ptr)
static jvmtiError GetSourceFileName(jvmtiEnv *env, jclass klass, char **source_name_ptr)
void utf_sprint_convert_to_latin1(char *buffer, Utf8String u)
static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv *env, jlong *nanos_ptr)
jboolean may_skip_forward
#define JVMTI_THREAD_STATE_WAITING
#define JVMTI_THREAD_STATE_IN_NATIVE
static jvmtiError GetExtensionFunctions(jvmtiEnv *env, jint *extension_count_ptr, jvmtiExtensionFunctionInfo **extensions)
static jvmtiError SetLocalLong(jvmtiEnv *env, jthread thread, jint depth, jint slot, jlong value)
#define JVMTI_THREAD_STATE_ALIVE
static jvmtiError GetLocalVariableTable(jvmtiEnv *env, jmethodID method, jint *entry_count_ptr, jvmtiLocalVariableEntry **table_ptr)
jvmtiCapabilities capabilities
#define JVMTI_THREAD_STATE_SUSPENDED
static jvmtiError GetObjectSize(jvmtiEnv *env, jobject object, jlong *size_ptr)
static jvmtiError IterateOverInstancesOfClass(jvmtiEnv *env, jclass klass, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, void *user_data)
static jvmtiError GetCapabilities(jvmtiEnv *env, jvmtiCapabilities *capabilities_ptr)
static jvmtiError SetLocalDouble(jvmtiEnv *env, jthread thread, jint depth, jint slot, jdouble value)
static jvmtiError GetPhase(jvmtiEnv *env, jvmtiPhase *phase_ptr)
jvmtiEventModeLL events[JVMTI_EVENT_END_ENUM-JVMTI_EVENT_START_ENUM]
#define JVMTI_THREAD_STATE_WAITING_INDEFINITELY
static jvmtiError GetImplementedInterfaces(jvmtiEnv *env, jclass klass, jint *interface_count_ptr, jclass **interfaces_ptr)
static void * threadstartup(void *t)
void lock_wait_for_object(java_handle_t *o, s8 millis, s4 nanos)
static jvmtiError GetCurrentContendedMonitor(jvmtiEnv *env, jthread thread, jobject *monitor_ptr)
static jvmtiError GetLoadedClasses(jvmtiEnv *env, jint *class_count_ptr, jclass **classes_ptr)
static jvmtiError SetBreakpoint(jvmtiEnv *env, jmethodID method, jlocation location)
static void execute_callback(jvmtiEvent e, functionptr ec, genericEventData *data)
static jvmtiError SetJNIFunctionTable(jvmtiEnv *env, const jniNativeInterface *function_table)
arraydescriptor * arraydesc
static jvmtiError SetSystemProperty(jvmtiEnv *env, const char *property, const char *value)
static jvmtiError GetErrorName(jvmtiEnv *env, jvmtiError error, char **name_ptr)
static jvmtiError GetObjectHashCode(jvmtiEnv *env, jobject object, jint *hash_code_ptr)
static jvmtiError RawMonitorNotifyAll(jvmtiEnv *env, jrawMonitorID monitor)
static jvmtiError IsFieldSynthetic(jvmtiEnv *env, jclass klass, jfieldID field, jboolean *is_synthetic_ptr)
void * EnvironmentLocalStorage
static jvmtiError GetTag(jvmtiEnv *env, jobject object, jlong *tag_ptr)
static jvmtiError IterateOverHeap(jvmtiEnv *env, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, void *user_data)
static jvmtiError GetClassLoaderClasses(jvmtiEnv *env, jobject initiating_loader, jint *class_count_ptr, jclass **classes_ptr)
static jvmtiError ResumeThreadList(jvmtiEnv *env, jint request_count, const jthread *request_list, jvmtiError *results)
static jvmtiError IterateOverObjectsReachableFromObject(jvmtiEnv *env, jobject object, jvmtiObjectReferenceCallback object_reference_callback, void *user_data)
classinfo * class_java_lang_String
#define JVMTI_THREAD_STATE_RUNNABLE
static jvmtiError GetBytecodes(jvmtiEnv *env, jmethodID method, jint *bytecode_count_ptr, unsigned char **bytecodes_ptr)
static jvmtiError RawMonitorExit(jvmtiEnv *env, jrawMonitorID monitor)
static jvmtiError GetThreadListStackTraces(jvmtiEnv *env, jint thread_count, const jthread *thread_list, jint max_frame_count, jvmtiStackInfo **stack_info_ptr)
jint * new_class_data_len
static jvmtiError SetExtensionEventCallback(jvmtiEnv *env, jint extension_event_index, jvmtiExtensionEvent callback)
static jvmtiError GetFrameCount(jvmtiEnv *env, jthread thread, jint *count_ptr)
#define JVMTI_THREAD_MIN_PRIORITY
static void dofireEvent(jvmtiEvent e, genericEventData *data)
static jvmtiError IsMethodObsolete(jvmtiEnv *env, jmethodID method, jboolean *is_obsolete_ptr)
bool lock_is_held_by_current_thread(java_handle_t *o)
#define CHECK_PHASE_START
#define JVMTI_THREAD_STATE_TERMINATED
jobject context_class_loader
static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv *env, jvmtiTimerInfo *info_ptr)
static jvmtiError GetTopThreadGroups(jvmtiEnv *env, jint *group_count_ptr, jthreadGroup **groups_ptr)
unsigned char ** new_class_data
static jvmtiError GetLocalInt(jvmtiEnv *env, jthread thread, jint depth, jint slot, jint *value_ptr)
jthread jint * owned_monitor_count_ptr
static jvmtiError GetVersionNumber(jvmtiEnv *env, jint *version_ptr)
#define JVMTI_THREAD_STATE_PARKED
#define CHECK_ADD_CAPABILITY(env, CAN)
static jvmtiError GetClassStatus(jvmtiEnv *env, jclass klass, jint *status_ptr)
static jvmtiError RawMonitorEnter(jvmtiEnv *env, jrawMonitorID monitor)
static jvmtiError GetClassLoader(jvmtiEnv *env, jclass klass, jobject *classloader_ptr)
static jvmtiError GetClassMethods(jvmtiEnv *env, jclass klass, jint *method_count_ptr, jmethodID **methods_ptr)
#define JVMTI_THREAD_MAX_PRIORITY
static jvmtiError SetFieldModificationWatch(jvmtiEnv *env, jclass klass, jfieldID field)
GNU Classpath java/lang/Thread.
jvmtiEventMode jvmtiEvent event_type
#define CHECK_DEL_CAPABILITY(env, CAN)
stackframeinfo_t * _stackframeinfo
static jvmtiError GetLineNumberTable(jvmtiEnv *env, jmethodID method, jint *entry_count_ptr, jvmtiLineNumberEntry **table_ptr)
classinfo * class_java_lang_Thread
bool lock_monitor_enter(java_handle_t *o)
static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv *env, const char *segment)
static jvmtiError ClearBreakpoint(jvmtiEnv *env, jmethodID method, jlocation location)
static jvmtiError GetTimerInfo(jvmtiEnv *env, jvmtiTimerInfo *info_ptr)
#define MREALLOC(ptr, type, num1, num2)
static jvmtiError ResumeThread(jvmtiEnv *env, jthread thread)
static jvmtiError GetArgumentsSize(jvmtiEnv *env, jmethodID method, jint *size_ptr)
static jvmtiError ClearFieldModificationWatch(jvmtiEnv *env, jclass klass, jfieldID field)
GNU Classpath java/lang/Class.
void jvmti_agentload(char *opt_arg, bool agentbypath, lt_dlhandle *handle, char **libname)
JNIEnv jthread jmethodID jlocation location
#define JVMTI_THREAD_STATE_IN_OBJECT_WAIT
static jvmtiError GetJNIFunctionTable(jvmtiEnv *env, jniNativeInterface **function_table)
#define MFREE(ptr, type, num)
static environment * envs
jobject protection_domain
static jvmtiError SetVerboseFlag(jvmtiEnv *env, jvmtiVerboseFlag flag, jboolean value)
#define CHECK_CAPABILITY(env, CAP)
static jvmtiError GetFrameLocation(jvmtiEnv *env, jthread thread, jint depth, jmethodID *method_ptr, jlocation *location_ptr)
static jvmtiError GetMaxLocals(jvmtiEnv *env, jmethodID method, jint *max_ptr)
jthread jint jobject ** owned_monitors_ptr
static jvmtiError getcacaostacktrace(stacktracebuffer **trace, jthread thread)
#define JVMTI_CLASS_STATUS_INITIALIZED
static jvmtiError GetAllStackTraces(jvmtiEnv *env, jint max_frame_count, jvmtiStackInfo **stack_info_ptr, jint *thread_count_ptr)
static jvmtiError GetThreadGroupChildren(jvmtiEnv *env, jthreadGroup group, jint *thread_count_ptr, jthread **threads_ptr, jint *group_count_ptr, jthreadGroup **groups_ptr)
static jvmtiError GetThreadGroupInfo(jvmtiEnv *env, jthreadGroup group, jvmtiThreadGroupInfo *info_ptr)
static jvmtiError SetTag(jvmtiEnv *env, jobject object, jlong tag)