perfetto_hprof: add flag to enable.
Add flag whether to allow loading of the perfetto hprof plugin.
Even with this option set, we will still only actually load the plugin
if we are on a userdebug build or the app is debuggable or profileable.
We do not want to enable this by default because PerfettoHprof does not
work on host, and we do not want to enable it in tests.
Test: flash flame-userdebug. get java heap dump.
Bug: 147667830
Change-Id: If978556dbf44b27828cba47e1fb95084a12838b7
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 5104297..b534fd2 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -296,7 +296,8 @@
process_state_(kProcessStateJankPerceptible),
zygote_no_threads_(false),
verifier_logging_threshold_ms_(100),
- verifier_missing_kthrow_fatal_(false) {
+ verifier_missing_kthrow_fatal_(false),
+ perfetto_hprof_enabled_(false) {
static_assert(Runtime::kCalleeSaveSize ==
static_cast<uint32_t>(CalleeSaveType::kLastCalleeSaveType), "Unexpected size");
CheckConstants();
@@ -1062,8 +1063,9 @@
StartSignalCatcher();
ScopedObjectAccess soa(Thread::Current());
- if (Dbg::IsJdwpAllowed() || IsProfileableFromShell() || IsJavaDebuggable() ||
- Runtime::Current()->IsSystemServer()) {
+ if (IsPerfettoHprofEnabled() &&
+ (Dbg::IsJdwpAllowed() || IsProfileableFromShell() || IsJavaDebuggable() ||
+ Runtime::Current()->IsSystemServer())) {
std::string err;
ScopedTrace tr("perfetto_hprof init.");
ScopedThreadSuspension sts(Thread::Current(), ThreadState::kNative);
@@ -1199,6 +1201,7 @@
MemMap::Init();
verifier_missing_kthrow_fatal_ = runtime_options.GetOrDefault(Opt::VerifierMissingKThrowFatal);
+ perfetto_hprof_enabled_ = runtime_options.GetOrDefault(Opt::PerfettoHprof);
// Try to reserve a dedicated fault page. This is allocated for clobbered registers and sentinels.
// If we cannot reserve it, log a warning.