blob: 8c4262dd865167e76ff9b1bebe3529f448639fe6 [file] [log] [blame]
Elliott Hughes17de6ce2021-06-23 18:00:46 -07001#!/usr/bin/env python3
Josh Gao043bad72015-09-22 11:43:08 -07002#
3# Copyright (C) 2015 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18import adb
19import argparse
Alex Light92476652019-01-17 11:18:48 -080020import json
Josh Gao043bad72015-09-22 11:43:08 -070021import logging
22import os
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -070023import posixpath
Elliott Hughes89e1ecf2017-06-30 14:03:32 -070024import re
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -070025import shutil
Josh Gao043bad72015-09-22 11:43:08 -070026import subprocess
27import sys
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -070028import tempfile
Alex Light92476652019-01-17 11:18:48 -080029import textwrap
Josh Gao043bad72015-09-22 11:43:08 -070030
31# Shared functions across gdbclient.py and ndk-gdb.py.
32import gdbrunner
33
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -070034g_temp_dirs = []
35
Haibo Huange194fce2020-01-06 14:40:27 -080036
37def read_toolchain_config(root):
Pirama Arumuga Nainarf7f95442021-06-30 13:31:41 -070038 """Finds out current toolchain version."""
39 version_output = subprocess.check_output(
40 f'{root}/build/soong/scripts/get_clang_version.py',
41 text=True)
42 return version_output.strip()
Haibo Huange194fce2020-01-06 14:40:27 -080043
44
Haibo Huange4d8bfd2020-07-22 16:37:35 -070045def get_lldb_path(toolchain_path):
46 for lldb_name in ['lldb.sh', 'lldb.cmd', 'lldb', 'lldb.exe']:
47 debugger_path = os.path.join(toolchain_path, "bin", lldb_name)
48 if os.path.isfile(debugger_path):
49 return debugger_path
50 return None
51
52
Haibo Huange194fce2020-01-06 14:40:27 -080053def get_lldb_server_path(root, clang_base, clang_version, arch):
54 arch = {
55 'arm': 'arm',
56 'arm64': 'aarch64',
57 'x86': 'i386',
58 'x86_64': 'x86_64',
59 }[arch]
60 return os.path.join(root, clang_base, "linux-x86",
61 clang_version, "runtimes_ndk_cxx", arch, "lldb-server")
62
63
Elliott Hughes89e1ecf2017-06-30 14:03:32 -070064def get_tracer_pid(device, pid):
65 if pid is None:
66 return 0
67
68 line, _ = device.shell(["grep", "-e", "^TracerPid:", "/proc/{}/status".format(pid)])
69 tracer_pid = re.sub('TracerPid:\t(.*)\n', r'\1', line)
70 return int(tracer_pid)
71
72
Josh Gao043bad72015-09-22 11:43:08 -070073def parse_args():
74 parser = gdbrunner.ArgumentParser()
75
76 group = parser.add_argument_group(title="attach target")
77 group = group.add_mutually_exclusive_group(required=True)
78 group.add_argument(
79 "-p", dest="target_pid", metavar="PID", type=int,
80 help="attach to a process with specified PID")
81 group.add_argument(
82 "-n", dest="target_name", metavar="NAME",
83 help="attach to a process with specified name")
84 group.add_argument(
85 "-r", dest="run_cmd", metavar="CMD", nargs=argparse.REMAINDER,
86 help="run a binary on the device, with args")
87
88 parser.add_argument(
89 "--port", nargs="?", default="5039",
Elliott Hughes89e1ecf2017-06-30 14:03:32 -070090 help="override the port used on the host [default: 5039]")
Josh Gao043bad72015-09-22 11:43:08 -070091 parser.add_argument(
92 "--user", nargs="?", default="root",
93 help="user to run commands as on the device [default: root]")
Alex Light92476652019-01-17 11:18:48 -080094 parser.add_argument(
Alex Lighta8f224d2020-11-10 10:30:19 -080095 "--setup-forwarding", default=None,
Elliott Hughes4c8e8752021-06-25 14:23:22 -070096 choices=["lldb", "vscode-lldb"],
97 help=("Set up lldb-server and port forwarding. Prints commands or " +
Alex Light92476652019-01-17 11:18:48 -080098 ".vscode/launch.json configuration needed to connect the debugging " +
Elliott Hughes4c8e8752021-06-25 14:23:22 -070099 "client to the server. 'vscode' with llbd and 'vscode-lldb' both " +
100 "require the 'vadimcn.vscode-lldb' extension."))
Haibo Huange194fce2020-01-06 14:40:27 -0800101
Peter Collingbourne63bf1082018-12-19 20:51:42 -0800102 parser.add_argument(
103 "--env", nargs=1, action="append", metavar="VAR=VALUE",
104 help="set environment variable when running a binary")
Peter Collingbourneba548262022-03-03 12:17:43 -0800105 parser.add_argument(
106 "--chroot", nargs='?', default="", metavar="PATH",
107 help="run command in a chroot in the given directory")
Peter Collingbourne63bf1082018-12-19 20:51:42 -0800108
Josh Gao043bad72015-09-22 11:43:08 -0700109 return parser.parse_args()
110
111
Elliott Hughes1a2f12d2017-06-02 13:15:59 -0700112def verify_device(root, device):
Junichi Uekawa6612c922020-09-07 11:20:59 +0900113 names = set([device.get_prop("ro.build.product"), device.get_prop("ro.product.name")])
Josh Gao466e2892017-07-13 15:39:05 -0700114 target_device = os.environ["TARGET_PRODUCT"]
Junichi Uekawa6612c922020-09-07 11:20:59 +0900115 if target_device not in names:
Josh Gao466e2892017-07-13 15:39:05 -0700116 msg = "TARGET_PRODUCT ({}) does not match attached device ({})"
Junichi Uekawa6612c922020-09-07 11:20:59 +0900117 sys.exit(msg.format(target_device, ", ".join(names)))
Josh Gao043bad72015-09-22 11:43:08 -0700118
119
120def get_remote_pid(device, process_name):
121 processes = gdbrunner.get_processes(device)
122 if process_name not in processes:
123 msg = "failed to find running process {}".format(process_name)
124 sys.exit(msg)
125 pids = processes[process_name]
126 if len(pids) > 1:
127 msg = "multiple processes match '{}': {}".format(process_name, pids)
128 sys.exit(msg)
129
130 # Fetch the binary using the PID later.
131 return pids[0]
132
133
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700134def make_temp_dir(prefix):
135 global g_temp_dirs
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700136 result = tempfile.mkdtemp(prefix='lldbclient-linker-')
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700137 g_temp_dirs.append(result)
138 return result
139
140
141def ensure_linker(device, sysroot, interp):
142 """Ensure that the device's linker exists on the host.
143
144 PT_INTERP is usually /system/bin/linker[64], but on the device, that file is
145 a symlink to /apex/com.android.runtime/bin/linker[64]. The symbolized linker
146 binary on the host is located in ${sysroot}/apex, not in ${sysroot}/system,
147 so add the ${sysroot}/apex path to the solib search path.
148
149 PT_INTERP will be /system/bin/bootstrap/linker[64] for executables using the
150 non-APEX/bootstrap linker. No search path modification is needed.
151
152 For a tapas build, only an unbundled app is built, and there is no linker in
153 ${sysroot} at all, so copy the linker from the device.
154
155 Returns:
156 A directory to add to the soinfo search path or None if no directory
157 needs to be added.
158 """
159
160 # Static executables have no interpreter.
161 if interp is None:
162 return None
163
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700164 # lldb will search for the linker using the PT_INTERP path. First try to find
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700165 # it in the sysroot.
166 local_path = os.path.join(sysroot, interp.lstrip("/"))
167 if os.path.exists(local_path):
168 return None
169
170 # If the linker on the device is a symlink, search for the symlink's target
171 # in the sysroot directory.
172 interp_real, _ = device.shell(["realpath", interp])
173 interp_real = interp_real.strip()
174 local_path = os.path.join(sysroot, interp_real.lstrip("/"))
175 if os.path.exists(local_path):
176 if posixpath.basename(interp) == posixpath.basename(interp_real):
177 # Add the interpreter's directory to the search path.
178 return os.path.dirname(local_path)
179 else:
180 # If PT_INTERP is linker_asan[64], but the sysroot file is
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700181 # linker[64], then copy the local file to the name lldb expects.
182 result = make_temp_dir('lldbclient-linker-')
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700183 shutil.copy(local_path, os.path.join(result, posixpath.basename(interp)))
184 return result
185
186 # Pull the system linker.
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700187 result = make_temp_dir('lldbclient-linker-')
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700188 device.pull(interp, os.path.join(result, posixpath.basename(interp)))
189 return result
Josh Gao043bad72015-09-22 11:43:08 -0700190
191
David Pursell639d1c42015-10-20 15:38:32 -0700192def handle_switches(args, sysroot):
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700193 """Fetch the targeted binary and determine how to attach lldb.
Josh Gao043bad72015-09-22 11:43:08 -0700194
195 Args:
196 args: Parsed arguments.
197 sysroot: Local sysroot path.
198
199 Returns:
200 (binary_file, attach_pid, run_cmd).
201 Precisely one of attach_pid or run_cmd will be None.
202 """
203
204 device = args.device
205 binary_file = None
206 pid = None
207 run_cmd = None
208
Josh Gao057c2732017-05-24 15:55:50 -0700209 args.su_cmd = ["su", args.user] if args.user else []
210
Josh Gao043bad72015-09-22 11:43:08 -0700211 if args.target_pid:
212 # Fetch the binary using the PID later.
213 pid = args.target_pid
214 elif args.target_name:
215 # Fetch the binary using the PID later.
216 pid = get_remote_pid(device, args.target_name)
217 elif args.run_cmd:
218 if not args.run_cmd[0]:
219 sys.exit("empty command passed to -r")
Josh Gao043bad72015-09-22 11:43:08 -0700220 run_cmd = args.run_cmd
Kevin Rocard258c89e2017-07-12 18:21:29 -0700221 if not run_cmd[0].startswith("/"):
222 try:
223 run_cmd[0] = gdbrunner.find_executable_path(device, args.run_cmd[0],
224 run_as_cmd=args.su_cmd)
225 except RuntimeError:
226 sys.exit("Could not find executable '{}' passed to -r, "
227 "please provide an absolute path.".format(args.run_cmd[0]))
228
David Pursell639d1c42015-10-20 15:38:32 -0700229 binary_file, local = gdbrunner.find_file(device, run_cmd[0], sysroot,
Josh Gao057c2732017-05-24 15:55:50 -0700230 run_as_cmd=args.su_cmd)
Josh Gao043bad72015-09-22 11:43:08 -0700231 if binary_file is None:
232 assert pid is not None
233 try:
David Pursell639d1c42015-10-20 15:38:32 -0700234 binary_file, local = gdbrunner.find_binary(device, pid, sysroot,
Josh Gao057c2732017-05-24 15:55:50 -0700235 run_as_cmd=args.su_cmd)
Josh Gao043bad72015-09-22 11:43:08 -0700236 except adb.ShellError:
237 sys.exit("failed to pull binary for PID {}".format(pid))
238
David Pursell639d1c42015-10-20 15:38:32 -0700239 if not local:
240 logging.warning("Couldn't find local unstripped executable in {},"
241 " symbols may not be available.".format(sysroot))
242
Josh Gao043bad72015-09-22 11:43:08 -0700243 return (binary_file, pid, run_cmd)
244
Edward Liaw22e9c502022-04-06 22:23:50 +0000245def generate_vscode_lldb_script(root, sysroot, binary_name, host, port, solib_search_path):
Alex Lighta8f224d2020-11-10 10:30:19 -0800246 # TODO It would be nice if we didn't need to copy this or run the
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700247 # lldbclient.py program manually. Doing this would probably require
Alex Lighta8f224d2020-11-10 10:30:19 -0800248 # writing a vscode extension or modifying an existing one.
249 # TODO: https://code.visualstudio.com/api/references/vscode-api#debug and
250 # https://code.visualstudio.com/api/extension-guides/debugger-extension and
251 # https://github.com/vadimcn/vscode-lldb/blob/6b775c439992b6615e92f4938ee4e211f1b060cf/extension/pickProcess.ts#L6
252 res = {
253 "name": "(lldbclient.py) Attach {} (port: {})".format(binary_name.split("/")[-1], port),
254 "type": "lldb",
255 "request": "custom",
256 "relativePathBase": root,
257 "sourceMap": { "/b/f/w" : root, '': root, '.': root },
258 "initCommands": ['settings append target.exec-search-paths {}'.format(' '.join(solib_search_path))],
259 "targetCreateCommands": ["target create {}".format(binary_name),
260 "target modules search-paths add / {}/".format(sysroot)],
Edward Liaw22e9c502022-04-06 22:23:50 +0000261 "processCreateCommands": ["gdb-remote {}:{}".format(host, port)]
Alex Lighta8f224d2020-11-10 10:30:19 -0800262 }
263 return json.dumps(res, indent=4)
264
Edward Liaw22e9c502022-04-06 22:23:50 +0000265def generate_lldb_script(root, sysroot, binary_name, host, port, solib_search_path):
Haibo Huange194fce2020-01-06 14:40:27 -0800266 commands = []
267 commands.append(
268 'settings append target.exec-search-paths {}'.format(' '.join(solib_search_path)))
269
270 commands.append('target create {}'.format(binary_name))
Haibo Huang987436c2020-09-22 21:01:31 -0700271 # For RBE support.
272 commands.append("settings append target.source-map '/b/f/w' '{}'".format(root))
273 commands.append("settings append target.source-map '' '{}'".format(root))
Haibo Huange194fce2020-01-06 14:40:27 -0800274 commands.append('target modules search-paths add / {}/'.format(sysroot))
Edward Liaw22e9c502022-04-06 22:23:50 +0000275 commands.append('gdb-remote {}:{}'.format(host, port))
Haibo Huange194fce2020-01-06 14:40:27 -0800276 return '\n'.join(commands)
277
278
Edward Liaw22e9c502022-04-06 22:23:50 +0000279def generate_setup_script(debugger_path, sysroot, linker_search_dir, binary_file, is64bit, host, port, debugger, connect_timeout=5):
Alex Light92476652019-01-17 11:18:48 -0800280 # Generate a setup script.
Alex Light92476652019-01-17 11:18:48 -0800281 root = os.environ["ANDROID_BUILD_TOP"]
282 symbols_dir = os.path.join(sysroot, "system", "lib64" if is64bit else "lib")
283 vendor_dir = os.path.join(sysroot, "vendor", "lib64" if is64bit else "lib")
284
285 solib_search_path = []
286 symbols_paths = ["", "hw", "ssl/engines", "drm", "egl", "soundfx"]
287 vendor_paths = ["", "hw", "egl"]
288 solib_search_path += [os.path.join(symbols_dir, x) for x in symbols_paths]
289 solib_search_path += [os.path.join(vendor_dir, x) for x in vendor_paths]
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700290 if linker_search_dir is not None:
291 solib_search_path += [linker_search_dir]
Alex Light92476652019-01-17 11:18:48 -0800292
Alex Lighta8f224d2020-11-10 10:30:19 -0800293 if debugger == "vscode-lldb":
294 return generate_vscode_lldb_script(
Edward Liaw22e9c502022-04-06 22:23:50 +0000295 root, sysroot, binary_file.name, host, port, solib_search_path)
Haibo Huange194fce2020-01-06 14:40:27 -0800296 elif debugger == 'lldb':
297 return generate_lldb_script(
Edward Liaw22e9c502022-04-06 22:23:50 +0000298 root, sysroot, binary_file.name, host, port, solib_search_path)
Alex Light92476652019-01-17 11:18:48 -0800299 else:
300 raise Exception("Unknown debugger type " + debugger)
301
Josh Gao043bad72015-09-22 11:43:08 -0700302
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700303def do_main():
Josh Gao466e2892017-07-13 15:39:05 -0700304 required_env = ["ANDROID_BUILD_TOP",
305 "ANDROID_PRODUCT_OUT", "TARGET_PRODUCT"]
306 for env in required_env:
307 if env not in os.environ:
308 sys.exit(
309 "Environment variable '{}' not defined, have you run lunch?".format(env))
310
Josh Gao043bad72015-09-22 11:43:08 -0700311 args = parse_args()
312 device = args.device
Josh Gao44b84a82015-10-28 11:57:37 -0700313
314 if device is None:
315 sys.exit("ERROR: Failed to find device.")
316
Edward Liaw22e9c502022-04-06 22:23:50 +0000317 if ":" in device.serial:
318 host = device.serial.split(":")[0]
319 else:
Elliott Hughesbc119c22022-06-14 17:59:32 -0700320 # lldb is broken with "localhost" right now (http://b/234034124)
321 host = "127.0.0.1"
Edward Liaw22e9c502022-04-06 22:23:50 +0000322
Josh Gao043bad72015-09-22 11:43:08 -0700323 root = os.environ["ANDROID_BUILD_TOP"]
Josh Gao466e2892017-07-13 15:39:05 -0700324 sysroot = os.path.join(os.environ["ANDROID_PRODUCT_OUT"], "symbols")
Josh Gao043bad72015-09-22 11:43:08 -0700325
326 # Make sure the environment matches the attached device.
Peter Collingbourneba548262022-03-03 12:17:43 -0800327 # Skip when running in a chroot because the chroot lunch target may not
328 # match the device's lunch target.
329 if not args.chroot:
330 verify_device(root, device)
Josh Gao043bad72015-09-22 11:43:08 -0700331
332 debug_socket = "/data/local/tmp/debug_socket"
333 pid = None
334 run_cmd = None
335
336 # Fetch binary for -p, -n.
David Pursell639d1c42015-10-20 15:38:32 -0700337 binary_file, pid, run_cmd = handle_switches(args, sysroot)
Josh Gao043bad72015-09-22 11:43:08 -0700338
339 with binary_file:
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700340 if sys.platform.startswith("linux"):
341 platform_name = "linux-x86"
342 elif sys.platform.startswith("darwin"):
343 platform_name = "darwin-x86"
344 else:
345 sys.exit("Unknown platform: {}".format(sys.platform))
346
Josh Gao043bad72015-09-22 11:43:08 -0700347 arch = gdbrunner.get_binary_arch(binary_file)
348 is64bit = arch.endswith("64")
349
350 # Make sure we have the linker
Pirama Arumuga Nainarf7f95442021-06-30 13:31:41 -0700351 clang_base = 'prebuilts/clang/host'
352 clang_version = read_toolchain_config(root)
Haibo Huange194fce2020-01-06 14:40:27 -0800353 toolchain_path = os.path.join(root, clang_base, platform_name,
354 clang_version)
355 llvm_readobj_path = os.path.join(toolchain_path, "bin", "llvm-readobj")
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700356 interp = gdbrunner.get_binary_interp(binary_file.name, llvm_readobj_path)
357 linker_search_dir = ensure_linker(device, sysroot, interp)
Josh Gao043bad72015-09-22 11:43:08 -0700358
Elliott Hughes89e1ecf2017-06-30 14:03:32 -0700359 tracer_pid = get_tracer_pid(device, pid)
360 if tracer_pid == 0:
Peter Collingbourne63bf1082018-12-19 20:51:42 -0800361 cmd_prefix = args.su_cmd
362 if args.env:
363 cmd_prefix += ['env'] + [v[0] for v in args.env]
364
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700365 # Start lldb-server.
366 server_local_path = get_lldb_server_path(root, clang_base, clang_version, arch)
367 server_remote_path = "/data/local/tmp/{}-lldb-server".format(arch)
Elliott Hughes89e1ecf2017-06-30 14:03:32 -0700368 gdbrunner.start_gdbserver(
Haibo Huange194fce2020-01-06 14:40:27 -0800369 device, server_local_path, server_remote_path,
Elliott Hughes89e1ecf2017-06-30 14:03:32 -0700370 target_pid=pid, run_cmd=run_cmd, debug_socket=debug_socket,
Peter Collingbourneba548262022-03-03 12:17:43 -0800371 port=args.port, run_as_cmd=cmd_prefix, lldb=True, chroot=args.chroot)
Elliott Hughes89e1ecf2017-06-30 14:03:32 -0700372 else:
Haibo Huange194fce2020-01-06 14:40:27 -0800373 print(
374 "Connecting to tracing pid {} using local port {}".format(
375 tracer_pid, args.port))
Elliott Hughes89e1ecf2017-06-30 14:03:32 -0700376 gdbrunner.forward_gdbserver_port(device, local=args.port,
377 remote="tcp:{}".format(args.port))
Josh Gao043bad72015-09-22 11:43:08 -0700378
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700379 debugger_path = get_lldb_path(toolchain_path)
380 debugger = args.setup_forwarding or 'lldb'
Haibo Huange194fce2020-01-06 14:40:27 -0800381
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700382 # Generate the lldb script.
Haibo Huange194fce2020-01-06 14:40:27 -0800383 setup_commands = generate_setup_script(debugger_path=debugger_path,
Alex Light92476652019-01-17 11:18:48 -0800384 sysroot=sysroot,
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700385 linker_search_dir=linker_search_dir,
Alex Light92476652019-01-17 11:18:48 -0800386 binary_file=binary_file,
387 is64bit=is64bit,
Edward Liaw22e9c502022-04-06 22:23:50 +0000388 host=host,
Alex Light92476652019-01-17 11:18:48 -0800389 port=args.port,
Haibo Huange194fce2020-01-06 14:40:27 -0800390 debugger=debugger)
Josh Gao043bad72015-09-22 11:43:08 -0700391
Alex Lighta8f224d2020-11-10 10:30:19 -0800392 if not args.setup_forwarding:
Alex Light92476652019-01-17 11:18:48 -0800393 # Print a newline to separate our messages from the GDB session.
394 print("")
David Pursell639d1c42015-10-20 15:38:32 -0700395
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700396 # Start lldb.
397 gdbrunner.start_gdb(debugger_path, setup_commands, lldb=True)
Alex Light92476652019-01-17 11:18:48 -0800398 else:
399 print("")
Haibo Huange194fce2020-01-06 14:40:27 -0800400 print(setup_commands)
Alex Light92476652019-01-17 11:18:48 -0800401 print("")
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700402 if args.setup_forwarding == "vscode-lldb":
Haibo Huange194fce2020-01-06 14:40:27 -0800403 print(textwrap.dedent("""
Alex Light92476652019-01-17 11:18:48 -0800404 Paste the above json into .vscode/launch.json and start the debugger as
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700405 normal. Press enter in this terminal once debugging is finished to shut
406 lldb-server down and close all the ports."""))
Alex Light92476652019-01-17 11:18:48 -0800407 else:
Haibo Huange194fce2020-01-06 14:40:27 -0800408 print(textwrap.dedent("""
Elliott Hughes4c8e8752021-06-25 14:23:22 -0700409 Paste the lldb commands above into the lldb frontend to set up the
410 lldb-server connection. Press enter in this terminal once debugging is
411 finished to shut lldb-server down and close all the ports."""))
Alex Light92476652019-01-17 11:18:48 -0800412 print("")
Siarhei Vishniakou9c4f1b32021-12-02 10:43:14 -0800413 input("Press enter to shut down lldb-server")
Josh Gao043bad72015-09-22 11:43:08 -0700414
Ryan Prichard5d1c3cb2019-06-04 16:35:02 -0700415
416def main():
417 try:
418 do_main()
419 finally:
420 global g_temp_dirs
421 for temp_dir in g_temp_dirs:
422 shutil.rmtree(temp_dir)
423
424
Josh Gao043bad72015-09-22 11:43:08 -0700425if __name__ == "__main__":
426 main()