| Elliott Hughes | f6a1e1e | 2011-10-25 16:28:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "debugger.h" |
| 18 | #include "logging.h" |
| 19 | |
| 20 | #include "JniConstants.h" // Last to avoid problems with LOG redefinition. |
| 21 | #include "ScopedPrimitiveArray.h" // Last to avoid problems with LOG redefinition. |
| 22 | |
| 23 | namespace art { |
| 24 | |
| 25 | namespace { |
| 26 | |
| 27 | static void DdmVmInternal_enableRecentAllocations(JNIEnv* env, jclass, jboolean enable) { |
| 28 | UNIMPLEMENTED(WARNING); |
| 29 | if (enable) { |
| 30 | //dvmEnableAllocTracker(); |
| 31 | } else { |
| 32 | //dvmDisableAllocTracker(); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | static jbyteArray DdmVmInternal_getRecentAllocations(JNIEnv* env, jclass) { |
| 37 | UNIMPLEMENTED(WARNING); |
| 38 | return NULL; |
| 39 | //ArrayObject* data = dvmDdmGetRecentAllocations(); |
| 40 | //dvmReleaseTrackedAlloc(data, NULL); |
| 41 | //return reinterpret_cast<jbyteArray>(addLocalReference(env, data)); |
| 42 | } |
| 43 | |
| 44 | static jboolean DdmVmInternal_getRecentAllocationStatus(JNIEnv* env, jclass) { |
| 45 | UNIMPLEMENTED(WARNING); |
| 46 | return JNI_FALSE; |
| 47 | //return (gDvm.allocRecords != NULL); |
| 48 | } |
| 49 | |
| 50 | /* |
| 51 | * Get a stack trace as an array of StackTraceElement objects. Returns |
| 52 | * NULL on failure, e.g. if the threadId couldn't be found. |
| 53 | */ |
| 54 | static jobjectArray DdmVmInternal_getStackTraceById(JNIEnv* env, jclass, jint threadId) { |
| 55 | UNIMPLEMENTED(WARNING); |
| 56 | return NULL; |
| 57 | //ArrayObject* trace = dvmDdmGetStackTraceById(threadId); |
| 58 | //return reinterpret_cast<jobjectArray>(addLocalReference(env, trace)); |
| 59 | } |
| 60 | |
| 61 | static jbyteArray DdmVmInternal_getThreadStats(JNIEnv* env, jclass) { |
| 62 | UNIMPLEMENTED(WARNING); |
| 63 | return NULL; |
| 64 | //ArrayObject* result = dvmDdmGenerateThreadStats(); |
| 65 | //dvmReleaseTrackedAlloc(result, NULL); |
| 66 | //return reinterpret_cast<jbyteArray>(addLocalReference(env, result)); |
| 67 | } |
| 68 | |
| 69 | static jint DdmVmInternal_heapInfoNotify(JNIEnv* env, jclass, jint when) { |
| 70 | UNIMPLEMENTED(WARNING); |
| 71 | return 0; |
| 72 | //return dvmDdmHandleHpifChunk(when); |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | * Enable DDM heap notifications. |
| 77 | * @param when: 0=never (off), 1=during GC |
| 78 | * @param what: 0=merged objects, 1=distinct objects |
| 79 | * @param native: false=virtual heap, true=native heap |
| 80 | */ |
| 81 | static jboolean DdmVmInternal_heapSegmentNotify(JNIEnv* env, jclass, jint when, jint what, jboolean native) { |
| 82 | UNIMPLEMENTED(WARNING); |
| 83 | return JNI_FALSE; |
| 84 | //return dvmDdmHandleHpsgNhsgChunk(when, what, native); |
| 85 | } |
| 86 | |
| 87 | static void DdmVmInternal_threadNotify(JNIEnv* env, jclass, jboolean enable) { |
| Elliott Hughes | 47fce01 | 2011-10-25 18:37:19 -0700 | [diff] [blame^] | 88 | Dbg::DdmSetThreadNotification(enable); |
| Elliott Hughes | f6a1e1e | 2011-10-25 16:28:04 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | static JNINativeMethod gMethods[] = { |
| 92 | NATIVE_METHOD(DdmVmInternal, enableRecentAllocations, "(Z)V"), |
| 93 | NATIVE_METHOD(DdmVmInternal, getRecentAllocations, "()[B"), |
| 94 | NATIVE_METHOD(DdmVmInternal, getRecentAllocationStatus, "()Z"), |
| 95 | NATIVE_METHOD(DdmVmInternal, getStackTraceById, "(I)[Ljava/lang/StackTraceElement;"), |
| 96 | NATIVE_METHOD(DdmVmInternal, getThreadStats, "()[B"), |
| 97 | NATIVE_METHOD(DdmVmInternal, heapInfoNotify, "(I)Z"), |
| 98 | NATIVE_METHOD(DdmVmInternal, heapSegmentNotify, "(IIZ)Z"), |
| 99 | NATIVE_METHOD(DdmVmInternal, threadNotify, "(Z)V"), |
| 100 | }; |
| 101 | |
| 102 | } // namespace |
| 103 | |
| 104 | void register_org_apache_harmony_dalvik_ddmc_DdmVmInternal(JNIEnv* env) { |
| 105 | jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/ddmc/DdmVmInternal", gMethods, NELEM(gMethods)); |
| 106 | } |
| 107 | |
| 108 | } // namespace art |