use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.
the class BinderProxy method dumpAsync.
/**
* Like {@link #dump(FileDescriptor, String[])}, but ensures the target
* executes asynchronously.
*/
public void dumpAsync(final FileDescriptor fd, final String[] args) {
final FileOutputStream fout = new FileOutputStream(fd);
final PrintWriter pw = new FastPrintWriter(fout);
Thread thr = new Thread("Binder.dumpAsync") {
public void run() {
try {
dump(fd, pw, args);
} finally {
pw.flush();
}
}
};
thr.start();
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.
the class BinderProxy method dump.
/**
* Implemented to call the more convenient version
* {@link #dump(FileDescriptor, PrintWriter, String[])}.
*/
public void dump(FileDescriptor fd, String[] args) {
FileOutputStream fout = new FileOutputStream(fd);
PrintWriter pw = new FastPrintWriter(fout);
try {
doDump(fd, pw, args);
} finally {
pw.flush();
}
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.
the class TransactionTracker method writeTracesToFile.
public void writeTracesToFile(ParcelFileDescriptor fd) {
if (mTraces.isEmpty()) {
return;
}
PrintWriter pw = new FastPrintWriter(new FileOutputStream(fd.getFileDescriptor()));
synchronized (this) {
for (String trace : mTraces.keySet()) {
pw.println("Count: " + mTraces.get(trace));
pw.println("Trace: " + trace);
pw.println();
}
}
pw.flush();
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.
the class Debug method startNativeTracing.
/**
* Enable qemu tracing. For this to work requires running everything inside
* the qemu emulator; otherwise, this method will have no effect. The trace
* file is specified on the command line when the emulator is started. For
* example, the following command line <br />
* <code>emulator -trace foo</code><br />
* will start running the emulator and create a trace file named "foo". This
* method simply enables writing the trace records to the trace file.
*
* <p>
* The main differences between this and {@link #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.
* </p>
*
* <p>
* One limitation of using this method compared to using
* {@link #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.
* </p>
*/
public static void startNativeTracing() {
// Open the sysfs file for writing and write "1" to it.
PrintWriter outStream = null;
try {
FileOutputStream fos = new FileOutputStream(SYSFS_QEMU_TRACE_STATE);
outStream = new FastPrintWriter(fos);
outStream.println("1");
} catch (Exception e) {
} finally {
if (outStream != null)
outStream.close();
}
VMDebug.startEmulatorTracing();
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.
the class Debug method stopNativeTracing.
/**
* Stop qemu tracing. See {@link #startNativeTracing()} to start tracing.
*
* <p>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.</p>
*/
public static void stopNativeTracing() {
VMDebug.stopEmulatorTracing();
// Open the sysfs file for writing and write "0" to it.
PrintWriter outStream = null;
try {
FileOutputStream fos = new FileOutputStream(SYSFS_QEMU_TRACE_STATE);
outStream = new FastPrintWriter(fos);
outStream.println("0");
} catch (Exception e) {
// We could print an error message here but we probably want
// to quietly ignore errors if we are not running in the emulator.
} finally {
if (outStream != null)
outStream.close();
}
}
Aggregations