From 046c706707ea0f16c804136e237ac7cbfdc897a1 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 18 May 2015 23:22:54 -0700 Subject: [PATCH] ART: Only print stripped dex2oat command line To curb logcat noise, strip many dex2oat parameters from the logcat printout. Bug: 20501758 Change-Id: Ifc367f91f593916e0773af1ca950c798f129889f --- dex2oat/dex2oat.cc | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index d45ab1bc3..7a2374681 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -89,6 +89,63 @@ static std::string CommandLine() { return Join(command, ' '); } +// A stripped version. Remove some less essential parameters. If we see a "--zip-fd=" parameter, be +// even more aggressive. There won't be much reasonable data here for us in that case anyways (the +// locations are all staged). +static std::string StrippedCommandLine() { + std::vector command; + + // Do a pre-pass to look for zip-fd. + bool saw_zip_fd = false; + for (int i = 0; i < original_argc; ++i) { + if (StartsWith(original_argv[i], "--zip-fd=")) { + saw_zip_fd = true; + break; + } + } + + // Now filter out things. + for (int i = 0; i < original_argc; ++i) { + // All runtime-arg parameters are dropped. + if (strcmp(original_argv[i], "--runtime-arg") == 0) { + i++; // Drop the next part, too. + continue; + } + + // Any instruction-setXXX is dropped. + if (StartsWith(original_argv[i], "--instruction-set")) { + continue; + } + + // The boot image is dropped. + if (StartsWith(original_argv[i], "--boot-image=")) { + continue; + } + + // This should leave any dex-file and oat-file options, describing what we compiled. + + // However, we prefer to drop this when we saw --zip-fd. + if (saw_zip_fd) { + // Drop anything --zip-X, --dex-X, --oat-X, --swap-X. + if (StartsWith(original_argv[i], "--zip-") || + StartsWith(original_argv[i], "--dex-") || + StartsWith(original_argv[i], "--oat-") || + StartsWith(original_argv[i], "--swap-")) { + continue; + } + } + + command.push_back(original_argv[i]); + } + + // Construct the final output. + if (command.size() <= 1U) { + // It seems only "/system/bin/dex2oat" is left, or not even that. Use a pretty line. + return "Starting dex2oat."; + } + return Join(command, ' '); +} + static void UsageErrorV(const char* fmt, va_list ap) { std::string error; StringAppendV(&error, fmt, ap); @@ -1911,7 +1968,17 @@ static int dex2oat(int argc, char** argv) { return EXIT_FAILURE; } - LOG(INFO) << CommandLine(); + // Print the complete line when any of the following is true: + // 1) Debug build + // 2) Compiling an image + // 3) Compiling with --host + // 4) Compiling on the host (not a target build) + // Otherwise, print a stripped command line. + if (kIsDebugBuild || dex2oat.IsImage() || dex2oat.IsHost() || !kIsTargetBuild) { + LOG(INFO) << CommandLine(); + } else { + LOG(INFO) << StrippedCommandLine(); + } if (!dex2oat.Setup()) { dex2oat.EraseOatFile(); -- 2.11.0