diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-09-25 14:22:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-25 14:22:13 -0400 |
commit | 391d67fa1d3509cc95ae79dd8f5c0dd33624d9a6 (patch) | |
tree | 6aceb4a8a5fd2da9364b3d7f8b255b8b1d5f9635 /python | |
parent | 9ee8890a7234e63730cce1fdb0878f03b7ed20ed (diff) | |
parent | 5edf4e163edcfc07e19baebd5a12d527383932a3 (diff) | |
download | servo-391d67fa1d3509cc95ae79dd8f5c0dd33624d9a6.tar.gz servo-391d67fa1d3509cc95ae79dd8f5c0dd33624d9a6.zip |
Auto merge of #21759 - jdm:ndkgdb, r=paulrouget
Add mach command to setup remote debugging on Android devices.
This removes any need to fiddle with search paths for source files and makes the experience of remote debugging much less frustrating. I've tried this on a Pixel, Pixel 2, and emulator and successfully set breakpoints and investigated variables on all of them. The APP_ABI changes are necessary to prevent ndk-gdb from thinking that the build is arm64 when it's not.
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21759)
<!-- Reviewable:end -->
Diffstat (limited to 'python')
-rw-r--r-- | python/servo/devenv_commands.py | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index 9852558bce6..2a8d3c9f2b3 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -8,10 +8,12 @@ # except according to those terms. from __future__ import print_function, unicode_literals -from os import path, listdir +from os import path, listdir, getcwd from time import time +import signal import sys +import tempfile import urllib2 import json import subprocess @@ -265,3 +267,57 @@ class MachCommands(CommandBase): "local", self.config["android"]["lib"]) print(subprocess.check_output([ndk_stack, "-sym", sym_path, "-dump", logfile])) + + @Command('ndk-gdb', + description='Invoke ndk-gdb tool with the expected symbol paths', + category='devenv') + @CommandArgument('--release', action='store_true', help="Use release build symbols") + @CommandArgument('--target', action='store', default="armv7-linux-androideabi", + help="Build target") + def ndk_gdb(self, release, target): + env = self.build_env(target) + self.handle_android_target(target) + ndk_gdb = path.join(env["ANDROID_NDK"], "ndk-gdb") + adb_path = path.join(env["ANDROID_SDK"], "platform-tools", "adb") + sym_paths = [ + path.join( + getcwd(), + "target", + target, + "release" if release else "debug", + "apk", + "obj", + "local", + self.config["android"]["lib"] + ), + path.join( + getcwd(), + "target", + target, + "release" if release else "debug", + "apk", + "libs", + self.config["android"]["lib"] + ), + ] + env["NDK_PROJECT_PATH"] = path.join(getcwd(), "support", "android", "apk") + signal.signal(signal.SIGINT, signal.SIG_IGN) + + with tempfile.NamedTemporaryFile(delete=False) as f: + f.write('\n'.join([ + "python", + "param = gdb.parameter('solib-search-path')", + "param += ':{}'".format(':'.join(sym_paths)), + "gdb.execute('set solib-search-path ' + param)", + "end", + ])) + + p = subprocess.Popen([ + ndk_gdb, + "--adb", adb_path, + "--project", "support/android/apk/servoapp/src/main/", + "--launch", "com.mozilla.servo.MainActivity", + "-x", f.name, + "--verbose", + ], env=env) + return p.wait() |