The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | package dalvik.system; |
| 18 | |
Dianne Hackborn | 8205fe4 | 2009-06-23 19:21:10 -0700 | [diff] [blame] | 19 | import java.io.FileDescriptor; |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 20 | import java.io.IOException; |
| 21 | |
| 22 | /** |
| 23 | * Provides access to some VM-specific debug features. Though this class and |
| 24 | * many of its members are public, this class is meant to be wrapped in a more |
| 25 | * friendly way for use by application developers. On the Android platform, the |
| 26 | * recommended way to access this functionality is through the class |
| 27 | * <code>android.os.Debug</code>. |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame] | 28 | * |
Jesse Wilson | 8f27334 | 2010-04-01 15:44:05 -0700 | [diff] [blame] | 29 | * @hide |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 30 | */ |
| 31 | public final class VMDebug { |
| 32 | /** |
| 33 | * Specifies the default method trace data file name. |
Andy McFadden | 982744a | 2010-02-22 17:07:23 -0800 | [diff] [blame] | 34 | * |
Elliott Hughes | 99b4489 | 2013-06-06 15:19:50 -0700 | [diff] [blame] | 35 | * @deprecated Only used in one place, which is unused and deprecated. |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 36 | */ |
Elliott Hughes | 866e7ae | 2010-12-08 19:19:13 -0800 | [diff] [blame] | 37 | @Deprecated |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 38 | static public final String DEFAULT_METHOD_TRACE_FILE_NAME = "/sdcard/dmtrace.trace"; |
| 39 | |
| 40 | /** |
| 41 | * flag for startMethodTracing(), which adds the results from |
| 42 | * startAllocCounting to the trace key file. |
| 43 | */ |
| 44 | public static final int TRACE_COUNT_ALLOCS = 1; |
| 45 | |
| 46 | /* constants for getAllocCount */ |
Andy McFadden | 982744a | 2010-02-22 17:07:23 -0800 | [diff] [blame] | 47 | private static final int KIND_ALLOCATED_OBJECTS = 1<<0; |
| 48 | private static final int KIND_ALLOCATED_BYTES = 1<<1; |
| 49 | private static final int KIND_FREED_OBJECTS = 1<<2; |
| 50 | private static final int KIND_FREED_BYTES = 1<<3; |
| 51 | private static final int KIND_GC_INVOCATIONS = 1<<4; |
| 52 | private static final int KIND_CLASS_INIT_COUNT = 1<<5; |
| 53 | private static final int KIND_CLASS_INIT_TIME = 1<<6; |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 54 | private static final int KIND_EXT_ALLOCATED_OBJECTS = 1<<12; |
| 55 | private static final int KIND_EXT_ALLOCATED_BYTES = 1<<13; |
| 56 | private static final int KIND_EXT_FREED_OBJECTS = 1<<14; |
| 57 | private static final int KIND_EXT_FREED_BYTES = 1<<15; |
| 58 | |
| 59 | public static final int KIND_GLOBAL_ALLOCATED_OBJECTS = |
| 60 | KIND_ALLOCATED_OBJECTS; |
| 61 | public static final int KIND_GLOBAL_ALLOCATED_BYTES = |
| 62 | KIND_ALLOCATED_BYTES; |
| 63 | public static final int KIND_GLOBAL_FREED_OBJECTS = |
| 64 | KIND_FREED_OBJECTS; |
| 65 | public static final int KIND_GLOBAL_FREED_BYTES = |
| 66 | KIND_FREED_BYTES; |
| 67 | public static final int KIND_GLOBAL_GC_INVOCATIONS = |
| 68 | KIND_GC_INVOCATIONS; |
Andy McFadden | 982744a | 2010-02-22 17:07:23 -0800 | [diff] [blame] | 69 | public static final int KIND_GLOBAL_CLASS_INIT_COUNT = |
| 70 | KIND_CLASS_INIT_COUNT; |
| 71 | public static final int KIND_GLOBAL_CLASS_INIT_TIME = |
| 72 | KIND_CLASS_INIT_TIME; |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 73 | public static final int KIND_GLOBAL_EXT_ALLOCATED_OBJECTS = |
| 74 | KIND_EXT_ALLOCATED_OBJECTS; |
| 75 | public static final int KIND_GLOBAL_EXT_ALLOCATED_BYTES = |
| 76 | KIND_EXT_ALLOCATED_BYTES; |
| 77 | public static final int KIND_GLOBAL_EXT_FREED_OBJECTS = |
| 78 | KIND_EXT_FREED_OBJECTS; |
| 79 | public static final int KIND_GLOBAL_EXT_FREED_BYTES = |
| 80 | KIND_EXT_FREED_BYTES; |
| 81 | |
| 82 | public static final int KIND_THREAD_ALLOCATED_OBJECTS = |
| 83 | KIND_ALLOCATED_OBJECTS << 16; |
| 84 | public static final int KIND_THREAD_ALLOCATED_BYTES = |
| 85 | KIND_ALLOCATED_BYTES << 16; |
| 86 | public static final int KIND_THREAD_FREED_OBJECTS = |
| 87 | KIND_FREED_OBJECTS << 16; |
| 88 | public static final int KIND_THREAD_FREED_BYTES = |
| 89 | KIND_FREED_BYTES << 16; |
| 90 | public static final int KIND_THREAD_GC_INVOCATIONS = |
| 91 | KIND_GC_INVOCATIONS << 16; |
Andy McFadden | 982744a | 2010-02-22 17:07:23 -0800 | [diff] [blame] | 92 | public static final int KIND_THREAD_CLASS_INIT_COUNT = |
| 93 | KIND_CLASS_INIT_COUNT << 16; |
| 94 | public static final int KIND_THREAD_CLASS_INIT_TIME = |
| 95 | KIND_CLASS_INIT_TIME << 16; |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 96 | public static final int KIND_THREAD_EXT_ALLOCATED_OBJECTS = |
| 97 | KIND_EXT_ALLOCATED_OBJECTS << 16; |
| 98 | public static final int KIND_THREAD_EXT_ALLOCATED_BYTES = |
| 99 | KIND_EXT_ALLOCATED_BYTES << 16; |
| 100 | public static final int KIND_THREAD_EXT_FREED_OBJECTS = |
| 101 | KIND_EXT_FREED_OBJECTS << 16; |
| 102 | public static final int KIND_THREAD_EXT_FREED_BYTES = |
| 103 | KIND_EXT_FREED_BYTES << 16; |
| 104 | |
| 105 | public static final int KIND_ALL_COUNTS = 0xffffffff; |
| 106 | |
| 107 | /* all methods are static */ |
| 108 | private VMDebug() {} |
| 109 | |
| 110 | /** |
| 111 | * Returns the time since the last known debugger activity. |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame] | 112 | * |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 113 | * @return the time in milliseconds, or -1 if the debugger is not connected |
| 114 | */ |
| 115 | public static native long lastDebuggerActivity(); |
| 116 | |
| 117 | /** |
| 118 | * Determines if debugging is enabled in this VM. If debugging is not |
| 119 | * enabled, a debugger cannot be attached. |
| 120 | * |
| 121 | * @return true if debugging is enabled |
| 122 | */ |
| 123 | public static native boolean isDebuggingEnabled(); |
| 124 | |
| 125 | /** |
| 126 | * Determines if a debugger is currently attached. |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame] | 127 | * |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 128 | * @return true if (and only if) a debugger is connected |
| 129 | */ |
| 130 | public static native boolean isDebuggerConnected(); |
| 131 | |
| 132 | /** |
Andy McFadden | d3c419d | 2010-01-22 07:23:40 -0800 | [diff] [blame] | 133 | * Returns an array of strings that identify VM features. This is |
| 134 | * used by DDMS to determine what sorts of operations the VM can |
| 135 | * perform. |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 136 | */ |
Andy McFadden | d3c419d | 2010-01-22 07:23:40 -0800 | [diff] [blame] | 137 | public static native String[] getVmFeatureList(); |
| 138 | |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 139 | /** |
| 140 | * Start method tracing with default name, size, and with <code>0</code> |
| 141 | * flags. |
Andy McFadden | 982744a | 2010-02-22 17:07:23 -0800 | [diff] [blame] | 142 | * |
Elliott Hughes | 99b4489 | 2013-06-06 15:19:50 -0700 | [diff] [blame] | 143 | * @deprecated Not used, not needed. |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 144 | */ |
Elliott Hughes | 866e7ae | 2010-12-08 19:19:13 -0800 | [diff] [blame] | 145 | @Deprecated |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 146 | public static void startMethodTracing() { |
| 147 | startMethodTracing(DEFAULT_METHOD_TRACE_FILE_NAME, 0, 0); |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Start method tracing, specifying a file name as well as a default |
| 152 | * buffer size. See <a |
Scott Main | 016a87c | 2009-04-24 13:41:43 -0700 | [diff] [blame] | 153 | * href="{@docRoot}guide/developing/tools/traceview.html"> Running the |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 154 | * Traceview Debugging Program</a> for information about reading |
| 155 | * trace files. |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame] | 156 | * |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 157 | * <p>You can use either a fully qualified path and |
| 158 | * name, or just a name. If only a name is specified, the file will |
| 159 | * be created under the /sdcard/ directory. If a name is not given, |
| 160 | * the default is /sdcard/dmtrace.trace.</p> |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame] | 161 | * |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 162 | * @param traceFileName name to give the trace file |
| 163 | * @param bufferSize the maximum size of both files combined. If passed |
| 164 | * as <code>0</code>, it defaults to 8MB. |
| 165 | * @param flags flags to control method tracing. The only one that |
| 166 | * is currently defined is {@link #TRACE_COUNT_ALLOCS}. |
| 167 | */ |
Elliott Hughes | c2d0a1f | 2012-12-04 11:54:39 -0800 | [diff] [blame] | 168 | public static void startMethodTracing(String traceFileName, int bufferSize, int flags) { |
Andy McFadden | 93714a1 | 2010-01-22 16:36:30 -0800 | [diff] [blame] | 169 | |
| 170 | if (traceFileName == null) { |
Elliott Hughes | c2d0a1f | 2012-12-04 11:54:39 -0800 | [diff] [blame] | 171 | throw new NullPointerException("traceFileName == null"); |
Andy McFadden | 93714a1 | 2010-01-22 16:36:30 -0800 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | startMethodTracingNative(traceFileName, null, bufferSize, flags); |
Dianne Hackborn | 8205fe4 | 2009-06-23 19:21:10 -0700 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Like startMethodTracing(String, int, int), but taking an already-opened |
| 179 | * FileDescriptor in which the trace is written. The file name is also |
| 180 | * supplied simply for logging. Makes a dup of the file descriptor. |
Dianne Hackborn | 8205fe4 | 2009-06-23 19:21:10 -0700 | [diff] [blame] | 181 | */ |
Andy McFadden | 93714a1 | 2010-01-22 16:36:30 -0800 | [diff] [blame] | 182 | public static void startMethodTracing(String traceFileName, |
| 183 | FileDescriptor fd, int bufferSize, int flags) |
| 184 | { |
Elliott Hughes | c2d0a1f | 2012-12-04 11:54:39 -0800 | [diff] [blame] | 185 | if (traceFileName == null) { |
| 186 | throw new NullPointerException("traceFileName == null"); |
| 187 | } |
| 188 | if (fd == null) { |
| 189 | throw new NullPointerException("fd == null"); |
Andy McFadden | 93714a1 | 2010-01-22 16:36:30 -0800 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | startMethodTracingNative(traceFileName, fd, bufferSize, flags); |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Starts method tracing without a backing file. When stopMethodTracing |
| 197 | * is called, the result is sent directly to DDMS. (If DDMS is not |
| 198 | * attached when tracing ends, the profiling data will be discarded.) |
Andy McFadden | 93714a1 | 2010-01-22 16:36:30 -0800 | [diff] [blame] | 199 | */ |
| 200 | public static void startMethodTracingDdms(int bufferSize, int flags) { |
| 201 | startMethodTracingNative(null, null, bufferSize, flags); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Implements all startMethodTracing variants. |
Andy McFadden | 93714a1 | 2010-01-22 16:36:30 -0800 | [diff] [blame] | 206 | */ |
| 207 | private static native void startMethodTracingNative(String traceFileName, |
Dianne Hackborn | 8205fe4 | 2009-06-23 19:21:10 -0700 | [diff] [blame] | 208 | FileDescriptor fd, int bufferSize, int flags); |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 209 | |
| 210 | /** |
The Android Open Source Project | 5d287a9 | 2009-03-18 22:20:24 -0700 | [diff] [blame] | 211 | * Determine whether method tracing is currently active. |
The Android Open Source Project | 5d287a9 | 2009-03-18 22:20:24 -0700 | [diff] [blame] | 212 | */ |
| 213 | public static native boolean isMethodTracingActive(); |
| 214 | |
| 215 | /** |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 216 | * Stops method tracing. |
| 217 | */ |
| 218 | public static native void stopMethodTracing(); |
| 219 | |
| 220 | /** |
| 221 | * Starts sending Dalvik method trace info to the emulator. |
| 222 | */ |
| 223 | public static native void startEmulatorTracing(); |
| 224 | |
| 225 | /** |
| 226 | * Stops sending Dalvik method trace info to the emulator. |
| 227 | */ |
| 228 | public static native void stopEmulatorTracing(); |
| 229 | |
| 230 | /** |
| 231 | * Get an indication of thread CPU usage. The value returned indicates the |
| 232 | * amount of time that the current thread has spent executing code or |
| 233 | * waiting for certain types of I/O. |
| 234 | * <p> |
| 235 | * The time is expressed in nanoseconds, and is only meaningful when |
| 236 | * compared to the result from an earlier call. Note that nanosecond |
| 237 | * resolution does not imply nanosecond accuracy. |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame] | 238 | * |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 239 | * @return the CPU usage. A value of -1 means the system does not support |
| 240 | * this feature. |
| 241 | */ |
| 242 | public static native long threadCpuTimeNanos(); |
| 243 | |
| 244 | /** |
| 245 | * Count the number and aggregate size of memory allocations between |
| 246 | * two points. |
| 247 | */ |
| 248 | public static native void startAllocCounting(); |
| 249 | public static native void stopAllocCounting(); |
| 250 | public static native int getAllocCount(int kind); |
| 251 | public static native void resetAllocCount(int kinds); |
| 252 | |
| 253 | /** |
Carl Shapiro | 3ca860a | 2011-01-12 15:53:02 -0800 | [diff] [blame] | 254 | * This method exists for binary compatibility. It was part of |
| 255 | * the allocation limits API which was removed in Honeycomb. |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 256 | */ |
Carl Shapiro | 3ca860a | 2011-01-12 15:53:02 -0800 | [diff] [blame] | 257 | @Deprecated |
| 258 | public static int setAllocationLimit(int limit) { |
| 259 | return -1; |
| 260 | } |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 261 | |
| 262 | /** |
Carl Shapiro | 3ca860a | 2011-01-12 15:53:02 -0800 | [diff] [blame] | 263 | * This method exists for binary compatibility. It was part of |
| 264 | * the allocation limits API which was removed in Honeycomb. |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 265 | */ |
Carl Shapiro | 3ca860a | 2011-01-12 15:53:02 -0800 | [diff] [blame] | 266 | @Deprecated |
| 267 | public static int setGlobalAllocationLimit(int limit) { |
| 268 | return -1; |
| 269 | } |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 270 | |
| 271 | /** |
| 272 | * Count the number of instructions executed between two points. |
| 273 | */ |
| 274 | public static native void startInstructionCounting(); |
| 275 | public static native void stopInstructionCounting(); |
| 276 | public static native void getInstructionCount(int[] counts); |
| 277 | public static native void resetInstructionCount(); |
| 278 | |
| 279 | /** |
| 280 | * Dumps a list of loaded class to the log file. |
| 281 | */ |
| 282 | public static native void printLoadedClasses(int flags); |
| 283 | |
| 284 | /** |
| 285 | * Gets the number of loaded classes. |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame] | 286 | * |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 287 | * @return the number of loaded classes |
| 288 | */ |
| 289 | public static native int getLoadedClassCount(); |
| 290 | |
| 291 | /** |
Andy McFadden | 478f5f9 | 2010-07-09 16:49:05 -0700 | [diff] [blame] | 292 | * Dumps "hprof" data to the specified file. This may cause a GC. |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 293 | * |
| 294 | * The VM may create a temporary file in the same directory. |
| 295 | * |
Elliott Hughes | c2d0a1f | 2012-12-04 11:54:39 -0800 | [diff] [blame] | 296 | * @param filename Full pathname of output file (e.g. "/sdcard/dump.hprof"). |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 297 | * @throws UnsupportedOperationException if the VM was built without |
| 298 | * HPROF support. |
| 299 | * @throws IOException if an error occurs while opening or writing files. |
| 300 | */ |
Elliott Hughes | c2d0a1f | 2012-12-04 11:54:39 -0800 | [diff] [blame] | 301 | public static void dumpHprofData(String filename) throws IOException { |
| 302 | if (filename == null) { |
| 303 | throw new NullPointerException("filename == null"); |
| 304 | } |
| 305 | dumpHprofData(filename, null); |
Andy McFadden | 478f5f9 | 2010-07-09 16:49:05 -0700 | [diff] [blame] | 306 | } |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 307 | |
Andy McFadden | b24c385 | 2009-04-08 00:35:55 -0700 | [diff] [blame] | 308 | /** |
Andy McFadden | 478f5f9 | 2010-07-09 16:49:05 -0700 | [diff] [blame] | 309 | * Collects "hprof" heap data and sends it to DDMS. This may cause a GC. |
Andy McFadden | 21fc59c | 2010-01-28 17:01:39 -0800 | [diff] [blame] | 310 | * |
| 311 | * @throws UnsupportedOperationException if the VM was built without |
| 312 | * HPROF support. |
Andy McFadden | 21fc59c | 2010-01-28 17:01:39 -0800 | [diff] [blame] | 313 | */ |
| 314 | public static native void dumpHprofDataDdms(); |
| 315 | |
| 316 | /** |
Andy McFadden | 478f5f9 | 2010-07-09 16:49:05 -0700 | [diff] [blame] | 317 | * Dumps "hprof" heap data to a file, by name or descriptor. |
| 318 | * |
| 319 | * @param fileName Name of output file. If fd is non-null, the |
| 320 | * file name is only used in log messages (and may be null). |
| 321 | * @param fd Descriptor of open file that will receive the output. |
| 322 | * If this is null, the fileName is used instead. |
Andy McFadden | 478f5f9 | 2010-07-09 16:49:05 -0700 | [diff] [blame] | 323 | */ |
| 324 | public static native void dumpHprofData(String fileName, FileDescriptor fd) |
| 325 | throws IOException; |
| 326 | |
| 327 | /** |
Andy McFadden | b24c385 | 2009-04-08 00:35:55 -0700 | [diff] [blame] | 328 | * Primes the register map cache. |
Andy McFadden | b24c385 | 2009-04-08 00:35:55 -0700 | [diff] [blame] | 329 | */ |
| 330 | public static native boolean cacheRegisterMap(String classAndMethodDesc); |
| 331 | |
Andy McFadden | cd9ef3b | 2009-07-31 13:54:59 -0700 | [diff] [blame] | 332 | /** |
Andy McFadden | bb4b5ab | 2009-10-22 17:24:45 -0700 | [diff] [blame] | 333 | * Dumps the contents of the VM reference tables (e.g. JNI locals and |
| 334 | * globals) to the log file. |
Andy McFadden | bb4b5ab | 2009-10-22 17:24:45 -0700 | [diff] [blame] | 335 | */ |
| 336 | public static native void dumpReferenceTables(); |
| 337 | |
| 338 | /** |
| 339 | * Crashes the VM. Seriously. Dumps the interpreter stack trace for |
| 340 | * the current thread and then aborts the VM so you can see the native |
| 341 | * stack trace. Useful for figuring out how you got somewhere when |
| 342 | * lots of native code is involved. |
Andy McFadden | cd9ef3b | 2009-07-31 13:54:59 -0700 | [diff] [blame] | 343 | */ |
| 344 | public static native void crash(); |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 345 | |
Ben Cheng | dd60d48 | 2010-03-12 16:11:49 -0800 | [diff] [blame] | 346 | /** |
| 347 | * Together with gdb, provide a handy way to stop the VM at user-tagged |
| 348 | * locations. |
Ben Cheng | dd60d48 | 2010-03-12 16:11:49 -0800 | [diff] [blame] | 349 | */ |
| 350 | public static native void infopoint(int id); |
| 351 | |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 352 | /* |
| 353 | * Fake method, inserted into dmtrace output when the garbage collector |
| 354 | * runs. Not actually called. |
| 355 | */ |
| 356 | private static void startGC() {} |
| 357 | |
| 358 | /* |
| 359 | * Fake method, inserted into dmtrace output during class preparation |
| 360 | * (loading and linking, but not verification or initialization). Not |
| 361 | * actually called. |
| 362 | */ |
| 363 | private static void startClassPrep() {} |
Carl Shapiro | 2e386d4 | 2010-08-16 21:40:20 -0700 | [diff] [blame] | 364 | |
| 365 | /** |
Carl Shapiro | 9e2e604 | 2010-11-04 15:18:22 -0700 | [diff] [blame] | 366 | * Counts the instances of a class. |
Carl Shapiro | 2e386d4 | 2010-08-16 21:40:20 -0700 | [diff] [blame] | 367 | * |
Carl Shapiro | 9e2e604 | 2010-11-04 15:18:22 -0700 | [diff] [blame] | 368 | * @param klass the class to be counted. |
| 369 | * @param assignable if false, direct instances of klass are |
| 370 | * counted. If true, instances that are |
| 371 | * assignable to klass, as defined by |
| 372 | * {@link Class#isAssignableFrom} are counted. |
Carl Shapiro | 7921449 | 2011-01-12 14:40:13 -0800 | [diff] [blame] | 373 | * @return the number of matching instances. |
Carl Shapiro | 2e386d4 | 2010-08-16 21:40:20 -0700 | [diff] [blame] | 374 | */ |
Carl Shapiro | 9e2e604 | 2010-11-04 15:18:22 -0700 | [diff] [blame] | 375 | public static native long countInstancesOfClass(Class klass, boolean assignable); |
Hiroshi Yamauchi | 929e3dc | 2013-07-15 14:15:53 -0700 | [diff] [blame] | 376 | |
| 377 | /** |
| 378 | * Export the heap per-space stats for dumpsys meminfo. |
| 379 | * |
| 380 | * The content of the array is: |
| 381 | * |
| 382 | * <pre> |
| 383 | * data[0] : the application heap space size |
| 384 | * data[1] : the application heap space allocated bytes |
| 385 | * data[2] : the application heap space free bytes |
| 386 | * data[3] : the zygote heap space size |
| 387 | * data[4] : the zygote heap space allocated size |
| 388 | * data[5] : the zygote heap space free size |
| 389 | * data[6] : the large object space size |
| 390 | * data[7] : the large object space allocated bytes |
| 391 | * data[8] : the large object space free bytes |
| 392 | * </pre> |
| 393 | * |
| 394 | * @param data the array into which the stats are written. |
| 395 | */ |
| 396 | public static native void getHeapSpaceStats(long[] data); |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 397 | } |