gdbclient.py: Implement --chroot argument.
This allows executables to be debugged inside a chroot (such as the ART
testing chroot).
Change-Id: I1b790c3c2307e240d37ed0afb9a930d00957acec
diff --git a/scripts/gdbclient.py b/scripts/gdbclient.py
index b9764cd..539e6d0 100755
--- a/scripts/gdbclient.py
+++ b/scripts/gdbclient.py
@@ -102,6 +102,9 @@
parser.add_argument(
"--env", nargs=1, action="append", metavar="VAR=VALUE",
help="set environment variable when running a binary")
+ parser.add_argument(
+ "--chroot", nargs='?', default="", metavar="PATH",
+ help="run command in a chroot in the given directory")
return parser.parse_args()
@@ -315,7 +318,10 @@
sysroot = os.path.join(os.environ["ANDROID_PRODUCT_OUT"], "symbols")
# Make sure the environment matches the attached device.
- verify_device(root, device)
+ # Skip when running in a chroot because the chroot lunch target may not
+ # match the device's lunch target.
+ if not args.chroot:
+ verify_device(root, device)
debug_socket = "/data/local/tmp/debug_socket"
pid = None
@@ -356,7 +362,7 @@
gdbrunner.start_gdbserver(
device, server_local_path, server_remote_path,
target_pid=pid, run_cmd=run_cmd, debug_socket=debug_socket,
- port=args.port, run_as_cmd=cmd_prefix, lldb=True)
+ port=args.port, run_as_cmd=cmd_prefix, lldb=True, chroot=args.chroot)
else:
print(
"Connecting to tracing pid {} using local port {}".format(