From: Wei Wang Date: Thu, 2 Aug 2018 19:26:10 +0000 (-0700) Subject: simpleperf: add pid argument to inferno X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d89dbd88f464406b246ffb45d64cfb2347bac18a;p=android-x86%2Fsystem-extras.git simpleperf: add pid argument to inferno Bug: 112146809 Test: inferno.sh --pid 620 Change-Id: I99afe432a194bb8799e4633f0a651ff1be2354f5 (cherry picked from commit 6db1fa95d3d4e25c49d3e7b0224df45f521f1f90) --- diff --git a/simpleperf/scripts/inferno/inferno.py b/simpleperf/scripts/inferno/inferno.py index 0bc06650..bf2cf9a3 100755 --- a/simpleperf/scripts/inferno/inferno.py +++ b/simpleperf/scripts/inferno/inferno.py @@ -264,6 +264,8 @@ def main(): Like -np surfaceflinger.""") record_group.add_argument('-p', '--app', help="""Profile an Android app, given the package name. Like -p com.example.android.myapp.""") + record_group.add_argument('--pid', type=int, default=-1, help="""Profile a native program + with given pid, the pid should exist on the device.""") record_group.add_argument('--record_file', default='perf.data', help='Default is perf.data.') record_group.add_argument('-sc', '--skip_collection', action='store_true', help="""Skip data collection""") @@ -301,6 +303,15 @@ def main(): process = Process("", 0) if not args.skip_collection: + if args.pid != -1: + result, output = AdbHelper().run_and_return_output(['shell', 'ps', '-p', + str(args.pid), '-o', 'comm=']) + if result: + try: + args.native_program = output.replace('\n', '') + except: + log_warning("Could not find native app for pid '%d'." % process.pid) + process.name = args.app or args.native_program log_info("Starting data collection stage for process '%s'." % process.name) if not collect_data(args):