Merge "Add an argument to cmd pm dump-profiles to send --dump-classes-and-methods to profman." into tm-dev am: 8e8ff54f2e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17822423 Change-Id: I38f75dfd77b512d882ebde071738dbeee4636f43 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -571,8 +571,14 @@ interface IPackageManager {
|
||||
|
||||
/**
|
||||
* Ask the package manager to dump profiles associated with a package.
|
||||
*
|
||||
* @param packageName The name of the package to dump.
|
||||
* @param dumpClassesAndMethods If false, pass {@code --dump-only} to profman to dump the
|
||||
* profile in a human readable form intended for debugging. If true, pass
|
||||
* {@code --dump-classes-and-methods} to profman to dump a sorted list of classes and methods
|
||||
* in a human readable form that is valid input for {@code profman --create-profile-from}.
|
||||
*/
|
||||
void dumpProfiles(String packageName);
|
||||
void dumpProfiles(String packageName, boolean dumpClassesAndMethods);
|
||||
|
||||
void forceDexOpt(String packageName);
|
||||
|
||||
|
||||
@@ -629,12 +629,17 @@ public class Installer extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean dumpProfiles(int uid, String packageName, String profileName, String codePath)
|
||||
/**
|
||||
* Dumps profiles associated with a package in a human readable format.
|
||||
*/
|
||||
public boolean dumpProfiles(int uid, String packageName, String profileName, String codePath,
|
||||
boolean dumpClassesAndMethods)
|
||||
throws InstallerException {
|
||||
if (!checkBeforeRemote()) return false;
|
||||
BlockGuard.getVmPolicy().onPathAccess(codePath);
|
||||
try {
|
||||
return mInstalld.dumpProfiles(uid, packageName, profileName, codePath);
|
||||
return mInstalld.dumpProfiles(uid, packageName, profileName, codePath,
|
||||
dumpClassesAndMethods);
|
||||
} catch (Exception e) {
|
||||
throw InstallerException.from(e);
|
||||
}
|
||||
|
||||
@@ -4665,7 +4665,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpProfiles(String packageName) {
|
||||
public void dumpProfiles(String packageName, boolean dumpClassesAndMethods) {
|
||||
/* Only the shell, root, or the app user should be able to dump profiles. */
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
final Computer snapshot = snapshotComputer();
|
||||
@@ -4683,7 +4683,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
|
||||
|
||||
synchronized (mInstallLock) {
|
||||
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dump profiles");
|
||||
mArtManagerService.dumpProfiles(pkg);
|
||||
mArtManagerService.dumpProfiles(pkg, dumpClassesAndMethods);
|
||||
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1994,8 +1994,23 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
}
|
||||
|
||||
private int runDumpProfiles() throws RemoteException {
|
||||
final PrintWriter pw = getOutPrintWriter();
|
||||
boolean dumpClassesAndMethods = false;
|
||||
|
||||
String opt;
|
||||
while ((opt = getNextOption()) != null) {
|
||||
switch (opt) {
|
||||
case "--dump-classes-and-methods":
|
||||
dumpClassesAndMethods = true;
|
||||
break;
|
||||
default:
|
||||
pw.println("Error: Unknown option: " + opt);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
String packageName = getNextArg();
|
||||
mInterface.dumpProfiles(packageName);
|
||||
mInterface.dumpProfiles(packageName, dumpClassesAndMethods);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4164,9 +4179,12 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
pw.println(" reconcile-secondary-dex-files TARGET-PACKAGE");
|
||||
pw.println(" Reconciles the package secondary dex files with the generated oat files.");
|
||||
pw.println("");
|
||||
pw.println(" dump-profiles TARGET-PACKAGE");
|
||||
pw.println(" dump-profiles [--dump-classes-and-methods] TARGET-PACKAGE");
|
||||
pw.println(" Dumps method/class profile files to");
|
||||
pw.println(" " + ART_PROFILE_SNAPSHOT_DEBUG_LOCATION + "TARGET-PACKAGE.txt");
|
||||
pw.println(" " + ART_PROFILE_SNAPSHOT_DEBUG_LOCATION
|
||||
+ "TARGET-PACKAGE-primary.prof.txt.");
|
||||
pw.println(" --dump-classes-and-methods: passed along to the profman binary to");
|
||||
pw.println(" switch to the format used by 'profman --create-profile-from'.");
|
||||
pw.println("");
|
||||
pw.println(" snapshot-profile TARGET-PACKAGE [--code-path path]");
|
||||
pw.println(" Take a snapshot of the package profiles to");
|
||||
|
||||
@@ -465,14 +465,15 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
|
||||
/**
|
||||
* Dumps the profiles for the given package.
|
||||
*/
|
||||
public void dumpProfiles(AndroidPackage pkg) {
|
||||
public void dumpProfiles(AndroidPackage pkg, boolean dumpClassesAndMethods) {
|
||||
final int sharedGid = UserHandle.getSharedAppGid(pkg.getUid());
|
||||
try {
|
||||
ArrayMap<String, String> packageProfileNames = getPackageProfileNames(pkg);
|
||||
for (int i = packageProfileNames.size() - 1; i >= 0; i--) {
|
||||
String codePath = packageProfileNames.keyAt(i);
|
||||
String profileName = packageProfileNames.valueAt(i);
|
||||
mInstaller.dumpProfiles(sharedGid, pkg.getPackageName(), profileName, codePath);
|
||||
mInstaller.dumpProfiles(sharedGid, pkg.getPackageName(), profileName, codePath,
|
||||
dumpClassesAndMethods);
|
||||
}
|
||||
} catch (InstallerException e) {
|
||||
Slog.w(TAG, "Failed to dump profiles", e);
|
||||
|
||||
Reference in New Issue
Block a user