Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perfetto: check if binary is debuggable for memory profiling #519

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions benchmarking/profilers/perfetto/perfetto.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
from tempfile import NamedTemporaryFile
from typing import List

# from platforms.android.android_platform import AndroidPlatform
from profilers.perfetto.perfetto_config import PerfettoConfig
from profilers.profiler_base import ProfilerBase
from profilers.utilities import generate_perf_filename, upload_profiling_reports
from utils.custom_logger import getLogger
from utils.utilities import BenchmarkUnsupportedDeviceException
from utils.utilities import (
BenchmarkInvalidBinaryException,
BenchmarkUnsupportedDeviceException,
)

PROCESS_KEY = "perfetto"

Expand Down Expand Up @@ -84,6 +86,7 @@ def __init__(
options=None,
):
self.platform = platform
self.cmd = cmd
self.types = types or ["memory"]
self.options = options or {}
self.android_version: int = int(platform.rel_version.split(".")[0])
Expand Down Expand Up @@ -162,6 +165,14 @@ def _start(self):
if not self.user_was_root:
self.adb.root()

if "memory" in self.types:
output = self.adb.shell(["file", self.cmd[0]])
getLogger().error(f"file {self.cmd[0]} returned '{output}'.")
if output and "not stripped" not in output[0]:
raise BenchmarkInvalidBinaryException(
f"Cannot run perfetto memory profiling on non-debuggable binary {self.cmd[0]}."
)

if "battery" in self.types:
if self.is_rooted_device:
if not self._hasBattery():
Expand Down
6 changes: 6 additions & 0 deletions benchmarking/utils/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class BenchmarkUnsupportedDeviceException(BenchmarkException):
pass


class BenchmarkInvalidBinaryException(BenchmarkException):
"""Raised where benchmark arguments specify an invalid binary."""

pass


def check_is_json(json_str):
try:
json.loads(json_str)
Expand Down