Android
dalvik.system
public final class

dalvik.system.VMDebug

java.lang.Object
dalvik.system.VMDebug

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.

Summary

Constants

      Value  
String  DEFAULT_METHOD_TRACE_FILE_NAME  default method trace data file name   "/sdcard/dmtrace.trace" 
int  KIND_ALL_COUNTS    -1  0xffffffff 
int  KIND_GLOBAL_ALLOCATED_BYTES    0x00000002 
int  KIND_GLOBAL_ALLOCATED_OBJECTS    0x00000001 
int  KIND_GLOBAL_EXT_ALLOCATED_BYTES    8192  0x00002000 
int  KIND_GLOBAL_EXT_ALLOCATED_OBJECTS    4096  0x00001000 
int  KIND_GLOBAL_EXT_FREED_BYTES    32768  0x00008000 
int  KIND_GLOBAL_EXT_FREED_OBJECTS    16384  0x00004000 
int  KIND_GLOBAL_FREED_BYTES    0x00000008 
int  KIND_GLOBAL_FREED_OBJECTS    0x00000004 
int  KIND_GLOBAL_GC_INVOCATIONS    16  0x00000010 
int  KIND_THREAD_ALLOCATED_BYTES    131072  0x00020000 
int  KIND_THREAD_ALLOCATED_OBJECTS    65536  0x00010000 
int  KIND_THREAD_EXT_ALLOCATED_BYTES    536870912  0x20000000 
int  KIND_THREAD_EXT_ALLOCATED_OBJECTS    268435456  0x10000000 
int  KIND_THREAD_EXT_FREED_BYTES    -2147483648  0x80000000 
int  KIND_THREAD_EXT_FREED_OBJECTS    1073741824  0x40000000 
int  KIND_THREAD_FREED_BYTES    524288  0x00080000 
int  KIND_THREAD_FREED_OBJECTS    262144  0x00040000 
int  KIND_THREAD_GC_INVOCATIONS    1048576  0x00100000 
int  TRACE_COUNT_ALLOCS  flag for startMethodTracing(), which adds the results from startAllocCounting to the trace key file.  0x00000001 

Public Methods

      static    int  getAllocCount(int kind)
      static    void  getInstructionCount(int[] counts)
      static    int  getLoadedClassCount()
Get the number of loaded classes.
      static    boolean  isDebuggerConnected()
Determine if a debugger is currently attached.
      static    long  lastDebuggerActivity()
Time, in msec, since the last debugger activity.
      static    void  printLoadedClasses(int flags)
Dump a list of loaded class to the log file.
      static    void  resetAllocCount(int kinds)
      static    void  resetInstructionCount()
      static    int  setAllocationLimit(int limit)
Establish an object allocation limit in the current thread.
      static    int  setGlobalAllocationLimit(int limit)
Establish an object allocation limit for the entire VM.
      static    void  startAllocCounting()
Count the number and aggregate size of memory allocations between two points.
      static    void  startEmulatorTracing()
Start sending Dalvik method trace info to the emulator.
      static    void  startInstructionCounting()
Count the number of instructions executed between two points.
      static    void  startMethodTracing()
Start method tracing with default name, size, and with 0 flags.
      static    void  startMethodTracing(String traceFileName, int bufferSize, int flags)
Start method tracing, specifying a file name as well as a default buffer size.
      static    void  stopAllocCounting()
      static    void  stopEmulatorTracing()
Stop sending Dalvik method trace info to the emulator.
      static    void  stopInstructionCounting()
      static    void  stopMethodTracing()
Stop method tracing.
      static    long  threadCpuTimeNanos()
Get an indication of thread CPU usage.
Methods inherited from class java.lang.Object

Details

Constants

public static final String DEFAULT_METHOD_TRACE_FILE_NAME

default method trace data file name
Constant Value: "/sdcard/dmtrace.trace"

public static final int KIND_ALL_COUNTS

