public final class VMDebug extends Object
android.os.Debug.| Modifier and Type | Method and Description |
|---|---|
static boolean |
cacheRegisterMap(String classAndMethodDesc)
Primes the register map cache.
|
static long |
countInstancesOfClass(Class klass,
boolean assignable)
Counts the instances of a class.
|
static long[] |
countInstancesOfClasses(Class[] classes,
boolean assignable)
Counts the instances of classes.
|
static void |
crash()
Crashes the VM.
|
static void |
dumpHprofData(String filename)
Dumps "hprof" data to the specified file.
|
static void |
dumpHprofData(String fileName,
FileDescriptor fd)
Dumps "hprof" heap data to a file, by name or descriptor.
|
static void |
dumpHprofDataDdms()
Collects "hprof" heap data and sends it to DDMS.
|
static void |
dumpReferenceTables()
Dumps the contents of the VM reference tables (e.g.
|
static int |
getAllocCount(int kind) |
static void |
getHeapSpaceStats(long[] data)
Export the heap per-space stats for dumpsys meminfo.
|
static void |
getInstructionCount(int[] counts) |
static int |
getLoadedClassCount()
Gets the number of loaded classes.
|
static int |
getMethodTracingMode()
Determine whether method tracing is currently active and what type is
active.
|
static String |
getRuntimeStat(String statName)
Returns the value of a particular runtime statistic or
null if no
such runtime statistic exists. |
static Map<String,String> |
getRuntimeStats()
Returns a map of the names/values of the runtime statistics
that
#getRuntimeStat() supports. |
static String[] |
getVmFeatureList()
Returns an array of strings that identify VM features.
|
static void |
infopoint(int id)
Together with gdb, provide a handy way to stop the VM at user-tagged
locations.
|
static boolean |
isDebuggerConnected()
Determines if a debugger is currently attached.
|
static boolean |
isDebuggingEnabled()
Determines if debugging is enabled in this VM.
|
static long |
lastDebuggerActivity()
Returns the time since the last known debugger activity.
|
static void |
printLoadedClasses(int flags)
Dumps a list of loaded class to the log file.
|
static void |
resetAllocCount(int kinds) |
static void |
resetInstructionCount() |
static int |
setAllocationLimit(int limit)
Deprecated.
|
static int |
setGlobalAllocationLimit(int limit)
Deprecated.
|
static void |
startAllocCounting()
Count the number and aggregate size of memory allocations between
two points.
|
static void |
startEmulatorTracing()
Starts sending Dalvik method trace info to the emulator.
|
static void |
startInstructionCounting()
Count the number of instructions executed between two points.
|
static void |
startMethodTracing()
Deprecated.
Not used, not needed.
|
static void |
startMethodTracing(String traceFileName,
FileDescriptor fd,
int bufferSize,
int flags,
boolean samplingEnabled,
int intervalUs)
Like startMethodTracing(String, int, int), but taking an already-opened
FileDescriptor in which the trace is written.
|
static void |
startMethodTracing(String traceFileName,
int bufferSize,
int flags,
boolean samplingEnabled,
int intervalUs)
Start method tracing, specifying a file name as well as a default
buffer size.
|
static void |
startMethodTracingDdms(int bufferSize,
int flags,
boolean samplingEnabled,
int intervalUs)
Starts method tracing without a backing file.
|
static void |
stopAllocCounting() |
static void |
stopEmulatorTracing()
Stops sending Dalvik method trace info to the emulator.
|
static void |
stopInstructionCounting() |
static void |
stopMethodTracing()
Stops method tracing.
|
static long |
threadCpuTimeNanos()
Get an indication of thread CPU usage.
|
public static final int TRACE_COUNT_ALLOCS
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_CLASS_INIT_COUNT
public static final int KIND_GLOBAL_CLASS_INIT_TIME
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_CLASS_INIT_COUNT
public static final int KIND_THREAD_CLASS_INIT_TIME
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
public static long lastDebuggerActivity()
public static boolean isDebuggingEnabled()
public static boolean isDebuggerConnected()
public static String[] getVmFeatureList()
@Deprecated public static void startMethodTracing()
0
flags.public static void startMethodTracing(String traceFileName, int bufferSize, int flags, boolean samplingEnabled, int intervalUs)
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.
traceFileName - name to give the trace filebufferSize - 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.samplingEnabled - if true, sample profiling is enabled. Otherwise,
method instrumentation is used.intervalUs - the time between samples in microseconds when
sampling is enabled.public static void startMethodTracing(String traceFileName, FileDescriptor fd, int bufferSize, int flags, boolean samplingEnabled, int intervalUs)
public static void startMethodTracingDdms(int bufferSize,
int flags,
boolean samplingEnabled,
int intervalUs)
public static int getMethodTracingMode()
public static void stopMethodTracing()
public static void startEmulatorTracing()
public static void stopEmulatorTracing()
public static long threadCpuTimeNanos()
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.
public static void startAllocCounting()
public static void stopAllocCounting()
public static int getAllocCount(int kind)
public static void resetAllocCount(int kinds)
@Deprecated public static int setAllocationLimit(int limit)
@Deprecated public static int setGlobalAllocationLimit(int limit)
public static void startInstructionCounting()
public static void stopInstructionCounting()
public static void getInstructionCount(int[] counts)
public static void resetInstructionCount()
public static void printLoadedClasses(int flags)
public static int getLoadedClassCount()
public static void dumpHprofData(String filename) throws IOException
filename - Full pathname of output file (e.g. "/sdcard/dump.hprof").UnsupportedOperationException - if the VM was built without
HPROF support.IOException - if an error occurs while opening or writing files.public static void dumpHprofDataDdms()
UnsupportedOperationException - if the VM was built without
HPROF support.public static void dumpHprofData(String fileName, FileDescriptor fd) throws IOException
fileName - Name of output file. If fd is non-null, the
file name is only used in log messages (and may be null).fd - Descriptor of open file that will receive the output.
If this is null, the fileName is used instead.IOExceptionpublic static boolean cacheRegisterMap(String classAndMethodDesc)
public static void dumpReferenceTables()
public static void crash()
public static void infopoint(int id)
public static long countInstancesOfClass(Class klass, boolean assignable)
klass - the class to be counted.assignable - if false, direct instances of klass are
counted. If true, instances that are
assignable to klass, as defined by
Class.isAssignableFrom(java.lang.Class<?>) are counted.public static long[] countInstancesOfClasses(Class[] classes, boolean assignable)
classes - the classes to be counted.assignable - if false, direct instances of klass are
counted. If true, instances that are
assignable to klass, as defined by
Class.isAssignableFrom(java.lang.Class<?>) are counted.public static void getHeapSpaceStats(long[] data)
data[0] : the application heap space size data[1] : the application heap space allocated bytes data[2] : the application heap space free bytes data[3] : the zygote heap space size data[4] : the zygote heap space allocated size data[5] : the zygote heap space free size data[6] : the large object space size data[7] : the large object space allocated bytes data[8] : the large object space free bytes
data - the array into which the stats are written.public static String getRuntimeStat(String statName)
null if no
such runtime statistic exists.statName - the name of the runtime statistic to look up.