Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -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 | |
Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 17 | #include "dalvik_system_VMDebug.h" |
| 18 | |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 19 | #include <string.h> |
| 20 | #include <unistd.h> |
| 21 | |
Hiroshi Yamauchi | a1c9f01 | 2015-04-02 10:18:12 -0700 | [diff] [blame] | 22 | #include <sstream> |
| 23 | |
Andreas Gampe | a14100c | 2017-04-24 15:09:56 -0700 | [diff] [blame] | 24 | #include "nativehelper/jni_macros.h" |
| 25 | |
Hiroshi Yamauchi | a1c9f01 | 2015-04-02 10:18:12 -0700 | [diff] [blame] | 26 | #include "base/histogram-inl.h" |
Vladimir Marko | 80afd02 | 2015-05-19 18:08:00 +0100 | [diff] [blame] | 27 | #include "base/time_utils.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 28 | #include "class_linker.h" |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 29 | #include "common_throws.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 30 | #include "debugger.h" |
Mathieu Chartier | 7410f29 | 2013-11-24 13:17:35 -0800 | [diff] [blame] | 31 | #include "gc/space/bump_pointer_space.h" |
Hiroshi Yamauchi | 09b07a9 | 2013-07-15 13:17:06 -0700 | [diff] [blame] | 32 | #include "gc/space/dlmalloc_space.h" |
| 33 | #include "gc/space/large_object_space.h" |
| 34 | #include "gc/space/space-inl.h" |
Mathieu Chartier | 1f3b535 | 2014-02-03 14:00:42 -0800 | [diff] [blame] | 35 | #include "gc/space/zygote_space.h" |
Andreas Gampe | c15a2f4 | 2017-04-21 12:09:39 -0700 | [diff] [blame] | 36 | #include "handle_scope-inl.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 37 | #include "hprof/hprof.h" |
Andreas Gampe | c15a2f4 | 2017-04-21 12:09:39 -0700 | [diff] [blame] | 38 | #include "java_vm_ext.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 39 | #include "jni_internal.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 40 | #include "mirror/class.h" |
Andreas Gampe | c15a2f4 | 2017-04-21 12:09:39 -0700 | [diff] [blame] | 41 | #include "mirror/object_array-inl.h" |
Andreas Gampe | 87583b3 | 2017-05-25 11:22:18 -0700 | [diff] [blame] | 42 | #include "native_util.h" |
Steven Moreland | e431e27 | 2017-07-18 16:53:49 -0700 | [diff] [blame] | 43 | #include "nativehelper/ScopedLocalRef.h" |
| 44 | #include "nativehelper/ScopedUtfChars.h" |
Mathieu Chartier | 0795f23 | 2016-09-27 18:43:30 -0700 | [diff] [blame] | 45 | #include "scoped_fast_native_object_access-inl.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 46 | #include "trace.h" |
Ian Rogers | dd157d7 | 2014-05-15 14:47:50 -0700 | [diff] [blame] | 47 | #include "well_known_classes.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 48 | |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 49 | namespace art { |
| 50 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 51 | static jobjectArray VMDebug_getVmFeatureList(JNIEnv* env, jclass) { |
Ian Rogers | dd157d7 | 2014-05-15 14:47:50 -0700 | [diff] [blame] | 52 | static const char* features[] = { |
| 53 | "method-trace-profiling", |
| 54 | "method-trace-profiling-streaming", |
| 55 | "method-sample-profiling", |
| 56 | "hprof-heap-dump", |
| 57 | "hprof-heap-dump-streaming", |
| 58 | }; |
| 59 | jobjectArray result = env->NewObjectArray(arraysize(features), |
| 60 | WellKnownClasses::java_lang_String, |
| 61 | nullptr); |
| 62 | if (result != nullptr) { |
| 63 | for (size_t i = 0; i < arraysize(features); ++i) { |
| 64 | ScopedLocalRef<jstring> jfeature(env, env->NewStringUTF(features[i])); |
| 65 | if (jfeature.get() == nullptr) { |
| 66 | return nullptr; |
| 67 | } |
| 68 | env->SetObjectArrayElement(result, i, jfeature.get()); |
| 69 | } |
| 70 | } |
| 71 | return result; |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 74 | static void VMDebug_startAllocCounting(JNIEnv*, jclass) { |
Mathieu Chartier | 9ef78b5 | 2014-09-25 17:03:12 -0700 | [diff] [blame] | 75 | Runtime::Current()->SetStatsEnabled(true); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 78 | static void VMDebug_stopAllocCounting(JNIEnv*, jclass) { |
Mathieu Chartier | 9ef78b5 | 2014-09-25 17:03:12 -0700 | [diff] [blame] | 79 | Runtime::Current()->SetStatsEnabled(false); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Elliott Hughes | 1bac54f | 2012-03-16 12:48:31 -0700 | [diff] [blame] | 82 | static jint VMDebug_getAllocCount(JNIEnv*, jclass, jint kind) { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 83 | return Runtime::Current()->GetStat(kind); |
| 84 | } |
| 85 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 86 | static void VMDebug_resetAllocCount(JNIEnv*, jclass, jint kinds) { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 87 | Runtime::Current()->ResetStats(kinds); |
| 88 | } |
| 89 | |
Jeff Hao | 23009dc | 2013-08-22 15:36:42 -0700 | [diff] [blame] | 90 | static void VMDebug_startMethodTracingDdmsImpl(JNIEnv*, jclass, jint bufferSize, jint flags, |
| 91 | jboolean samplingEnabled, jint intervalUs) { |
Andreas Gampe | 7e7e0f4 | 2015-03-29 15:26:23 -0700 | [diff] [blame] | 92 | Trace::Start("[DDMS]", -1, bufferSize, flags, Trace::TraceOutputMode::kDDMS, |
| 93 | samplingEnabled ? Trace::TraceMode::kSampling : Trace::TraceMode::kMethodTracing, |
| 94 | intervalUs); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 97 | static void VMDebug_startMethodTracingFd(JNIEnv* env, jclass, jstring javaTraceFilename, |
Andreas Gampe | ad5df10 | 2017-10-04 16:31:08 -0700 | [diff] [blame^] | 98 | jint javaFd, jint bufferSize, jint flags, |
Shukang Zhou | ca6e14e | 2017-01-25 00:35:21 -0800 | [diff] [blame] | 99 | jboolean samplingEnabled, jint intervalUs, |
| 100 | jboolean streamingOutput) { |
Andreas Gampe | ad5df10 | 2017-10-04 16:31:08 -0700 | [diff] [blame^] | 101 | int originalFd = javaFd; |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 102 | if (originalFd < 0) { |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | int fd = dup(originalFd); |
| 107 | if (fd < 0) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 108 | ScopedObjectAccess soa(env); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 109 | soa.Self()->ThrowNewExceptionF("Ljava/lang/RuntimeException;", |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 110 | "dup(%d) failed: %s", originalFd, strerror(errno)); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 111 | return; |
| 112 | } |
| 113 | |
| 114 | ScopedUtfChars traceFilename(env, javaTraceFilename); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 115 | if (traceFilename.c_str() == nullptr) { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 116 | return; |
| 117 | } |
Shukang Zhou | ca6e14e | 2017-01-25 00:35:21 -0800 | [diff] [blame] | 118 | Trace::TraceOutputMode outputMode = streamingOutput |
| 119 | ? Trace::TraceOutputMode::kStreaming |
| 120 | : Trace::TraceOutputMode::kFile; |
| 121 | Trace::Start(traceFilename.c_str(), fd, bufferSize, flags, outputMode, |
Andreas Gampe | 7e7e0f4 | 2015-03-29 15:26:23 -0700 | [diff] [blame] | 122 | samplingEnabled ? Trace::TraceMode::kSampling : Trace::TraceMode::kMethodTracing, |
| 123 | intervalUs); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 126 | static void VMDebug_startMethodTracingFilename(JNIEnv* env, jclass, jstring javaTraceFilename, |
Jeff Hao | 4044bda | 2014-01-06 15:50:45 -0800 | [diff] [blame] | 127 | jint bufferSize, jint flags, |
| 128 | jboolean samplingEnabled, jint intervalUs) { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 129 | ScopedUtfChars traceFilename(env, javaTraceFilename); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 130 | if (traceFilename.c_str() == nullptr) { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 131 | return; |
| 132 | } |
Andreas Gampe | 7e7e0f4 | 2015-03-29 15:26:23 -0700 | [diff] [blame] | 133 | Trace::Start(traceFilename.c_str(), -1, bufferSize, flags, Trace::TraceOutputMode::kFile, |
| 134 | samplingEnabled ? Trace::TraceMode::kSampling : Trace::TraceMode::kMethodTracing, |
| 135 | intervalUs); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Jeff Hao | 64caa7d | 2013-08-29 11:18:01 -0700 | [diff] [blame] | 138 | static jint VMDebug_getMethodTracingMode(JNIEnv*, jclass) { |
| 139 | return Trace::GetMethodTracingMode(); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 142 | static void VMDebug_stopMethodTracing(JNIEnv*, jclass) { |
jeffhao | e343b76 | 2011-12-05 16:36:44 -0800 | [diff] [blame] | 143 | Trace::Stop(); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 146 | static void VMDebug_startEmulatorTracing(JNIEnv*, jclass) { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 147 | UNIMPLEMENTED(WARNING); |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 148 | // dvmEmulatorTraceStart(); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 149 | } |
| 150 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 151 | static void VMDebug_stopEmulatorTracing(JNIEnv*, jclass) { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 152 | UNIMPLEMENTED(WARNING); |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 153 | // dvmEmulatorTraceStop(); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 154 | } |
| 155 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 156 | static jboolean VMDebug_isDebuggerConnected(JNIEnv*, jclass) { |
Elliott Hughes | c0f0933 | 2012-03-26 13:27:06 -0700 | [diff] [blame] | 157 | return Dbg::IsDebuggerActive(); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 160 | static jboolean VMDebug_isDebuggingEnabled(JNIEnv*, jclass) { |
Elliott Hughes | c0f0933 | 2012-03-26 13:27:06 -0700 | [diff] [blame] | 161 | return Dbg::IsJdwpConfigured(); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 164 | static jlong VMDebug_lastDebuggerActivity(JNIEnv*, jclass) { |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 165 | return Dbg::LastDebuggerActivity(); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 166 | } |
| 167 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 168 | static void ThrowUnsupportedOperationException(JNIEnv* env) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 169 | ScopedObjectAccess soa(env); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 170 | soa.Self()->ThrowNewException("Ljava/lang/UnsupportedOperationException;", nullptr); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | static void VMDebug_startInstructionCounting(JNIEnv* env, jclass) { |
| 174 | ThrowUnsupportedOperationException(env); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 177 | static void VMDebug_stopInstructionCounting(JNIEnv* env, jclass) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 178 | ThrowUnsupportedOperationException(env); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 179 | } |
| 180 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 181 | static void VMDebug_getInstructionCount(JNIEnv* env, jclass, jintArray /*javaCounts*/) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 182 | ThrowUnsupportedOperationException(env); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 185 | static void VMDebug_resetInstructionCount(JNIEnv* env, jclass) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 186 | ThrowUnsupportedOperationException(env); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 189 | static void VMDebug_printLoadedClasses(JNIEnv* env, jclass, jint flags) { |
Andreas Gampe | cc1b535 | 2016-12-01 16:58:38 -0800 | [diff] [blame] | 190 | class DumpClassVisitor : public ClassVisitor { |
| 191 | public: |
| 192 | explicit DumpClassVisitor(int dump_flags) : flags_(dump_flags) {} |
| 193 | |
| 194 | bool operator()(ObjPtr<mirror::Class> klass) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_) { |
| 195 | klass->DumpClass(LOG_STREAM(ERROR), flags_); |
| 196 | return true; |
| 197 | } |
| 198 | |
| 199 | private: |
| 200 | const int flags_; |
| 201 | }; |
| 202 | DumpClassVisitor visitor(flags); |
| 203 | |
Ian Rogers | 53b8b09 | 2014-03-13 23:45:53 -0700 | [diff] [blame] | 204 | ScopedFastNativeObjectAccess soa(env); |
Andreas Gampe | cc1b535 | 2016-12-01 16:58:38 -0800 | [diff] [blame] | 205 | return Runtime::Current()->GetClassLinker()->VisitClasses(&visitor); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 208 | static jint VMDebug_getLoadedClassCount(JNIEnv* env, jclass) { |
Ian Rogers | 53b8b09 | 2014-03-13 23:45:53 -0700 | [diff] [blame] | 209 | ScopedFastNativeObjectAccess soa(env); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 210 | return Runtime::Current()->GetClassLinker()->NumLoadedClasses(); |
| 211 | } |
| 212 | |
| 213 | /* |
| 214 | * Returns the thread-specific CPU-time clock value for the current thread, |
| 215 | * or -1 if the feature isn't supported. |
| 216 | */ |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 217 | static jlong VMDebug_threadCpuTimeNanos(JNIEnv*, jclass) { |
| 218 | return ThreadCpuNanoTime(); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | /* |
| 222 | * static void dumpHprofData(String fileName, FileDescriptor fd) |
| 223 | * |
| 224 | * Cause "hprof" data to be dumped. We can throw an IOException if an |
| 225 | * error occurs during file handling. |
| 226 | */ |
Andreas Gampe | ad5df10 | 2017-10-04 16:31:08 -0700 | [diff] [blame^] | 227 | static void VMDebug_dumpHprofData(JNIEnv* env, jclass, jstring javaFilename, jint javaFd) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 228 | // Only one of these may be null. |
Andreas Gampe | ad5df10 | 2017-10-04 16:31:08 -0700 | [diff] [blame^] | 229 | if (javaFilename == nullptr && javaFd < 0) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 230 | ScopedObjectAccess soa(env); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 231 | ThrowNullPointerException("fileName == null && fd == null"); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 232 | return; |
| 233 | } |
| 234 | |
| 235 | std::string filename; |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 236 | if (javaFilename != nullptr) { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 237 | ScopedUtfChars chars(env, javaFilename); |
| 238 | if (env->ExceptionCheck()) { |
| 239 | return; |
| 240 | } |
| 241 | filename = chars.c_str(); |
| 242 | } else { |
| 243 | filename = "[fd]"; |
| 244 | } |
| 245 | |
Andreas Gampe | ad5df10 | 2017-10-04 16:31:08 -0700 | [diff] [blame^] | 246 | int fd = javaFd; |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 247 | |
Elliott Hughes | 622a698 | 2012-06-08 17:58:54 -0700 | [diff] [blame] | 248 | hprof::DumpHeap(filename.c_str(), fd, false); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 251 | static void VMDebug_dumpHprofDataDdms(JNIEnv*, jclass) { |
Elliott Hughes | 622a698 | 2012-06-08 17:58:54 -0700 | [diff] [blame] | 252 | hprof::DumpHeap("[DDMS]", -1, true); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 255 | static void VMDebug_dumpReferenceTables(JNIEnv* env, jclass) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 256 | ScopedObjectAccess soa(env); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 257 | LOG(INFO) << "--- reference table dump ---"; |
| 258 | |
Andreas Gampe | 3fec9ac | 2016-09-13 10:47:28 -0700 | [diff] [blame] | 259 | soa.Env()->DumpReferenceTables(LOG_STREAM(INFO)); |
| 260 | soa.Vm()->DumpReferenceTables(LOG_STREAM(INFO)); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 261 | |
| 262 | LOG(INFO) << "---"; |
| 263 | } |
| 264 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 265 | static void VMDebug_crash(JNIEnv*, jclass) { |
Elliott Hughes | 81ff318 | 2012-03-23 20:35:56 -0700 | [diff] [blame] | 266 | LOG(FATAL) << "Crashing runtime on request"; |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 269 | static void VMDebug_infopoint(JNIEnv*, jclass, jint id) { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 270 | LOG(INFO) << "VMDebug infopoint " << id << " hit"; |
| 271 | } |
| 272 | |
Mathieu Chartier | 9d156d5 | 2016-10-06 17:44:26 -0700 | [diff] [blame] | 273 | static jlong VMDebug_countInstancesOfClass(JNIEnv* env, |
| 274 | jclass, |
| 275 | jclass javaClass, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 276 | jboolean countAssignable) { |
| 277 | ScopedObjectAccess soa(env); |
Mathieu Chartier | f182085 | 2015-07-10 13:19:51 -0700 | [diff] [blame] | 278 | gc::Heap* const heap = Runtime::Current()->GetHeap(); |
| 279 | // Caller's responsibility to do GC if desired. |
Mathieu Chartier | 0795f23 | 2016-09-27 18:43:30 -0700 | [diff] [blame] | 280 | ObjPtr<mirror::Class> c = soa.Decode<mirror::Class>(javaClass); |
Mathieu Chartier | 412c7fc | 2014-02-07 12:18:39 -0800 | [diff] [blame] | 281 | if (c == nullptr) { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 282 | return 0; |
| 283 | } |
Mathieu Chartier | e8a3c57 | 2016-10-11 16:52:17 -0700 | [diff] [blame] | 284 | VariableSizedHandleScope hs(soa.Self()); |
Mathieu Chartier | 9d156d5 | 2016-10-06 17:44:26 -0700 | [diff] [blame] | 285 | std::vector<Handle<mirror::Class>> classes {hs.NewHandle(c)}; |
Elliott Hughes | ec0f83d | 2013-01-15 16:54:08 -0800 | [diff] [blame] | 286 | uint64_t count = 0; |
Mathieu Chartier | 412c7fc | 2014-02-07 12:18:39 -0800 | [diff] [blame] | 287 | heap->CountInstances(classes, countAssignable, &count); |
Elliott Hughes | ec0f83d | 2013-01-15 16:54:08 -0800 | [diff] [blame] | 288 | return count; |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 289 | } |
| 290 | |
Mathieu Chartier | 9d156d5 | 2016-10-06 17:44:26 -0700 | [diff] [blame] | 291 | static jlongArray VMDebug_countInstancesOfClasses(JNIEnv* env, |
| 292 | jclass, |
| 293 | jobjectArray javaClasses, |
Mathieu Chartier | f182085 | 2015-07-10 13:19:51 -0700 | [diff] [blame] | 294 | jboolean countAssignable) { |
| 295 | ScopedObjectAccess soa(env); |
| 296 | gc::Heap* const heap = Runtime::Current()->GetHeap(); |
| 297 | // Caller's responsibility to do GC if desired. |
Mathieu Chartier | 0795f23 | 2016-09-27 18:43:30 -0700 | [diff] [blame] | 298 | ObjPtr<mirror::ObjectArray<mirror::Class>> decoded_classes = |
| 299 | soa.Decode<mirror::ObjectArray<mirror::Class>>(javaClasses); |
Mathieu Chartier | f182085 | 2015-07-10 13:19:51 -0700 | [diff] [blame] | 300 | if (decoded_classes == nullptr) { |
| 301 | return nullptr; |
| 302 | } |
Mathieu Chartier | e8a3c57 | 2016-10-11 16:52:17 -0700 | [diff] [blame] | 303 | VariableSizedHandleScope hs(soa.Self()); |
Mathieu Chartier | 9d156d5 | 2016-10-06 17:44:26 -0700 | [diff] [blame] | 304 | std::vector<Handle<mirror::Class>> classes; |
Mathieu Chartier | f182085 | 2015-07-10 13:19:51 -0700 | [diff] [blame] | 305 | for (size_t i = 0, count = decoded_classes->GetLength(); i < count; ++i) { |
Mathieu Chartier | 9d156d5 | 2016-10-06 17:44:26 -0700 | [diff] [blame] | 306 | classes.push_back(hs.NewHandle(decoded_classes->Get(i))); |
Mathieu Chartier | f182085 | 2015-07-10 13:19:51 -0700 | [diff] [blame] | 307 | } |
| 308 | std::vector<uint64_t> counts(classes.size(), 0u); |
| 309 | // Heap::CountInstances can handle null and will put 0 for these classes. |
| 310 | heap->CountInstances(classes, countAssignable, &counts[0]); |
Mathieu Chartier | 9d156d5 | 2016-10-06 17:44:26 -0700 | [diff] [blame] | 311 | ObjPtr<mirror::LongArray> long_counts = mirror::LongArray::Alloc(soa.Self(), counts.size()); |
Mathieu Chartier | f182085 | 2015-07-10 13:19:51 -0700 | [diff] [blame] | 312 | if (long_counts == nullptr) { |
| 313 | soa.Self()->AssertPendingOOMException(); |
| 314 | return nullptr; |
| 315 | } |
| 316 | for (size_t i = 0; i < counts.size(); ++i) { |
| 317 | long_counts->Set(i, counts[i]); |
| 318 | } |
| 319 | return soa.AddLocalReference<jlongArray>(long_counts); |
| 320 | } |
| 321 | |
Hiroshi Yamauchi | 09b07a9 | 2013-07-15 13:17:06 -0700 | [diff] [blame] | 322 | // We export the VM internal per-heap-space size/alloc/free metrics |
| 323 | // for the zygote space, alloc space (application heap), and the large |
| 324 | // object space for dumpsys meminfo. The other memory region data such |
| 325 | // as PSS, private/shared dirty/shared data are available via |
| 326 | // /proc/<pid>/smaps. |
| 327 | static void VMDebug_getHeapSpaceStats(JNIEnv* env, jclass, jlongArray data) { |
Ian Rogers | 6b99dd1 | 2013-07-25 12:11:32 -0700 | [diff] [blame] | 328 | jlong* arr = reinterpret_cast<jlong*>(env->GetPrimitiveArrayCritical(data, 0)); |
Mathieu Chartier | 7410f29 | 2013-11-24 13:17:35 -0800 | [diff] [blame] | 329 | if (arr == nullptr || env->GetArrayLength(data) < 9) { |
Hiroshi Yamauchi | 09b07a9 | 2013-07-15 13:17:06 -0700 | [diff] [blame] | 330 | return; |
| 331 | } |
| 332 | |
| 333 | size_t allocSize = 0; |
| 334 | size_t allocUsed = 0; |
| 335 | size_t zygoteSize = 0; |
| 336 | size_t zygoteUsed = 0; |
| 337 | size_t largeObjectsSize = 0; |
| 338 | size_t largeObjectsUsed = 0; |
Hiroshi Yamauchi | 09b07a9 | 2013-07-15 13:17:06 -0700 | [diff] [blame] | 339 | gc::Heap* heap = Runtime::Current()->GetHeap(); |
Mathieu Chartier | a9d82fe | 2016-01-25 20:06:11 -0800 | [diff] [blame] | 340 | { |
| 341 | ScopedObjectAccess soa(env); |
| 342 | for (gc::space::ContinuousSpace* space : heap->GetContinuousSpaces()) { |
| 343 | if (space->IsImageSpace()) { |
| 344 | // Currently don't include the image space. |
| 345 | } else if (space->IsZygoteSpace()) { |
| 346 | gc::space::ZygoteSpace* zygote_space = space->AsZygoteSpace(); |
| 347 | zygoteSize += zygote_space->Size(); |
| 348 | zygoteUsed += zygote_space->GetBytesAllocated(); |
| 349 | } else if (space->IsMallocSpace()) { |
| 350 | // This is a malloc space. |
| 351 | gc::space::MallocSpace* malloc_space = space->AsMallocSpace(); |
| 352 | allocSize += malloc_space->GetFootprint(); |
| 353 | allocUsed += malloc_space->GetBytesAllocated(); |
| 354 | } else if (space->IsBumpPointerSpace()) { |
| 355 | gc::space::BumpPointerSpace* bump_pointer_space = space->AsBumpPointerSpace(); |
| 356 | allocSize += bump_pointer_space->Size(); |
| 357 | allocUsed += bump_pointer_space->GetBytesAllocated(); |
| 358 | } |
| 359 | } |
| 360 | for (gc::space::DiscontinuousSpace* space : heap->GetDiscontinuousSpaces()) { |
| 361 | if (space->IsLargeObjectSpace()) { |
| 362 | largeObjectsSize += space->AsLargeObjectSpace()->GetBytesAllocated(); |
| 363 | largeObjectsUsed += largeObjectsSize; |
| 364 | } |
Hiroshi Yamauchi | 09b07a9 | 2013-07-15 13:17:06 -0700 | [diff] [blame] | 365 | } |
| 366 | } |
Hiroshi Yamauchi | 09b07a9 | 2013-07-15 13:17:06 -0700 | [diff] [blame] | 367 | size_t allocFree = allocSize - allocUsed; |
| 368 | size_t zygoteFree = zygoteSize - zygoteUsed; |
| 369 | size_t largeObjectsFree = largeObjectsSize - largeObjectsUsed; |
| 370 | |
| 371 | int j = 0; |
| 372 | arr[j++] = allocSize; |
| 373 | arr[j++] = allocUsed; |
| 374 | arr[j++] = allocFree; |
| 375 | arr[j++] = zygoteSize; |
| 376 | arr[j++] = zygoteUsed; |
| 377 | arr[j++] = zygoteFree; |
| 378 | arr[j++] = largeObjectsSize; |
| 379 | arr[j++] = largeObjectsUsed; |
| 380 | arr[j++] = largeObjectsFree; |
| 381 | env->ReleasePrimitiveArrayCritical(data, arr, 0); |
| 382 | } |
| 383 | |
Hiroshi Yamauchi | a1c9f01 | 2015-04-02 10:18:12 -0700 | [diff] [blame] | 384 | // The runtime stat names for VMDebug.getRuntimeStat(). |
| 385 | enum class VMDebugRuntimeStatId { |
| 386 | kArtGcGcCount = 0, |
| 387 | kArtGcGcTime, |
| 388 | kArtGcBytesAllocated, |
| 389 | kArtGcBytesFreed, |
| 390 | kArtGcBlockingGcCount, |
| 391 | kArtGcBlockingGcTime, |
| 392 | kArtGcGcCountRateHistogram, |
| 393 | kArtGcBlockingGcCountRateHistogram, |
| 394 | kNumRuntimeStats, |
| 395 | }; |
| 396 | |
| 397 | static jobject VMDebug_getRuntimeStatInternal(JNIEnv* env, jclass, jint statId) { |
| 398 | gc::Heap* heap = Runtime::Current()->GetHeap(); |
| 399 | switch (static_cast<VMDebugRuntimeStatId>(statId)) { |
| 400 | case VMDebugRuntimeStatId::kArtGcGcCount: { |
| 401 | std::string output = std::to_string(heap->GetGcCount()); |
| 402 | return env->NewStringUTF(output.c_str()); |
| 403 | } |
| 404 | case VMDebugRuntimeStatId::kArtGcGcTime: { |
| 405 | std::string output = std::to_string(NsToMs(heap->GetGcTime())); |
| 406 | return env->NewStringUTF(output.c_str()); |
| 407 | } |
| 408 | case VMDebugRuntimeStatId::kArtGcBytesAllocated: { |
| 409 | std::string output = std::to_string(heap->GetBytesAllocatedEver()); |
| 410 | return env->NewStringUTF(output.c_str()); |
| 411 | } |
| 412 | case VMDebugRuntimeStatId::kArtGcBytesFreed: { |
| 413 | std::string output = std::to_string(heap->GetBytesFreedEver()); |
| 414 | return env->NewStringUTF(output.c_str()); |
| 415 | } |
| 416 | case VMDebugRuntimeStatId::kArtGcBlockingGcCount: { |
| 417 | std::string output = std::to_string(heap->GetBlockingGcCount()); |
| 418 | return env->NewStringUTF(output.c_str()); |
| 419 | } |
| 420 | case VMDebugRuntimeStatId::kArtGcBlockingGcTime: { |
| 421 | std::string output = std::to_string(NsToMs(heap->GetBlockingGcTime())); |
| 422 | return env->NewStringUTF(output.c_str()); |
| 423 | } |
| 424 | case VMDebugRuntimeStatId::kArtGcGcCountRateHistogram: { |
| 425 | std::ostringstream output; |
| 426 | heap->DumpGcCountRateHistogram(output); |
| 427 | return env->NewStringUTF(output.str().c_str()); |
| 428 | } |
| 429 | case VMDebugRuntimeStatId::kArtGcBlockingGcCountRateHistogram: { |
| 430 | std::ostringstream output; |
| 431 | heap->DumpBlockingGcCountRateHistogram(output); |
| 432 | return env->NewStringUTF(output.str().c_str()); |
| 433 | } |
| 434 | default: |
| 435 | return nullptr; |
| 436 | } |
| 437 | } |
| 438 | |
Andreas Gampe | ca620d7 | 2016-11-08 08:09:33 -0800 | [diff] [blame] | 439 | static bool SetRuntimeStatValue(JNIEnv* env, |
| 440 | jobjectArray result, |
| 441 | VMDebugRuntimeStatId id, |
| 442 | const std::string& value) { |
Hiroshi Yamauchi | a1c9f01 | 2015-04-02 10:18:12 -0700 | [diff] [blame] | 443 | ScopedLocalRef<jstring> jvalue(env, env->NewStringUTF(value.c_str())); |
| 444 | if (jvalue.get() == nullptr) { |
| 445 | return false; |
| 446 | } |
| 447 | env->SetObjectArrayElement(result, static_cast<jint>(id), jvalue.get()); |
| 448 | return true; |
| 449 | } |
| 450 | |
| 451 | static jobjectArray VMDebug_getRuntimeStatsInternal(JNIEnv* env, jclass) { |
| 452 | jobjectArray result = env->NewObjectArray( |
| 453 | static_cast<jint>(VMDebugRuntimeStatId::kNumRuntimeStats), |
| 454 | WellKnownClasses::java_lang_String, |
| 455 | nullptr); |
| 456 | if (result == nullptr) { |
| 457 | return nullptr; |
| 458 | } |
| 459 | gc::Heap* heap = Runtime::Current()->GetHeap(); |
| 460 | if (!SetRuntimeStatValue(env, result, VMDebugRuntimeStatId::kArtGcGcCount, |
| 461 | std::to_string(heap->GetGcCount()))) { |
| 462 | return nullptr; |
| 463 | } |
| 464 | if (!SetRuntimeStatValue(env, result, VMDebugRuntimeStatId::kArtGcGcTime, |
| 465 | std::to_string(NsToMs(heap->GetGcTime())))) { |
| 466 | return nullptr; |
| 467 | } |
| 468 | if (!SetRuntimeStatValue(env, result, VMDebugRuntimeStatId::kArtGcBytesAllocated, |
| 469 | std::to_string(heap->GetBytesAllocatedEver()))) { |
| 470 | return nullptr; |
| 471 | } |
| 472 | if (!SetRuntimeStatValue(env, result, VMDebugRuntimeStatId::kArtGcBytesFreed, |
| 473 | std::to_string(heap->GetBytesFreedEver()))) { |
| 474 | return nullptr; |
| 475 | } |
| 476 | if (!SetRuntimeStatValue(env, result, VMDebugRuntimeStatId::kArtGcBlockingGcCount, |
| 477 | std::to_string(heap->GetBlockingGcCount()))) { |
| 478 | return nullptr; |
| 479 | } |
| 480 | if (!SetRuntimeStatValue(env, result, VMDebugRuntimeStatId::kArtGcBlockingGcTime, |
| 481 | std::to_string(NsToMs(heap->GetBlockingGcTime())))) { |
| 482 | return nullptr; |
| 483 | } |
| 484 | { |
| 485 | std::ostringstream output; |
| 486 | heap->DumpGcCountRateHistogram(output); |
| 487 | if (!SetRuntimeStatValue(env, result, VMDebugRuntimeStatId::kArtGcGcCountRateHistogram, |
| 488 | output.str())) { |
| 489 | return nullptr; |
| 490 | } |
| 491 | } |
| 492 | { |
| 493 | std::ostringstream output; |
| 494 | heap->DumpBlockingGcCountRateHistogram(output); |
| 495 | if (!SetRuntimeStatValue(env, result, VMDebugRuntimeStatId::kArtGcBlockingGcCountRateHistogram, |
| 496 | output.str())) { |
| 497 | return nullptr; |
| 498 | } |
| 499 | } |
| 500 | return result; |
| 501 | } |
| 502 | |
Leonard Mosescu | eb84221 | 2016-10-06 17:26:36 -0700 | [diff] [blame] | 503 | static void VMDebug_attachAgent(JNIEnv* env, jclass, jstring agent) { |
| 504 | if (agent == nullptr) { |
| 505 | ScopedObjectAccess soa(env); |
| 506 | ThrowNullPointerException("agent is null"); |
| 507 | return; |
| 508 | } |
| 509 | |
| 510 | if (!Dbg::IsJdwpAllowed()) { |
| 511 | ScopedObjectAccess soa(env); |
| 512 | ThrowSecurityException("Can't attach agent, process is not debuggable."); |
| 513 | return; |
| 514 | } |
| 515 | |
| 516 | std::string filename; |
| 517 | { |
| 518 | ScopedUtfChars chars(env, agent); |
| 519 | if (env->ExceptionCheck()) { |
| 520 | return; |
| 521 | } |
| 522 | filename = chars.c_str(); |
| 523 | } |
| 524 | |
| 525 | Runtime::Current()->AttachAgent(filename); |
| 526 | } |
| 527 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 528 | static JNINativeMethod gMethods[] = { |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 529 | NATIVE_METHOD(VMDebug, countInstancesOfClass, "(Ljava/lang/Class;Z)J"), |
Mathieu Chartier | f182085 | 2015-07-10 13:19:51 -0700 | [diff] [blame] | 530 | NATIVE_METHOD(VMDebug, countInstancesOfClasses, "([Ljava/lang/Class;Z)[J"), |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 531 | NATIVE_METHOD(VMDebug, crash, "()V"), |
Andreas Gampe | ad5df10 | 2017-10-04 16:31:08 -0700 | [diff] [blame^] | 532 | NATIVE_METHOD(VMDebug, dumpHprofData, "(Ljava/lang/String;I)V"), |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 533 | NATIVE_METHOD(VMDebug, dumpHprofDataDdms, "()V"), |
| 534 | NATIVE_METHOD(VMDebug, dumpReferenceTables, "()V"), |
| 535 | NATIVE_METHOD(VMDebug, getAllocCount, "(I)I"), |
Hiroshi Yamauchi | 09b07a9 | 2013-07-15 13:17:06 -0700 | [diff] [blame] | 536 | NATIVE_METHOD(VMDebug, getHeapSpaceStats, "([J)V"), |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 537 | NATIVE_METHOD(VMDebug, getInstructionCount, "([I)V"), |
Igor Murashkin | 3b6f440 | 2017-02-16 16:13:17 -0800 | [diff] [blame] | 538 | FAST_NATIVE_METHOD(VMDebug, getLoadedClassCount, "()I"), |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 539 | NATIVE_METHOD(VMDebug, getVmFeatureList, "()[Ljava/lang/String;"), |
| 540 | NATIVE_METHOD(VMDebug, infopoint, "(I)V"), |
Igor Murashkin | 3b6f440 | 2017-02-16 16:13:17 -0800 | [diff] [blame] | 541 | FAST_NATIVE_METHOD(VMDebug, isDebuggerConnected, "()Z"), |
| 542 | FAST_NATIVE_METHOD(VMDebug, isDebuggingEnabled, "()Z"), |
Jeff Hao | 64caa7d | 2013-08-29 11:18:01 -0700 | [diff] [blame] | 543 | NATIVE_METHOD(VMDebug, getMethodTracingMode, "()I"), |
Igor Murashkin | 3b6f440 | 2017-02-16 16:13:17 -0800 | [diff] [blame] | 544 | FAST_NATIVE_METHOD(VMDebug, lastDebuggerActivity, "()J"), |
| 545 | FAST_NATIVE_METHOD(VMDebug, printLoadedClasses, "(I)V"), |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 546 | NATIVE_METHOD(VMDebug, resetAllocCount, "(I)V"), |
| 547 | NATIVE_METHOD(VMDebug, resetInstructionCount, "()V"), |
| 548 | NATIVE_METHOD(VMDebug, startAllocCounting, "()V"), |
| 549 | NATIVE_METHOD(VMDebug, startEmulatorTracing, "()V"), |
| 550 | NATIVE_METHOD(VMDebug, startInstructionCounting, "()V"), |
Jeff Hao | 23009dc | 2013-08-22 15:36:42 -0700 | [diff] [blame] | 551 | NATIVE_METHOD(VMDebug, startMethodTracingDdmsImpl, "(IIZI)V"), |
Andreas Gampe | ad5df10 | 2017-10-04 16:31:08 -0700 | [diff] [blame^] | 552 | NATIVE_METHOD(VMDebug, startMethodTracingFd, "(Ljava/lang/String;IIIZIZ)V"), |
Jeff Hao | 4044bda | 2014-01-06 15:50:45 -0800 | [diff] [blame] | 553 | NATIVE_METHOD(VMDebug, startMethodTracingFilename, "(Ljava/lang/String;IIZI)V"), |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 554 | NATIVE_METHOD(VMDebug, stopAllocCounting, "()V"), |
| 555 | NATIVE_METHOD(VMDebug, stopEmulatorTracing, "()V"), |
| 556 | NATIVE_METHOD(VMDebug, stopInstructionCounting, "()V"), |
| 557 | NATIVE_METHOD(VMDebug, stopMethodTracing, "()V"), |
Igor Murashkin | 3b6f440 | 2017-02-16 16:13:17 -0800 | [diff] [blame] | 558 | FAST_NATIVE_METHOD(VMDebug, threadCpuTimeNanos, "()J"), |
Hiroshi Yamauchi | a1c9f01 | 2015-04-02 10:18:12 -0700 | [diff] [blame] | 559 | NATIVE_METHOD(VMDebug, getRuntimeStatInternal, "(I)Ljava/lang/String;"), |
Leonard Mosescu | eb84221 | 2016-10-06 17:26:36 -0700 | [diff] [blame] | 560 | NATIVE_METHOD(VMDebug, getRuntimeStatsInternal, "()[Ljava/lang/String;"), |
| 561 | NATIVE_METHOD(VMDebug, attachAgent, "(Ljava/lang/String;)V"), |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 562 | }; |
| 563 | |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 564 | void register_dalvik_system_VMDebug(JNIEnv* env) { |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 565 | REGISTER_NATIVE_METHODS("dalvik/system/VMDebug"); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | } // namespace art |