Merge "[Frameworks] Add an 'am' cmd option to enable streaming in profiling."

am: e924640c4b

Change-Id: I7e56dd815f5ac72b27ac6e2e2ca7614eaa648db1
This commit is contained in:
Shukang Zhou
2017-01-27 18:57:12 +00:00
committed by android-build-merger
6 changed files with 43 additions and 11 deletions

View File

@@ -534,6 +534,7 @@ public final class ActivityThread {
ParcelFileDescriptor profileFd;
int samplingInterval;
boolean autoStopProfiler;
boolean streamingOutput;
boolean profiling;
boolean handlingProfiling;
public void setProfiler(ProfilerInfo profilerInfo) {
@@ -559,6 +560,7 @@ public final class ActivityThread {
profileFd = fd;
samplingInterval = profilerInfo.samplingInterval;
autoStopProfiler = profilerInfo.autoStopProfiler;
streamingOutput = profilerInfo.streamingOutput;
}
public void startProfiling() {
if (profileFd == null || profiling) {
@@ -567,7 +569,8 @@ public final class ActivityThread {
try {
int bufferSize = SystemProperties.getInt("debug.traceview-buffer-size-mb", 8);
VMDebug.startMethodTracing(profileFile, profileFd.getFileDescriptor(),
bufferSize * 1024 * 1024, 0, samplingInterval != 0, samplingInterval);
bufferSize * 1024 * 1024, 0, samplingInterval != 0, samplingInterval,
streamingOutput);
profiling = true;
} catch (RuntimeException e) {
Slog.w(TAG, "Profiling failed on path " + profileFile);
@@ -5109,6 +5112,7 @@ public final class ActivityThread {
mProfiler.profileFd = data.initProfilerInfo.profileFd;
mProfiler.samplingInterval = data.initProfilerInfo.samplingInterval;
mProfiler.autoStopProfiler = data.initProfilerInfo.autoStopProfiler;
mProfiler.streamingOutput = data.initProfilerInfo.streamingOutput;
}
// send up app name; do this *before* waiting for debugger

View File

@@ -39,11 +39,16 @@ public class ProfilerInfo implements Parcelable {
/* Automatically stop the profiler when the app goes idle. */
public final boolean autoStopProfiler;
public ProfilerInfo(String filename, ParcelFileDescriptor fd, int interval, boolean autoStop) {
/* Indicates whether to stream the profiling info to the out file continuously. */
public final boolean streamingOutput;
public ProfilerInfo(String filename, ParcelFileDescriptor fd, int interval, boolean autoStop,
boolean streaming) {
profileFile = filename;
profileFd = fd;
samplingInterval = interval;
autoStopProfiler = autoStop;
streamingOutput = streaming;
}
public int describeContents() {
@@ -64,6 +69,7 @@ public class ProfilerInfo implements Parcelable {
}
out.writeInt(samplingInterval);
out.writeInt(autoStopProfiler ? 1 : 0);
out.writeInt(streamingOutput ? 1 : 0);
}
public static final Parcelable.Creator<ProfilerInfo> CREATOR =
@@ -82,5 +88,6 @@ public class ProfilerInfo implements Parcelable {
profileFd = in.readInt() != 0 ? ParcelFileDescriptor.CREATOR.createFromParcel(in) : null;
samplingInterval = in.readInt();
autoStopProfiler = in.readInt() != 0;
streamingOutput = in.readInt() != 0;
}
}

View File

@@ -1119,8 +1119,8 @@ public final class Debug
* @hide
*/
public static void startMethodTracing(String traceName, FileDescriptor fd,
int bufferSize, int flags) {
VMDebug.startMethodTracing(traceName, fd, bufferSize, flags, false, 0);
int bufferSize, int flags, boolean streamOutput) {
VMDebug.startMethodTracing(traceName, fd, bufferSize, flags, false, 0, streamOutput);
}
/**