Debugging a forked perl process in emacs should open a new buffer

45 views
Skip to first unread message

yary

unread,
Dec 6, 2012, 4:57:58 PM12/6/12
to emacs-perl-...@googlegroups.com
What the subject says. Running perl-db ought to inject a sub for DB::get_fork_TTY that opens a new Emacs buffer with a tty and returns it, so when debugging perl code that forks/threads, you get a debugger window for each interpreter.

I'm going to take a quick look at it... consider this a request for guru-cycles... a few others have posted on the 'net about it but no working examples cited.

yary

unread,
Dec 6, 2012, 5:52:06 PM12/6/12
to emacs-perl-...@googlegroups.com
The perl side would look like
sub DB::get_fork_TTY {
 return `emacsclient -e "$some_elisp"`
}
where $some_elisp opens a frame (or window), allocating a tty (pty?), and returning the new tty/pty.

The only thing is I'm running on Windows and as far as I can tell "emacs cannot allocate a pseudo-tty on Windows" so I am not going to dig into that elisp, which is a weak point for me anyways.

yary

unread,
Dec 6, 2012, 6:19:29 PM12/6/12
to emacs-perl-...@googlegroups.com
Does the perl debugger care if the file it gets handed is a "real" pty/tty? What if emacs opened a named pipe & returned that? Then started inserting what it reads into the buffer, sending keyboard input back into the pipe? In short, emacs is the tty.

Talking to myself, not writing code, need to stop.

Joseph Brenner

unread,
Dec 7, 2012, 2:26:52 PM12/7/12
to yary, emacs-perl-...@googlegroups.com
yary <not...@gmail.com> wrote:
> What the subject says. Running perl-db ought to inject a sub for
> DB::get_fork_TTY that opens a new Emacs buffer with a tty and returns it, so
> when debugging perl code that forks/threads, you get a debugger window for
> each interpreter.

If you got something like that working, that'd be useful in a number
of cases. Last I looked, if you wanted to debug mod_perl code with
emacs, you had to run the apache as single-process (-X option, I
think). If I remember right, pTk could deal with apache sans -X, but
not emacs perldb.

yary

unread,
Dec 7, 2012, 2:43:58 PM12/7/12
to emacs-perl-...@googlegroups.com, yary
looking into this showed me a new-ish package for using tmux to help with debugging forking processes
http://cpansearch.perl.org/src/VERESC/Debug-Fork-Tmux-1.000009/README.html
which ought to help with debugging apache.

Still doesn't help my in windows-land, or with emacs specifically. I did get some ideas. The debug docs talk about options to use filehandles in lieu of TTY's, and there are instructions on custom debugger front ends. Alas it has been a time sink... if I ever do get around to it I'll post on perlmonks & some appropriate emacs forum & leave a pointer here.

LanX

unread,
Dec 7, 2012, 2:55:01 PM12/7/12
to emacs-perl-...@googlegroups.com
hmm

I already replied per mail, but somehow the answer doesn't appear in the google-group...

So once again:

-----------------------------------------------------
Hi yary

this group has been inactive for years now and the questions you're asking are so special that only combined forces of P5P and emacs-gurus can answer them

The only thing that I can tell you is that debugger-buffers in emacs are named after the debugged script. So somehow renaming the fork could help.

Cheers
  Rolf
Reply all
Reply to author
Forward
0 new messages