diff options
-rw-r--r-- | artd/artd.cc | 32 | ||||
-rw-r--r-- | artd/artd.h | 2 | ||||
-rw-r--r-- | build/apex/art.rc | 7 | ||||
-rw-r--r-- | dexopt_chroot_setup/dexopt_chroot_setup.cc | 26 | ||||
-rw-r--r-- | libarttools/art_exec.cc | 2 |
5 files changed, 36 insertions, 33 deletions
diff --git a/artd/artd.cc b/artd/artd.cc index f3853365fc..3eef99d7a8 100644 --- a/artd/artd.cc +++ b/artd/artd.cc @@ -606,8 +606,7 @@ ndk::ScopedAStatus Artd::isProfileUsable(const ProfilePath& in_profile, FdLogger fd_logger; - CmdlineBuilder art_exec_args; - art_exec_args.Add(OR_RETURN_FATAL(GetArtExec())).Add("--drop-capabilities"); + CmdlineBuilder art_exec_args = OR_RETURN_FATAL(GetArtExecCmdlineBuilder()); CmdlineBuilder args; args.Add(OR_RETURN_FATAL(GetProfman())); @@ -659,8 +658,7 @@ ndk::ScopedAStatus Artd::CopyAndRewriteProfileImpl(File src, FdLogger fd_logger; - CmdlineBuilder art_exec_args; - art_exec_args.Add(OR_RETURN_FATAL(GetArtExec())).Add("--drop-capabilities"); + CmdlineBuilder art_exec_args = OR_RETURN_FATAL(GetArtExecCmdlineBuilder()); CmdlineBuilder args; args.Add(OR_RETURN_FATAL(GetProfman())).Add("--copy-and-update-profile-key"); @@ -833,8 +831,7 @@ ndk::ScopedAStatus Artd::mergeProfiles(const std::vector<ProfilePath>& in_profil FdLogger fd_logger; - CmdlineBuilder art_exec_args; - art_exec_args.Add(OR_RETURN_FATAL(GetArtExec())).Add("--drop-capabilities"); + CmdlineBuilder art_exec_args = OR_RETURN_FATAL(GetArtExecCmdlineBuilder()); CmdlineBuilder args; args.Add(OR_RETURN_FATAL(GetProfman())); @@ -1028,8 +1025,7 @@ ndk::ScopedAStatus Artd::dexopt( FdLogger fd_logger; - CmdlineBuilder art_exec_args; - art_exec_args.Add(OR_RETURN_FATAL(GetArtExec())).Add("--drop-capabilities"); + CmdlineBuilder art_exec_args = OR_RETURN_FATAL(GetArtExecCmdlineBuilder()); CmdlineBuilder args; args.Add(OR_RETURN_FATAL(GetDex2Oat())); @@ -1549,7 +1545,13 @@ bool Artd::DenyArtApexDataFilesLocked() { Result<std::string> Artd::GetProfman() { return BuildArtBinPath("profman"); } -Result<std::string> Artd::GetArtExec() { return BuildArtBinPath("art_exec"); } +Result<CmdlineBuilder> Artd::GetArtExecCmdlineBuilder() { + CmdlineBuilder args; + args.Add(OR_RETURN(BuildArtBinPath("art_exec"))) + .Add("--drop-capabilities") + .AddIf(options_.is_pre_reboot, "--process-name-suffix=Pre-reboot Dexopt chroot"); + return args; +} bool Artd::ShouldUseDex2Oat64() { return !props_->GetOrEmpty("ro.product.cpu.abilist64").empty() && @@ -1782,10 +1784,8 @@ Result<void> Artd::PreRebootInitDeriveClasspath(const std::string& path) { return ErrnoErrorf("Failed to create '{}'", path); } - CmdlineBuilder args; - args.Add(OR_RETURN(GetArtExec())) - .Add("--drop-capabilities") - .Add("--keep-fds=%d", output->Fd()) + CmdlineBuilder args = OR_RETURN(GetArtExecCmdlineBuilder()); + args.Add("--keep-fds=%d", output->Fd()) .Add("--") .Add("/apex/com.android.sdkext/bin/derive_classpath") .Add("/proc/self/fd/%d", output->Fd()); @@ -1811,10 +1811,8 @@ Result<void> Artd::PreRebootInitDeriveClasspath(const std::string& path) { } Result<void> Artd::PreRebootInitBootImages() { - CmdlineBuilder args; - args.Add(OR_RETURN(GetArtExec())) - .Add("--drop-capabilities") - .Add("--") + CmdlineBuilder args = OR_RETURN(GetArtExecCmdlineBuilder()); + args.Add("--") .Add(OR_RETURN(BuildArtBinPath("odrefresh"))) .Add("--only-boot-images") .Add("--compile"); diff --git a/artd/artd.h b/artd/artd.h index 07927104df..a926dbc652 100644 --- a/artd/artd.h +++ b/artd/artd.h @@ -263,7 +263,7 @@ class Artd : public aidl::com::android::server::art::BnArtd { android::base::Result<std::string> GetProfman(); - android::base::Result<std::string> GetArtExec(); + android::base::Result<tools::CmdlineBuilder> GetArtExecCmdlineBuilder(); bool ShouldUseDex2Oat64(); diff --git a/build/apex/art.rc b/build/apex/art.rc index bab7fe30a3..8a98a5f670 100644 --- a/build/apex/art.rc +++ b/build/apex/art.rc @@ -26,7 +26,12 @@ service artd /apex/com.android.art/bin/artd # Same as above, but for Pre-reboot Dexopt. It runs in a chroot environment that # is set up by dexopt_chroot_setup. It's a lazy service that is started and # stopped dynamically as needed. -service artd_pre_reboot /apex/com.android.art/bin/art_exec --chroot=/mnt/pre_reboot_dexopt/chroot -- /apex/com.android.art/bin/artd --pre-reboot +service artd_pre_reboot /apex/com.android.art/bin/art_exec \ + --chroot=/mnt/pre_reboot_dexopt/chroot \ + --process-name-suffix="Pre-reboot Dexopt chroot" \ + -- \ + /apex/com.android.art/bin/artd \ + --pre-reboot interface aidl artd_pre_reboot disabled # Prevents the service from automatically starting at boot. oneshot # Prevents the service from automatically restarting each time it is stopped. diff --git a/dexopt_chroot_setup/dexopt_chroot_setup.cc b/dexopt_chroot_setup/dexopt_chroot_setup.cc index 967cb20c1e..f7d1ea4d37 100644 --- a/dexopt_chroot_setup/dexopt_chroot_setup.cc +++ b/dexopt_chroot_setup/dexopt_chroot_setup.cc @@ -97,13 +97,17 @@ Result<void> Run(std::string_view log_name, const std::vector<std::string>& args return {}; } -Result<std::string> GetArtExec() { +Result<CmdlineBuilder> GetArtExecCmdlineBuilder() { std::string error_msg; std::string art_root = GetArtRootSafe(&error_msg); if (!error_msg.empty()) { return Error() << error_msg; } - return art_root + "/bin/art_exec"; + CmdlineBuilder args; + args.Add(art_root + "/bin/art_exec") + .Add("--chroot=%s", DexoptChrootSetup::CHROOT_DIR) + .Add("--process-name-suffix=Pre-reboot Dexopt chroot"); + return args; } Result<void> CreateDir(const std::string& path) { @@ -408,19 +412,15 @@ Result<void> DexoptChrootSetup::SetUpChroot(const std::optional<std::string>& ot PLOG(WARNING) << "Failed to generate empty linker config to suppress warnings"; } - CmdlineBuilder args; - args.Add(OR_RETURN(GetArtExec())) - .Add("--chroot=%s", CHROOT_DIR) - .Add("--") + CmdlineBuilder args = OR_RETURN(GetArtExecCmdlineBuilder()); + args.Add("--") .Add("/system/bin/apexd") .Add("--otachroot-bootstrap") .AddIf(!IsOtaUpdate(ota_slot), "--also-include-staged-apexes"); OR_RETURN(Run("apexd", args.Get())); - args = CmdlineBuilder(); - args.Add(OR_RETURN(GetArtExec())) - .Add("--chroot=%s", CHROOT_DIR) - .Add("--drop-capabilities") + args = OR_RETURN(GetArtExecCmdlineBuilder()); + args.Add("--drop-capabilities") .Add("--") .Add("/apex/com.android.runtime/bin/linkerconfig") .Add("--target") @@ -432,10 +432,8 @@ Result<void> DexoptChrootSetup::SetUpChroot(const std::optional<std::string>& ot Result<void> DexoptChrootSetup::TearDownChroot() const { if (OS::FileExists(PathInChroot("/system/bin/apexd").c_str())) { - CmdlineBuilder args; - args.Add(OR_RETURN(GetArtExec())) - .Add("--chroot=%s", CHROOT_DIR) - .Add("--") + CmdlineBuilder args = OR_RETURN(GetArtExecCmdlineBuilder()); + args.Add("--") .Add("/system/bin/apexd") .Add("--unmount-all") .Add("--also-include-staged-apexes"); diff --git a/libarttools/art_exec.cc b/libarttools/art_exec.cc index 704b25dddb..dfd0ca5bf9 100644 --- a/libarttools/art_exec.cc +++ b/libarttools/art_exec.cc @@ -67,6 +67,8 @@ Supported options: --keep-fds=FILE_DESCRIPTORS: A semicolon-separated list of file descriptors to keep open. --env=KEY=VALUE: Set an environment variable. This flag can be passed multiple times to set multiple environment variables. + --process-name-suffix=SUFFIX: Add a suffix in parentheses to argv[0] when calling `execv`. This + suffix will show up as part of the process name in tombstone when the process crashes. )"; constexpr int kErrorUsage = 100; |