diff options
Diffstat (limited to 'runtime/openjdkjvmti/OpenjdkJvmTi.cc')
| -rw-r--r-- | runtime/openjdkjvmti/OpenjdkJvmTi.cc | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/runtime/openjdkjvmti/OpenjdkJvmTi.cc b/runtime/openjdkjvmti/OpenjdkJvmTi.cc index 0896210f1c..d3e8798bd6 100644 --- a/runtime/openjdkjvmti/OpenjdkJvmTi.cc +++ b/runtime/openjdkjvmti/OpenjdkJvmTi.cc @@ -48,6 +48,8 @@ #include "scoped_thread_state_change-inl.h" #include "thread-current-inl.h" #include "thread_list.h" +#include "ti_allocator.h" +#include "ti_breakpoint.h" #include "ti_class.h" #include "ti_dump.h" #include "ti_field.h" @@ -108,22 +110,12 @@ class JvmtiFunctions { static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) { ENSURE_VALID_ENV(env); ENSURE_NON_NULL(mem_ptr); - if (size < 0) { - return ERR(ILLEGAL_ARGUMENT); - } else if (size == 0) { - *mem_ptr = nullptr; - return OK; - } - *mem_ptr = static_cast<unsigned char*>(malloc(size)); - return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY); + return AllocUtil::Allocate(env, size, mem_ptr); } static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) { ENSURE_VALID_ENV(env); - if (mem != nullptr) { - free(mem); - } - return OK; + return AllocUtil::Deallocate(env, mem); } static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) { @@ -619,20 +611,17 @@ class JvmtiFunctions { return ERR(NOT_IMPLEMENTED); } - static jvmtiError SetBreakpoint(jvmtiEnv* env, - jmethodID method ATTRIBUTE_UNUSED, - jlocation location ATTRIBUTE_UNUSED) { + + static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) { ENSURE_VALID_ENV(env); ENSURE_HAS_CAP(env, can_generate_breakpoint_events); - return ERR(NOT_IMPLEMENTED); + return BreakpointUtil::SetBreakpoint(env, method, location); } - static jvmtiError ClearBreakpoint(jvmtiEnv* env, - jmethodID method ATTRIBUTE_UNUSED, - jlocation location ATTRIBUTE_UNUSED) { + static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) { ENSURE_VALID_ENV(env); ENSURE_HAS_CAP(env, can_generate_breakpoint_events); - return ERR(NOT_IMPLEMENTED); + return BreakpointUtil::ClearBreakpoint(env, method, location); } static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) { @@ -924,12 +913,12 @@ class JvmtiFunctions { } static jvmtiError GetBytecodes(jvmtiEnv* env, - jmethodID method ATTRIBUTE_UNUSED, - jint* bytecode_count_ptr ATTRIBUTE_UNUSED, - unsigned char** bytecodes_ptr ATTRIBUTE_UNUSED) { + jmethodID method, + jint* bytecode_count_ptr, + unsigned char** bytecodes_ptr) { ENSURE_VALID_ENV(env); ENSURE_HAS_CAP(env, can_get_bytecodes); - return ERR(NOT_IMPLEMENTED); + return MethodUtil::GetBytecodes(env, method, bytecode_count_ptr, bytecodes_ptr); } static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) { @@ -1219,6 +1208,23 @@ class JvmtiFunctions { return error; } + error = add_extension( + reinterpret_cast<jvmtiExtensionFunction>(AllocUtil::GetGlobalJvmtiAllocationState), + "com.android.art.alloc.get_global_jvmti_allocation_state", + "Returns the total amount of memory currently allocated by all jvmtiEnvs through the" + " 'Allocate' jvmti function. This does not include any memory that has been deallocated" + " through the 'Deallocate' function. This number is approximate and might not correspond" + " exactly to the sum of the sizes of all not freed allocations.", + 1, + { // NOLINT [whitespace/braces] [4] + { "currently_allocated", JVMTI_KIND_OUT, JVMTI_TYPE_JLONG, false}, + }, + 1, + { ERR(NULL_POINTER) }); + if (error != ERR(NONE)) { + return error; + } + // Copy into output buffer. *extension_count_ptr = ext_vector.size(); |