public final class Debug extends Object
Logging Trace Files
Debug can create log files that give details about an application, such as
a call stack and start/stop times for any running methods. See Traceview: A Graphical Log Viewer for
information about reading trace files. To start logging trace files, call one
of the startMethodTracing() methods. To stop tracing, call
stopMethodTracing()
.
Modifier and Type | Class and Description |
---|---|
static interface |
Debug.DebugProperty
Annotation to put on fields you want to set with
setFieldsOn(Class, boolean) . |
static class |
Debug.InstructionCount
Deprecated.
Instruction counting is no longer supported.
|
static class |
Debug.MemoryInfo
This class is used to retrieved various statistics about the memory mappings for this
process.
|
Modifier and Type | Field and Description |
---|---|
static int |
MEMINFO_BUFFERS |
static int |
MEMINFO_CACHED |
static int |
MEMINFO_COUNT |
static int |
MEMINFO_FREE |
static int |
MEMINFO_KERNEL_STACK |
static int |
MEMINFO_MAPPED |
static int |
MEMINFO_PAGE_TABLES |
static int |
MEMINFO_SHMEM |
static int |
MEMINFO_SLAB |
static int |
MEMINFO_SWAP_FREE |
static int |
MEMINFO_SWAP_TOTAL |
static int |
MEMINFO_TOTAL |
static int |
MEMINFO_VM_ALLOC_USED |
static int |
MEMINFO_ZRAM_TOTAL |
static int |
SHOW_CLASSLOADER |
static int |
SHOW_FULL_DETAIL
Flags for printLoadedClasses().
|
static int |
SHOW_INITIALIZED |
static int |
TRACE_COUNT_ALLOCS
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
cacheRegisterMap(String classAndMethodDesc)
Primes the register map cache.
|
static void |
changeDebugPort(int port)
Deprecated.
no longer needed or useful
|
static long |
countInstancesOfClass(Class cls)
Returns a count of the extant instances of a class.
|
static void |
dumpHprofData(String fileName)
Dump "hprof" data to the specified file.
|
static void |
dumpHprofData(String fileName,
FileDescriptor fd)
Like dumpHprofData(String), but takes an already-opened
FileDescriptor to which the trace is written.
|
static void |
dumpHprofDataDdms()
Collect "hprof" and send it to DDMS.
|
static void |
dumpNativeBacktraceToFile(int pid,
String file)
Have the stack traces of the given native process dumped to the
specified file.
|
static void |
dumpNativeHeap(FileDescriptor fd)
Writes native heap data to the specified file descriptor.
|
static void |
dumpReferenceTables()
Dumps the contents of VM reference tables (e.g.
|
static boolean |
dumpService(String name,
FileDescriptor fd,
String[] args)
Get a debugging dump of a system service by name.
|
static void |
enableEmulatorTraceOutput()
Enable "emulator traces", in which information about the current
method is made available to the "emulator -trace" feature.
|
static int |
getBinderDeathObjectCount()
Returns the number of death notification links to Binder objects that
exist in the current process.
|
static int |
getBinderLocalObjectCount()
Returns the number of active local Binder objects that exist in the
current process.
|
static int |
getBinderProxyObjectCount()
Returns the number of references to remote proxy Binder objects that
exist in the current process.
|
static int |
getBinderReceivedTransactions()
Returns the number of received transactions from the binder driver.
|
static int |
getBinderSentTransactions()
Returns the number of sent transactions from this process.
|
static String |
getCaller() |
static String |
getCallers(int depth)
Return a string consisting of methods and locations at multiple call stack levels.
|
static String |
getCallers(int start,
int depth)
Return a string consisting of methods and locations at multiple call stack levels.
|
static String |
getCallers(int depth,
String linePrefix)
Like
getCallers(int) , but each location is append to the string
as a new line with linePrefix in front of it. |
static int |
getGlobalAllocCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static int |
getGlobalAllocSize()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static int |
getGlobalClassInitCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static int |
getGlobalClassInitTime()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static int |
getGlobalExternalAllocCount()
Deprecated.
This method is now obsolete.
|
static int |
getGlobalExternalAllocSize()
Deprecated.
This method is now obsolete.
|
static int |
getGlobalExternalFreedCount()
Deprecated.
This method is now obsolete.
|
static int |
getGlobalExternalFreedSize()
Deprecated.
This method is now obsolete.
|
static int |
getGlobalFreedCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static int |
getGlobalFreedSize()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static int |
getGlobalGcInvocationCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static int |
getLoadedClassCount()
Get the number of loaded classes.
|
static void |
getMemInfo(long[] outSizes)
Retrieves /proc/meminfo.
|
static void |
getMemoryInfo(Debug.MemoryInfo memoryInfo)
Retrieves information about this processes memory usages.
|
static void |
getMemoryInfo(int pid,
Debug.MemoryInfo memoryInfo)
Note: currently only works when the requested pid has the same UID
as the caller.
|
static int |
getMethodTracingMode()
Determine whether method tracing is currently active and what type is
active.
|
static long |
getNativeHeapAllocatedSize()
Returns the amount of allocated memory in the native heap.
|
static long |
getNativeHeapFreeSize()
Returns the amount of free memory in the native heap.
|
static long |
getNativeHeapSize()
Returns the size of the native heap.
|
static long |
getPss()
Retrieves the PSS memory used by the process as given by the
smaps.
|
static long |
getPss(int pid,
long[] outUssSwapPss,
long[] outMemtrack)
Retrieves the PSS memory used by the process as given by the
smaps.
|
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(String) supports. |
static int |
getThreadAllocCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static int |
getThreadAllocSize()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static int |
getThreadExternalAllocCount()
Deprecated.
This method is now obsolete.
|
static int |
getThreadExternalAllocSize()
Deprecated.
This method is now obsolete.
|
static int |
getThreadGcInvocationCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static String |
getUnreachableMemory(int limit,
boolean contents)
Get description of unreachable native memory.
|
static String[] |
getVmFeatureList()
Returns an array of strings that identify VM features.
|
static boolean |
isDebuggerConnected()
Determine if a debugger is currently attached.
|
static void |
printLoadedClasses(int flags)
Dump a list of all currently loaded class to the log file.
|
static void |
resetAllCounts()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
resetGlobalAllocCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
resetGlobalAllocSize()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
resetGlobalClassInitCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
resetGlobalClassInitTime()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
resetGlobalExternalAllocCount()
Deprecated.
This method is now obsolete.
|
static void |
resetGlobalExternalAllocSize()
Deprecated.
This method is now obsolete.
|
static void |
resetGlobalExternalFreedCount()
Deprecated.
This method is now obsolete.
|
static void |
resetGlobalExternalFreedSize()
Deprecated.
This method is now obsolete.
|
static void |
resetGlobalFreedCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
resetGlobalFreedSize()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
resetGlobalGcInvocationCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
resetThreadAllocCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
resetThreadAllocSize()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
resetThreadExternalAllocCount()
Deprecated.
This method is now obsolete.
|
static void |
resetThreadExternalAllocSize()
Deprecated.
This method is now obsolete.
|
static void |
resetThreadGcInvocationCount()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static int |
setAllocationLimit(int limit)
Deprecated.
This method is now obsolete.
|
static void |
setFieldsOn(Class<?> cl)
Equivalent to
setFieldsOn(cl, false) . |
static void |
setFieldsOn(Class<?> cl,
boolean partial)
Reflectively sets static fields of a class based on internal debugging
properties.
|
static int |
setGlobalAllocationLimit(int limit)
Deprecated.
This method is now obsolete.
|
static void |
startAllocCounting()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
startMethodTracing()
Start method tracing with default log name and buffer size.
|
static void |
startMethodTracing(String tracePath)
Start method tracing, specifying the trace log file path.
|
static void |
startMethodTracing(String traceName,
FileDescriptor fd,
int bufferSize,
int flags)
Like startMethodTracing(String, int, int), but taking an already-opened
FileDescriptor in which the trace is written.
|
static void |
startMethodTracing(String tracePath,
int bufferSize)
Start method tracing, specifying the trace log file name and the buffer
size.
|
static void |
startMethodTracing(String tracePath,
int bufferSize,
int flags)
Start method tracing, specifying the trace log file name, the buffer
size, and flags.
|
static void |
startMethodTracingDdms(int bufferSize,
int flags,
boolean samplingEnabled,
int intervalUs)
Starts method tracing without a backing file.
|
static void |
startMethodTracingSampling(String tracePath,
int bufferSize,
int intervalUs)
Start sampling-based method tracing, specifying the trace log file name,
the buffer size, and the sampling interval.
|
static void |
startNativeTracing()
Enable qemu tracing.
|
static void |
stopAllocCounting()
Deprecated.
Accurate counting is a burden on the runtime and may be removed.
|
static void |
stopMethodTracing()
Stop method tracing.
|
static void |
stopNativeTracing()
Stop qemu tracing.
|
static long |
threadCpuTimeNanos()
Get an indication of thread CPU usage.
|
static void |
waitForDebugger()
Wait until a debugger attaches.
|
static boolean |
waitingForDebugger()
Returns "true" if one or more threads is waiting for a debugger
to attach.
|
@Deprecated public static final int TRACE_COUNT_ALLOCS
public static final int SHOW_FULL_DETAIL
public static final int SHOW_CLASSLOADER
public static final int SHOW_INITIALIZED
public static final int MEMINFO_TOTAL
public static final int MEMINFO_FREE
public static final int MEMINFO_BUFFERS
public static final int MEMINFO_CACHED
public static final int MEMINFO_SHMEM
public static final int MEMINFO_SLAB
public static final int MEMINFO_SWAP_TOTAL
public static final int MEMINFO_SWAP_FREE
public static final int MEMINFO_ZRAM_TOTAL
public static final int MEMINFO_MAPPED
public static final int MEMINFO_VM_ALLOC_USED
public static final int MEMINFO_PAGE_TABLES
public static final int MEMINFO_KERNEL_STACK
public static final int MEMINFO_COUNT
public static void waitForDebugger()
public static boolean waitingForDebugger()
public static boolean isDebuggerConnected()
public static String[] getVmFeatureList()
@Deprecated public static void changeDebugPort(int port)
public static void startNativeTracing()
emulator -trace foo
The main differences between this and startMethodTracing()
are
that tracing in the qemu emulator traces every cpu instruction of every
process, including kernel code, so we have more complete information,
including all context switches. We can also get more detailed information
such as cache misses. The sequence of calls is determined by
post-processing the instruction trace. The qemu tracing is also done
without modifying the application or perturbing the timing of calls
because no instrumentation is added to the application being traced.
One limitation of using this method compared to using
startMethodTracing()
on the real device is that the emulator
does not model all of the real hardware effects such as memory and
bus contention. The emulator also has a simple cache model and cannot
capture all the complexities of a real cache.
public static void stopNativeTracing()
startNativeTracing()
to start tracing.
Tracing can be started and stopped as many times as desired. When the qemu emulator itself is stopped then the buffered trace records are flushed and written to the trace file. In fact, it is not necessary to call this method at all; simply killing qemu is sufficient. But starting and stopping a trace is useful for examining a specific region of code.
public static void enableEmulatorTraceOutput()
startNativeTracing()
.public static void startMethodTracing()
By default, the trace file is called "dmtrace.trace" and it's placed
under your package-specific directory on primary shared/external storage,
as returned by Context.getExternalFilesDir(String)
.
See Traceview: A Graphical Log Viewer for information about reading trace files.
When method tracing is enabled, the VM will run more slowly than usual,
so the timings from the trace files should only be considered in relative
terms (e.g. was run #1 faster than run #2). The times for native methods
will not change, so don't try to use this to compare the performance of
interpreted and native implementations of the same method. As an
alternative, consider using sampling-based method tracing via
startMethodTracingSampling(String, int, int)
or "native" tracing
in the emulator via startNativeTracing()
.
public static void startMethodTracing(String tracePath)
When a relative file path is given, the trace file will be placed under
your package-specific directory on primary shared/external storage, as
returned by Context.getExternalFilesDir(String)
.
See Traceview: A Graphical Log Viewer for information about reading trace files.
When method tracing is enabled, the VM will run more slowly than usual,
so the timings from the trace files should only be considered in relative
terms (e.g. was run #1 faster than run #2). The times for native methods
will not change, so don't try to use this to compare the performance of
interpreted and native implementations of the same method. As an
alternative, consider using sampling-based method tracing via
startMethodTracingSampling(String, int, int)
or "native" tracing
in the emulator via startNativeTracing()
.
tracePath
- Path to the trace log file to create. If null
,
this will default to "dmtrace.trace". If the file already
exists, it will be truncated. If the path given does not end
in ".trace", it will be appended for you.public static void startMethodTracing(String tracePath, int bufferSize)
When a relative file path is given, the trace file will be placed under
your package-specific directory on primary shared/external storage, as
returned by Context.getExternalFilesDir(String)
.
See Traceview: A Graphical Log Viewer for information about reading trace files.
When method tracing is enabled, the VM will run more slowly than usual,
so the timings from the trace files should only be considered in relative
terms (e.g. was run #1 faster than run #2). The times for native methods
will not change, so don't try to use this to compare the performance of
interpreted and native implementations of the same method. As an
alternative, consider using sampling-based method tracing via
startMethodTracingSampling(String, int, int)
or "native" tracing
in the emulator via startNativeTracing()
.
tracePath
- Path to the trace log file to create. If null
,
this will default to "dmtrace.trace". If the file already
exists, it will be truncated. If the path given does not end
in ".trace", it will be appended for you.bufferSize
- The maximum amount of trace data we gather. If not
given, it defaults to 8MB.public static void startMethodTracing(String tracePath, int bufferSize, int flags)
When a relative file path is given, the trace file will be placed under
your package-specific directory on primary shared/external storage, as
returned by Context.getExternalFilesDir(String)
.
See Traceview: A Graphical Log Viewer for information about reading trace files.
When method tracing is enabled, the VM will run more slowly than usual,
so the timings from the trace files should only be considered in relative
terms (e.g. was run #1 faster than run #2). The times for native methods
will not change, so don't try to use this to compare the performance of
interpreted and native implementations of the same method. As an
alternative, consider using sampling-based method tracing via
startMethodTracingSampling(String, int, int)
or "native" tracing
in the emulator via startNativeTracing()
.
tracePath
- Path to the trace log file to create. If null
,
this will default to "dmtrace.trace". If the file already
exists, it will be truncated. If the path given does not end
in ".trace", it will be appended for you.bufferSize
- The maximum amount of trace data we gather. If not
given, it defaults to 8MB.flags
- Flags to control method tracing. The only one that is
currently defined is TRACE_COUNT_ALLOCS
.public static void startMethodTracingSampling(String tracePath, int bufferSize, int intervalUs)
When a relative file path is given, the trace file will be placed under
your package-specific directory on primary shared/external storage, as
returned by Context.getExternalFilesDir(String)
.
See Traceview: A Graphical Log Viewer for information about reading trace files.
tracePath
- Path to the trace log file to create. If null
,
this will default to "dmtrace.trace". If the file already
exists, it will be truncated. If the path given does not end
in ".trace", it will be appended for you.bufferSize
- The maximum amount of trace data we gather. If not
given, it defaults to 8MB.intervalUs
- The amount of time between each sample in microseconds.public static void startMethodTracing(String traceName, FileDescriptor fd, int bufferSize, int flags)
public static void startMethodTracingDdms(int bufferSize, int flags, boolean samplingEnabled, int intervalUs)
public static int getMethodTracingMode()
public static void stopMethodTracing()
public static long threadCpuTimeNanos()
@Deprecated public static void startAllocCounting()
The start
method resets the counts and enables counting.
The stop
method disables the counting so that the analysis
code doesn't cause additional allocations. The various get
methods return
the specified value. And the various reset
methods reset the specified
count.
Counts are kept for the system as a whole (global) and for each thread. The per-thread counts for threads other than the current thread are not cleared by the "reset" or "start" calls.
@Deprecated public static void stopAllocCounting()
@Deprecated public static int getGlobalAllocCount()
@Deprecated public static void resetGlobalAllocCount()
getGlobalAllocCount()
@Deprecated public static int getGlobalAllocSize()
@Deprecated public static void resetGlobalAllocSize()
getGlobalAllocSize()
@Deprecated public static int getGlobalFreedCount()
@Deprecated public static void resetGlobalFreedCount()
getGlobalFreedCount()
@Deprecated public static int getGlobalFreedSize()
@Deprecated public static void resetGlobalFreedSize()
getGlobalFreedSize()
@Deprecated public static int getGlobalGcInvocationCount()
@Deprecated public static void resetGlobalGcInvocationCount()
getGlobalGcInvocationCount()
@Deprecated public static int getGlobalClassInitCount()
@Deprecated public static void resetGlobalClassInitCount()
getGlobalClassInitCount()
@Deprecated public static int getGlobalClassInitTime()
@Deprecated public static void resetGlobalClassInitTime()
getGlobalClassInitTime()
@Deprecated public static int getGlobalExternalAllocCount()
@Deprecated public static void resetGlobalExternalAllocSize()
@Deprecated public static void resetGlobalExternalAllocCount()
@Deprecated public static int getGlobalExternalAllocSize()
@Deprecated public static int getGlobalExternalFreedCount()
@Deprecated public static void resetGlobalExternalFreedCount()
@Deprecated public static int getGlobalExternalFreedSize()
@Deprecated public static void resetGlobalExternalFreedSize()
@Deprecated public static int getThreadAllocCount()
@Deprecated public static void resetThreadAllocCount()
getThreadAllocCount()
@Deprecated public static int getThreadAllocSize()
@Deprecated public static void resetThreadAllocSize()
getThreadAllocSize()
@Deprecated public static int getThreadExternalAllocCount()
@Deprecated public static void resetThreadExternalAllocCount()
@Deprecated public static int getThreadExternalAllocSize()
@Deprecated public static void resetThreadExternalAllocSize()
@Deprecated public static int getThreadGcInvocationCount()
@Deprecated public static void resetThreadGcInvocationCount()
getThreadGcInvocationCount()
@Deprecated public static void resetAllCounts()
startAllocCounting()
public static String getRuntimeStat(String statName)
null
if no
such runtime statistic exists.
The following table lists the runtime statistics that the runtime supports. Note runtime statistics may be added or removed in a future API level.
Runtime statistic name | Meaning | Example | Supported (API Levels) |
---|---|---|---|
art.gc.gc-count | The number of garbage collection runs. | 164 |
23 |
art.gc.gc-time | The total duration of garbage collection runs in ms. | 62364 |
23 |
art.gc.bytes-allocated | The total number of bytes that the application allocated. | 1463948408 |
23 |
art.gc.bytes-freed | The total number of bytes that garbage collection reclaimed. | 1313493084 |
23 |
art.gc.blocking-gc-count | The number of blocking garbage collection runs. | 2 |
23 |
art.gc.blocking-gc-time | The total duration of blocking garbage collection runs in ms. | 804 |
23 |
art.gc.gc-count-rate-histogram | Every 10 seconds, the gc-count-rate is computed as the number of garbage collection runs that have occurred over the last 10 seconds. art.gc.gc-count-rate-histogram is a histogram of the gc-count-rate samples taken since the process began. The histogram can be used to identify instances of high rates of garbage collection runs. For example, a histogram of "0:34503,1:45350,2:11281,3:8088,4:43,5:8" shows that most of the time there are between 0 and 2 garbage collection runs every 10 seconds, but there were 8 distinct 10-second intervals in which 5 garbage collection runs occurred. | 0:34503,1:45350,2:11281,3:8088,4:43,5:8 |
23 |
art.gc.blocking-gc-count-rate-histogram | Every 10 seconds, the blocking-gc-count-rate is computed as the number of blocking garbage collection runs that have occurred over the last 10 seconds. art.gc.blocking-gc-count-rate-histogram is a histogram of the blocking-gc-count-rate samples taken since the process began. The histogram can be used to identify instances of high rates of blocking garbage collection runs. For example, a histogram of "0:99269,1:1,2:1" shows that most of the time there are zero blocking garbage collection runs every 10 seconds, but there was one 10-second interval in which one blocking garbage collection run occurred, and there was one interval in which two blocking garbage collection runs occurred. | 0:99269,1:1,2:1 |
23 |
statName
- the name of the runtime statistic to look up.null
if the
runtime statistic doesn't exist.public static Map<String,String> getRuntimeStats()
getRuntimeStat(String)
supports.public static long getNativeHeapSize()
public static long getNativeHeapAllocatedSize()
public static long getNativeHeapFreeSize()
public static void getMemoryInfo(Debug.MemoryInfo memoryInfo)
Note: this method directly retrieves memory information for the give process
from low-level data available to it. It may not be able to retrieve information about
some protected allocations, such as graphics. If you want to be sure you can see
all information about allocations by the process, use instead
ActivityManager.getProcessMemoryInfo(int[])
.
public static void getMemoryInfo(int pid, Debug.MemoryInfo memoryInfo)
public static long getPss()
public static long getPss(int pid, long[] outUssSwapPss, long[] outMemtrack)
public static void getMemInfo(long[] outSizes)
@Deprecated public static int setAllocationLimit(int limit)
@Deprecated public static int setGlobalAllocationLimit(int limit)
public static void printLoadedClasses(int flags)
flags
- See constants above.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 dumpHprofData(String fileName, FileDescriptor fd) throws IOException
IOException
public static void dumpHprofDataDdms()
UnsupportedOperationException
- if the VM was built without
HPROF support.public static void dumpNativeHeap(FileDescriptor fd)
public static long countInstancesOfClass(Class cls)
public static int getBinderSentTransactions()
public static int getBinderReceivedTransactions()
public static final int getBinderLocalObjectCount()
public static final int getBinderProxyObjectCount()
public static final int getBinderDeathObjectCount()
public static final boolean cacheRegisterMap(String classAndMethodDesc)
classAndMethodDesc
- the method to preparepublic static final void dumpReferenceTables()
public static void setFieldsOn(Class<?> cl)
setFieldsOn(cl, false)
.setFieldsOn(Class, boolean)
public static void setFieldsOn(Class<?> cl, boolean partial)
NOTE TO APPLICATION DEVELOPERS: false will always be false in release builds. This API is typically only useful for platform developers.
Class setup: define a class whose only fields are non-final, static primitive types (except for "char") or Strings. In a static block after the field definitions/initializations, pass the class to this method, Debug.setFieldsOn(). Example:package com.example; import android.os.Debug; public class MyDebugVars { public static String s = "a string"; public static String s2 = "second string"; public static String ns = null; public static boolean b = false; public static int i = 5;
cl
- The class to (possibly) modifypartial
- If false, sets all static fields, otherwise, only set
fields with the Debug.DebugProperty
annotationIllegalArgumentException
- if any fields are final or non-static,
or if the type of the field does not match the type of
the internal debugging property value.public static boolean dumpService(String name, FileDescriptor fd, String[] args)
Most services require the caller to hold android.permission.DUMP.
name
- of the service to dumpfd
- to write dump output to (usually an output log file)args
- to pass to the service's dump method, may be nullpublic static void dumpNativeBacktraceToFile(int pid, String file)
public static String getUnreachableMemory(int limit, boolean contents)
limit
- the number of leaks to provide info on, 0 to only get a summary.contents
- true to include a hex dump of the contents of unreachable memory.public static String getCallers(int depth)
depth
- the number of levels to return, starting with the immediate caller.public static String getCallers(int start, int depth)
depth
- the number of levels to return, starting with the immediate caller.public static String getCallers(int depth, String linePrefix)
getCallers(int)
, but each location is append to the string
as a new line with linePrefix in front of it.depth
- the number of levels to return, starting with the immediate caller.linePrefix
- prefix to put in front of each location.public static String getCaller()