aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2018-09-20 10:59:16 -0400
committerJosh Matthews <josh@joshmatthews.net>2018-09-25 12:14:18 -0400
commit4fe41c69d327cd519d944bbddf1d893af08d6055 (patch)
tree9e1a3f58feaf45ecce73c747e14dc2e1e8af19c7 /python/servo
parent6e844f22780a1a2b78c3a1f4bd934581144cb34e (diff)
downloadservo-4fe41c69d327cd519d944bbddf1d893af08d6055.tar.gz
servo-4fe41c69d327cd519d944bbddf1d893af08d6055.zip
Add mach command to setup remote debugging on Android devices.
Diffstat (limited to 'python/servo')
-rw-r--r--python/servo/devenv_commands.py58
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()