Index: test/tools/lldb-server/gdbremote_testcase.py =================================================================== --- test/tools/lldb-server/gdbremote_testcase.py +++ test/tools/lldb-server/gdbremote_testcase.py @@ -142,24 +142,36 @@ def init_llgs_test(self, use_named_pipe=True): if lldb.remote_platform: + def run_shell_cmd(cmd): + platform = self.dbg.GetSelectedPlatform() + shell_cmd = lldb.SBPlatformShellCommand(cmd) + err = platform.Run(shell_cmd) + if err.Fail() or shell_cmd.GetStatus(): + m = "remote_platform.RunShellCommand('%s') failed:\n" % cmd + m += ">>> return code: %d\n" % shell_cmd.GetStatus() + if err.Fail(): + m += ">>> %s\n" % str(err).strip() + m += ">>> %s\n" % (shell_cmd.GetOutput() or + "Command generated no output.") + raise Exception(m) + return shell_cmd.GetOutput() # Remote platforms don't support named pipe based port negotiation use_named_pipe = False - platform = self.dbg.GetSelectedPlatform() - - shell_command = lldb.SBPlatformShellCommand("echo $PPID") - err = platform.Run(shell_command) - if err.Fail(): - raise Exception("remote_platform.RunShellCommand('echo $PPID') failed: %s" % err) - pid = shell_command.GetOutput().strip() + pid = run_shell_cmd("echo $PPID").strip() + try: + exe = run_shell_cmd("readlink /proc/%s/exe" % pid) + except Exception as e: + print "%s.\n>>> Looking up exe name from cmdline..." % str(e) + cmdline = run_shell_cmd("cat /proc/%s/cmdline" % pid).strip() + exe = cmdline.split()[0] + if exe[0] != '/': + raise Exception("'exe' path in cmdline is not absolute.\n" + "Giving up looking for lldb-server exe.") - shell_command = lldb.SBPlatformShellCommand("readlink /proc/%s/exe" % pid) - err = platform.Run(shell_command) - if err.Fail(): - raise Exception("remote_platform.RunShellCommand('readlink /proc/%d/exe') failed: %s" % (pid, err)) # 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\)$', '', shell_command.GetOutput().strip()) + self.debug_monitor_exe = re.sub(r' \(deleted\)$', '', exe.strip()) else: self.debug_monitor_exe = get_lldb_server_exe() if not self.debug_monitor_exe: