我正在尝试将 rdebug 与 emacs 和 cygwin 一起使用,但遇到了麻烦。每当我执行 M-x rdebug 并为其提供适当的脚本来运行时,它都会因错误而停止
"apply: Spawning child process: exec format error"
从一些谷歌搜索来看,如果我尝试通过 Windows 命令提示符启动 cygwin 可执行文件,似乎可能会发生这种情况,反之亦然。如果可执行文件的路径是 unix 样式链接,也可能会发生这种情况。
我试图找出执行 rdebug 的位置,以检查其中哪个是问题所在以及如何修复它。
到目前为止,我已经尝试过以下操作,但没有喜悦:
* 在 rdebug 上使用 edebug 及其被调用者:这让我进入了 gud-common-init,并且我很快就迷失了方向,试图找出 exec 调用发生的位置。
* 尝试将 shell 从 cygwin 切换到 windows,然后再切换回来,看看是否有任何差异:完全没有差异。
请注意,我可以从 Windows shell 以及 cygwin shell(通过 M-x shell 调用)运行 rdebug。我猜 /usr/bin/rdebug 和 /usr/bin/rdebug.bat 与此有关。
任何解决此问题或调试此问题的想法都非常好。
一些进展
我设法发现我可以通过尝试使用 comint-run (M-x comint-run ENTER rdebug ENTER) 执行 rdebug 来复制相同的问题。从一些调试和涉水代码来看,emacs 似乎正在调用 start-file-process (类似于 comint-run)来启动 rdebug 进程。
我在加载 cygwin 时也有以下内容:
;;; Use `bash' as the default shell in Emacs.
(setq exec-path (cons cygwin-bin exec-path))
(setq shell-file-name (concat cygwin-bin "/bash.exe")) ; Subprocesses invoked via the shell.
(setenv "SHELL" shell-file-name)
(setenv "PATH" (concat
(getenv "PATH")
(concat ";" (substring data-directory 0 2) "\\cygwin\\bin")) )
(setq explicit-shell-file-name shell-file-name) ; Interactive shell
(setq explicit-shell-args '("--login" "-i"))
(setq w32-quote-process-args ?\") ;; "
更多进展
临时重命名 rdebug.bat 显示 comint-run 正在通过 dos shell 调用 rdebug.bat。我希望在调用 comint-run 时通过 bash shell 调用 rdebug。关于如何指定 comint-run 使用哪个 shell 有什么想法吗?