Differential D56233 Diff 194380 packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
Changeset View
Changeset View
Standalone View
Standalone View
packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
Show First 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | def get_stub_port_from_named_socket(self, read_timeout_seconds=5): | ||||
return stub_port | return stub_port | ||||
def init_llgs_test(self, use_named_pipe=True): | def init_llgs_test(self, use_named_pipe=True): | ||||
if lldb.remote_platform: | if lldb.remote_platform: | ||||
# Remote platforms don't support named pipe based port negotiation | # Remote platforms don't support named pipe based port negotiation | ||||
use_named_pipe = False | use_named_pipe = False | ||||
triple = self.dbg.GetSelectedPlatform().GetTriple() | |||||
if re.match(".*-.*-windows", triple): | |||||
self.skipTest("Remotely testing is not supported on Windows yet.") | |||||
# Grab the ppid from /proc/[shell pid]/stat | # Grab the ppid from /proc/[shell pid]/stat | ||||
err, retcode, shell_stat = self.run_platform_command( | err, retcode, shell_stat = self.run_platform_command( | ||||
"cat /proc/$$/stat") | "cat /proc/$$/stat") | ||||
self.assertTrue( | self.assertTrue( | ||||
err.Success() and retcode == 0, | err.Success() and retcode == 0, | ||||
"Failed to read file /proc/$$/stat: %s, retcode: %d" % | "Failed to read file /proc/$$/stat: %s, retcode: %d" % | ||||
(err.GetCString(), | (err.GetCString(), | ||||
retcode)) | retcode)) | ||||
Show All 9 Lines | def init_llgs_test(self, use_named_pipe=True): | ||||
err.GetCString(), | err.GetCString(), | ||||
retcode)) | retcode)) | ||||
exe = ls_output.split()[-1] | exe = ls_output.split()[-1] | ||||
# If the binary has been deleted, the link name has " (deleted)" appended. | # If the binary has been deleted, the link name has " (deleted)" appended. | ||||
# Remove if it's there. | # Remove if it's there. | ||||
self.debug_monitor_exe = re.sub(r' \(deleted\)$', '', exe) | self.debug_monitor_exe = re.sub(r' \(deleted\)$', '', exe) | ||||
else: | else: | ||||
# Need to figure out how to create a named pipe on Windows. | |||||
if platform.system() == 'Windows': | |||||
use_named_pipe = False | |||||
self.debug_monitor_exe = get_lldb_server_exe() | self.debug_monitor_exe = get_lldb_server_exe() | ||||
if not self.debug_monitor_exe: | if not self.debug_monitor_exe: | ||||
self.skipTest("lldb-server exe not found") | self.skipTest("lldb-server exe not found") | ||||
self.debug_monitor_extra_args = ["gdbserver"] | self.debug_monitor_extra_args = ["gdbserver"] | ||||
self.setUpServerLogging(is_llgs=True) | self.setUpServerLogging(is_llgs=True) | ||||
if use_named_pipe: | if use_named_pipe: | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | def connect_to_debug_monitor(self, attach_pid=None): | ||||
# Attach to the stub and return a socket opened to it. | # Attach to the stub and return a socket opened to it. | ||||
self.sock = self.create_socket() | self.sock = self.create_socket() | ||||
return server | return server | ||||
# We're using a random port algorithm to try not to collide with other ports, | # We're using a random port algorithm to try not to collide with other ports, | ||||
# and retry a max # times. | # and retry a max # times. | ||||
attempts = 0 | attempts = 0 | ||||
MAX_ATTEMPTS = 20 | MAX_ATTEMPTS = 20 | ||||
labath: I don't think this can go in like this. However, I agree that this double-retry loop is pretty… | |||||
while attempts < MAX_ATTEMPTS: | while attempts < MAX_ATTEMPTS: | ||||
server = self.launch_debug_monitor(attach_pid=attach_pid) | server = self.launch_debug_monitor(attach_pid=attach_pid) | ||||
# Schedule debug monitor to be shut down during teardown. | # Schedule debug monitor to be shut down during teardown. | ||||
logger = self.logger | logger = self.logger | ||||
def shutdown_debug_monitor(): | def shutdown_debug_monitor(): | ||||
▲ Show 20 Lines • Show All 1,204 Lines • Show Last 20 Lines |
I don't think this can go in like this. However, I agree that this double-retry loop is pretty ugly. When I get some time, I'll try to see if I can rewrite this part to use reverse connects. That way we won't get any races at all. For the time being, I'd just revert this.