diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -162,18 +162,11 @@ self._verbose_log_handler = None TestBase.tearDown(self) - def getLocalServerLogFile(self): - return self.getLogBasenameForCurrentTest() + "-server.log" - def setUpServerLogging(self, is_llgs): if len(lldbtest_config.channels) == 0: return # No logging requested - if lldb.remote_platform: - log_file = lldbutil.join_remote_paths( - lldb.remote_platform.GetWorkingDirectory(), "server.log") - else: - log_file = self.getLocalServerLogFile() + log_file = self.getLogBasenameForCurrentTest() + "-server.log" if is_llgs: self.debug_monitor_extra_args.append("--log-file=" + log_file) @@ -192,38 +185,7 @@ def _init_llgs_test(self): reverse_connect = True - if lldb.remote_platform: - # Reverse connections may be tricky due to firewalls/NATs. - reverse_connect = False - - # FIXME: This is extremely linux-oriented - - # Grab the ppid from /proc/[shell pid]/stat - err, retcode, shell_stat = self.run_platform_command( - "cat /proc/$$/stat") - self.assertTrue( - err.Success() and retcode == 0, - "Failed to read file /proc/$$/stat: %s, retcode: %d" % - (err.GetCString(), - retcode)) - - # [pid] ([executable]) [state] [*ppid*] - pid = re.match(r"^\d+ \(.+\) . (\d+)", shell_stat).group(1) - err, retcode, ls_output = self.run_platform_command( - "ls -l /proc/%s/exe" % pid) - self.assertTrue( - err.Success() and retcode == 0, - "Failed to read file /proc/%s/exe: %s, retcode: %d" % - (pid, - err.GetCString(), - retcode)) - exe = ls_output.split()[-1] - - # If the binary has been deleted, the link name has " (deleted)" appended. - # Remove if it's there. - self.debug_monitor_exe = re.sub(r' \(deleted\)$', '', exe) - else: - self.debug_monitor_exe = get_lldb_server_exe() + self.debug_monitor_exe = get_lldb_server_exe() self.debug_monitor_extra_args = ["gdbserver"] self.setUpServerLogging(is_llgs=True) @@ -239,31 +201,6 @@ # when the process truly dies. self.stub_sends_two_stop_notifications_on_kill = True - def forward_adb_port(self, source, target, direction, device): - adb = ['adb'] + (['-s', device] if device else []) + [direction] - - def remove_port_forward(): - subprocess.call(adb + ["--remove", "tcp:%d" % source]) - - subprocess.call(adb + ["tcp:%d" % source, "tcp:%d" % target]) - self.addTearDownHook(remove_port_forward) - - def _verify_socket(self, sock): - # Normally, when the remote stub is not ready, we will get ECONNREFUSED during the - # connect() attempt. However, due to the way how ADB forwarding works, on android targets - # the connect() will always be successful, but the connection will be immediately dropped - # if ADB could not connect on the remote side. This function tries to detect this - # situation, and report it as "connection refused" so that the upper layers attempt the - # connection again. - triple = self.dbg.GetSelectedPlatform().GetTriple() - if not re.match(".*-.*-.*-android", triple): - return # Not android. - can_read, _, _ = select.select([sock], [], [], 0.1) - if sock not in can_read: - return # Data is not available, but the connection is alive. - if len(sock.recv(1, socket.MSG_PEEK)) == 0: - raise _ConnectionRefused() # Got EOF, connection dropped. - def create_socket(self): try: sock = socket.socket(family=socket.AF_INET) @@ -274,14 +211,6 @@ logger = self.logger - triple = self.dbg.GetSelectedPlatform().GetTriple() - if re.match(".*-.*-.*-android", triple): - self.forward_adb_port( - self.port, - self.port, - "forward", - self.stub_device) - logger.info( "Connecting to debug monitor on %s:%d", self.stub_hostname, @@ -313,8 +242,6 @@ self.addTearDownHook(shutdown_socket) - self._verify_socket(sock) - return sock def set_inferior_startup_launch(self): @@ -333,10 +260,7 @@ if self.reverse_connect: commandline_args += ["--reverse-connect", self.connect_address] else: - if lldb.remote_platform: - commandline_args += ["*:{}".format(self.port)] - else: - commandline_args += ["localhost:{}".format(self.port)] + commandline_args += ["localhost:{}".format(self.port)] return commandline_args @@ -498,18 +422,6 @@ if not inferior_exe_path: inferior_exe_path = self.getBuildArtifact("a.out") - if lldb.remote_platform: - remote_path = lldbutil.append_to_process_working_directory(self, - os.path.basename(inferior_exe_path)) - remote_file_spec = lldb.SBFileSpec(remote_path, False) - err = lldb.remote_platform.Install(lldb.SBFileSpec( - inferior_exe_path, True), remote_file_spec) - if err.Fail(): - raise Exception( - "remote_platform.Install('%s', '%s') failed: %s" % - (inferior_exe_path, remote_path, err)) - inferior_exe_path = remote_path - launch_args = [inferior_exe_path] if inferior_args: launch_args.extend(inferior_args) @@ -1578,17 +1490,3 @@ def maybe_strict_output_regex(self, regex): return '.*' + regex + \ '.*' if lldbplatformutil.hasChattyStderr(self) else '^' + regex + '$' - - def install_and_create_launch_args(self): - exe_path = self.getBuildArtifact("a.out") - if not lldb.remote_platform: - return [exe_path] - remote_path = lldbutil.append_to_process_working_directory(self, - os.path.basename(exe_path)) - remote_file_spec = lldb.SBFileSpec(remote_path, False) - err = lldb.remote_platform.Install(lldb.SBFileSpec(exe_path, True), - remote_file_spec) - if err.Fail(): - raise Exception("remote_platform.Install('%s', '%s') failed: %s" % - (exe_path, remote_path, err)) - return [remote_path]