views:

154

answers:

0

I'm trying to use rdebug with emacs and cygwin and I'm running into trouble. Whenever I do a M-x rdebug and give it the appropriate script to run, it stops with the error

 "apply: Spawning child process: exec format error"

From some googling, it seems like this could happen if I'm trying to launch a cygwin executable via the windows command prompt or vice versa. It could also happen if the path to the executable is a unix style link.

I'm trying to figure out the place where rdebug is being exec'd from to check which of these is the problem and how to fix it.

I've tried the following so far, but no joy: * Use edebug on rdebug and it's callees: That got me into gud-common-init and I quickly lost my way trying to find out where the exec call is happening. * Try switching the shell from cygwin to windows and back to see if there is any difference: no difference at all.

Note that I can run rdebug from my windows shell as well as from my cygwin shell (invoked via M-x shell). I'm guessing the /usr/bin/rdebug and /usr/bin/rdebug.bat have something to do with this.

Any ideas to fix this or to debug this issue would be really great.

Some progress

I managed to figure out that I can replicate the same problem with attempting to execute rdebug using comint-run (M-x comint-run ENTER rdebug ENTER). From some debugging and wading thru' the code, it looks like emacs is calling start-file-process (similar to the comint-run) to start the rdebug process.

I also have the following while loading up 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 ?\") ;; " 

More progress

Temporarily renaming rdebug.bat revealed that comint-run was invoking rdebug.bat via a dos shell. I'd like rdebug to be invoked via a bash shell when I invoke comint-run. Any ideas on how to specify which shell comint-run uses?