Constant Value: -1 (0xffffffff)

public static final int KIND_GLOBAL_ALLOCATED_BYTES

Constant Value: 2 (0x00000002)

public static final int KIND_GLOBAL_ALLOCATED_OBJECTS

Constant Value: 1 (0x00000001)

public static final int KIND_GLOBAL_EXT_ALLOCATED_BYTES

Constant Value: 8192 (0x00002000)

public static final int KIND_GLOBAL_EXT_ALLOCATED_OBJECTS

Constant Value: 4096 (0x00001000)

public static final int KIND_GLOBAL_EXT_FREED_BYTES

Constant Value: 32768 (0x00008000)

public static final int KIND_GLOBAL_EXT_FREED_OBJECTS

Constant Value: 16384 (0x00004000)

public static final int KIND_GLOBAL_FREED_BYTES

Constant Value: 8 (0x00000008)

public static final int KIND_GLOBAL_FREED_OBJECTS

Constant Value: 4 (0x00000004)

public static final int KIND_GLOBAL_GC_INVOCATIONS

Constant Value: 16 (0x00000010)

public static final int KIND_THREAD_ALLOCATED_BYTES

Constant Value: 131072 (0x00020000)

public static final int KIND_THREAD_ALLOCATED_OBJECTS

Constant Value: 65536 (0x00010000)

public static final int KIND_THREAD_EXT_ALLOCATED_BYTES

Constant Value: 536870912 (0x20000000)

public static final int KIND_THREAD_EXT_ALLOCATED_OBJECTS

Constant Value: 268435456 (0x10000000)

public static final int KIND_THREAD_EXT_FREED_BYTES

Constant Value: -2147483648 (0x80000000)

public static final int KIND_THREAD_EXT_FREED_OBJECTS

Constant Value: 1073741824 (0x40000000)

public static final int KIND_THREAD_FREED_BYTES

Constant Value: 524288 (0x00080000)

public static final int KIND_THREAD_FREED_OBJECTS

Constant Value: 262144 (0x00040000)

public static final int KIND_THREAD_GC_INVOCATIONS

Constant Value: 1048576 (0x00100000)

public static final int TRACE_COUNT_ALLOCS

flag for startMethodTracing(), which adds the results from startAllocCounting to the trace key file.
Constant Value: 1 (0x00000001)

Public Methods

public static int getAllocCount(int kind)

public static void getInstructionCount(int[] counts)

public static int getLoadedClassCount()

Get the number of loaded classes.

public static boolean isDebuggerConnected()

Determine if a debugger is currently attached.

public static long lastDebuggerActivity()

Time, in msec, since the last debugger activity. -1 if debugger is not connected.

public static void printLoadedClasses(int flags)

Dump a list of loaded class to the log file.

public static void resetAllocCount(int kinds)

public static void resetInstructionCount()

public static int setAllocationLimit(int limit)

Establish an object allocation limit in the current thread. Useful for catching regressions in code that is expected to operate without causing any allocations. Use -1 to disable the limit. Returns the previous limit.

public static int setGlobalAllocationLimit(int limit)

Establish an object allocation limit for the entire VM. Very much like setAllocationLimit(). Use -1 to disable the limit. Returns the previous limit.

public static void startAllocCounting()

Count the number and aggregate size of memory allocations between two points.

public static void startEmulatorTracing()

Start sending Dalvik method trace info to the emulator.

public static void startInstructionCounting()

Count the number of instructions executed between two points.

public static void startMethodTracing()

Start method tracing with default name, size, and with 0 flags.

public static void startMethodTracing(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.

Parameters

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

public static void stopAllocCounting()

public static void stopEmulatorTracing()

Stop sending Dalvik method trace info to the emulator.

public static void stopInstructionCounting()

public static void stopMethodTracing()

Stop method tracing.

public static long threadCpuTimeNanos()

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. On system which don't support this operation, the call returns -1.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56