From b61f795aa44c0135cc03559b5627d6531202df67 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Fri, 14 Oct 2022 00:09:15 +0000 Subject: [PATCH] Use `gdb-remote` without host if not given Test: lldbclient.py -r ls Change-Id: I162d318fa30c44f180b6104b31e61e7521fb6a48 --- scripts/gdbclient.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/gdbclient.py b/scripts/gdbclient.py index 8c4262dd8..1c864beef 100755 --- a/scripts/gdbclient.py +++ b/scripts/gdbclient.py @@ -242,6 +242,11 @@ def handle_switches(args, sysroot): return (binary_file, pid, run_cmd) +def format_hostport(host, port): + if host is not None: + return "{}:{}".format(host, port) + return str(port) + def generate_vscode_lldb_script(root, sysroot, binary_name, host, port, solib_search_path): # TODO It would be nice if we didn't need to copy this or run the # lldbclient.py program manually. Doing this would probably require @@ -258,7 +263,7 @@ def generate_vscode_lldb_script(root, sysroot, binary_name, host, port, solib_se "initCommands": ['settings append target.exec-search-paths {}'.format(' '.join(solib_search_path))], "targetCreateCommands": ["target create {}".format(binary_name), "target modules search-paths add / {}/".format(sysroot)], - "processCreateCommands": ["gdb-remote {}:{}".format(host, port)] + "processCreateCommands": ["gdb-remote {}".format(format_hostport(host, port))] } return json.dumps(res, indent=4) @@ -272,7 +277,7 @@ def generate_lldb_script(root, sysroot, binary_name, host, port, solib_search_pa commands.append("settings append target.source-map '/b/f/w' '{}'".format(root)) commands.append("settings append target.source-map '' '{}'".format(root)) commands.append('target modules search-paths add / {}/'.format(sysroot)) - commands.append('gdb-remote {}:{}'.format(host, port)) + commands.append('gdb-remote {}'.format(format_hostport(host, port))) return '\n'.join(commands) @@ -317,8 +322,7 @@ def do_main(): if ":" in device.serial: host = device.serial.split(":")[0] else: - # lldb is broken with "localhost" right now (http://b/234034124) - host = "127.0.0.1" + host = None root = os.environ["ANDROID_BUILD_TOP"] sysroot = os.path.join(os.environ["ANDROID_PRODUCT_OUT"], "symbols")