blob: fab49683fa86d9fcdbf350bb3a741b5961a3a9d5 [file] [log] [blame]
Elliott Hughesf6a1e1e2011-10-25 16:28:04 -07001/*
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
23namespace art {
24
25namespace {
26
27static void DdmVmInternal_enableRecentAllocations(JNIEnv* env, jclass, jboolean enable) {
28 UNIMPLEMENTED(WARNING);
29 if (enable) {
30 //dvmEnableAllocTracker();
31 } else {
32 //dvmDisableAllocTracker();
33 }
34}
35
36static 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
44static 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 */
54static 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
61static 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
69static 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 */
81static 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
87static void DdmVmInternal_threadNotify(JNIEnv* env, jclass, jboolean enable) {
Elliott Hughes47fce012011-10-25 18:37:19 -070088 Dbg::DdmSetThreadNotification(enable);
Elliott Hughesf6a1e1e2011-10-25 16:28:04 -070089}
90
91static 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
104void 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