FileDocCategorySizeDatePackage
VMDebug.javaAPI DocAndroid 1.5 API10144Wed May 06 22:41:02 BST 2009dalvik.system

VMDebug

public final class VMDebug extends Object
Provides access to some VM-specific debug features. Though this class and many of its members are public, this class is meant to be wrapped in a more friendly way for use by application developers. On the Android platform, the recommended way to access this functionality is through the class android.os.Debug.
cts
Please complete the spec.
since
Android 1.0

Fields Summary
public static final String
DEFAULT_METHOD_TRACE_FILE_NAME
Specifies the default method trace data file name.
public static final int
TRACE_COUNT_ALLOCS
flag for startMethodTracing(), which adds the results from startAllocCounting to the trace key file.
private static final int
KIND_ALLOCATED_OBJECTS
private static final int
KIND_ALLOCATED_BYTES
private static final int
KIND_FREED_OBJECTS
private static final int
KIND_FREED_BYTES
private static final int
KIND_GC_INVOCATIONS
private static final int
KIND_EXT_ALLOCATED_OBJECTS
private static final int
KIND_EXT_ALLOCATED_BYTES
private static final int
KIND_EXT_FREED_OBJECTS
private static final int
KIND_EXT_FREED_BYTES
public static final int
KIND_GLOBAL_ALLOCATED_OBJECTS
public static final int
KIND_GLOBAL_ALLOCATED_BYTES
public static final int
KIND_GLOBAL_FREED_OBJECTS
public static final int
KIND_GLOBAL_FREED_BYTES
public static final int
KIND_GLOBAL_GC_INVOCATIONS
public static final int
KIND_GLOBAL_EXT_ALLOCATED_OBJECTS
public static final int
KIND_GLOBAL_EXT_ALLOCATED_BYTES
public static final int
KIND_GLOBAL_EXT_FREED_OBJECTS
public static final int
KIND_GLOBAL_EXT_FREED_BYTES
public static final int
KIND_THREAD_ALLOCATED_OBJECTS
public static final int
KIND_THREAD_ALLOCATED_BYTES
public static final int
KIND_THREAD_FREED_OBJECTS
public static final int
KIND_THREAD_FREED_BYTES
public static final int
KIND_THREAD_GC_INVOCATIONS
public static final int
KIND_THREAD_EXT_ALLOCATED_OBJECTS
public static final int
KIND_THREAD_EXT_ALLOCATED_BYTES
public static final int
KIND_THREAD_EXT_FREED_OBJECTS
public static final int
KIND_THREAD_EXT_FREED_BYTES
public static final int
KIND_ALL_COUNTS
Constructors Summary
private VMDebug()


    /* all methods are static */
      
Methods Summary
public static native voiddumpHprofData(java.lang.String fileName)
Dump "hprof" data to the specified file. This will cause a GC. The VM may create a temporary file in the same directory.

param
fileName Full pathname of output file (e.g. "/sdcard/dump.hprof").
throws
UnsupportedOperationException if the VM was built without HPROF support.
throws
IOException if an error occurs while opening or writing files.

public static native intgetAllocCount(int kind)

public static native voidgetInstructionCount(int[] counts)

public static native intgetLoadedClassCount()
Gets the number of loaded classes.

return
the number of loaded classes

public static native booleanisDebuggerConnected()
Determines if a debugger is currently attached.

return
true if (and only if) a debugger is connected

public static native booleanisDebuggingEnabled()
Determines if debugging is enabled in this VM. If debugging is not enabled, a debugger cannot be attached.

return
true if debugging is enabled

public static native longlastDebuggerActivity()
Returns the time since the last known debugger activity.

return
the time in milliseconds, or -1 if the debugger is not connected

public static native voidprintLoadedClasses(int flags)
Dumps a list of loaded class to the log file.

static native voidprintThis(java.lang.Object thisThing, int count, int thing)

public static native voidresetAllocCount(int kinds)

public static native voidresetInstructionCount()

public static native intsetAllocationLimit(int limit)
Establishes an object allocation limit in the current thread. Useful for catching regressions in code that is expected to operate without causing any allocations. The limit is valid from the return of this method until it is either changed or the thread terminates.

param
limit the new limit. A value of 0 means not a single new object may be allocated. A value of -1 disables the limit.
return
the previous limit, or -1 if no limit was set
see
#setGlobalAllocationLimit(int)

public static native intsetGlobalAllocationLimit(int limit)
Establishes an object allocation limit for the entire VM. Useful for catching regressions in code that is expected to operate without causing any allocations. The limit is valid from the return of this method until it is either changed or the thread terminates.

param
limit the new limit. A value of 0 means not a single new object may be allocated. A value of -1 disables the limit.
return
the previous limit, or -1 if no limit was set
see
#setAllocationLimit(int)

public static native voidstartAllocCounting()
Count the number and aggregate size of memory allocations between two points.

private static voidstartClassPrep()

public static native voidstartEmulatorTracing()
Starts sending Dalvik method trace info to the emulator.

private static voidstartGC()

public static native voidstartInstructionCounting()
Count the number of instructions executed between two points.

public static voidstartMethodTracing()
Start method tracing with default name, size, and with 0 flags.

        startMethodTracing(DEFAULT_METHOD_TRACE_FILE_NAME, 0, 0);
    
public static native voidstartMethodTracing(java.lang.String traceFileName, int bufferSize, int flags)
Start method tracing, specifying a file name as well as a default buffer size. See Running the Traceview Debugging Program for information about reading trace files.

You can use either a fully qualified path and name, or just a name. If only a name is specified, the file will be created under the /sdcard/ directory. If a name is not given, the default is /sdcard/dmtrace.trace.

param
traceFileName name to give the trace file
param
bufferSize the maximum size of both files combined. If passed as 0, it defaults to 8MB.
param
flags flags to control method tracing. The only one that is currently defined is {@link #TRACE_COUNT_ALLOCS}.

public static native voidstopAllocCounting()

public static native voidstopEmulatorTracing()
Stops sending Dalvik method trace info to the emulator.

public static native voidstopInstructionCounting()

public static native voidstopMethodTracing()
Stops method tracing.

public static native longthreadCpuTimeNanos()
Get an indication of thread CPU usage. The value returned indicates the amount of time that the current thread has spent executing code or waiting for certain types of I/O.

The time is expressed in nanoseconds, and is only meaningful when compared to the result from an earlier call. Note that nanosecond resolution does not imply nanosecond accuracy.

return
the CPU usage. A value of -1 means the system does not support this feature.