Re: recent commit breaks multi-module debugging

Bill Clementson <[email protected]> Wed, 20 Jun 2007 09:02:43 -0700
Newsgroups gmane.comp.lang.erlang.distel.devel
Message-ID <[email protected]>
Matthias Radestock <[email protected]> writes:

> Bill Clementson <[email protected]> writes:
>
>> I was encountering it on a regular basis. However, I often debug in
>> the Emacs Erlang shell node and not in a separate Erlang node so maybe
>> that might be a factor.
>
> Ah, I never do that.

Hmm, actually, the problem is a distel problem so it is reproducible
in other erlang nodes too, so this shouldn't be a factor.

>> How would my new patch break multiple module debugging? If all modules
>> are running in the same node, it should have no impact at all. Did you
>> mean "across multiple *nodes*"?
>
> Yes, I did mean that. Sorry about the confusion.
>
>> If so, then yes my patch would reset the distel interpreted status
>> every time you switched nodes. However, the break points that are set
>> in the node would still exist. When you switch from one node to
>> another, you would need to toggle on interpreted status for a buffer.
>
> That doesn't sound too bad. How does this differ from the previous
> behaviour?

Previously, I was not able to debug (without re-starting emacs) if I
killed the erlang node that I had been debugging and subsequently
tried to debug it again. Now I can do this.

> I still don't understand the need for the change. Do you have a
> reproducible test case?

Yes, see below.

> Looking at the code, it seems that edb-start-monitor should update the
> interpreted status of modules in distel with that of the node. This
> suggests that manual toggling when switching nodes shouldn't actually be
> necessary. Also take a look at edb-ensure-monitoring and
> edb-monitor-node-change-p, which both supposedly deal with node
> switching.

The main problem occurs when you have done something to change the
"state" of the erlang node that is being debugged. Once this happens,
there is currently no way in distel to reset things. In my test case
below, I do this by killing the node and restarting it because this is
easy to reproduce; however, it could also be affected by other things
(perhaps clearing assigned variables). This same bug has hit me a
number of different times when I've been debugging in distel. I think
there needs to be some way to "reset" debugging in distel. It would be
nice if this could occur automatically (for example, when attaching to
a node or when a connection to a debugged node is lost). However, if
this might cause problems, maybe it would be better to just have a
separate function to reset debugging. What do you think?

--
Bill Clementson

Reproducible test case is below:
-------------------------------------------------------------------------
The following reproducible test case assumes the following test.erl file:
-module(test).
-export([test/0]).

test() ->
    io:format("line 1"),
    io:format("line 2"),
    io:format("line 3"),
    io:format("line 4"),
    io:format("line 5"),
    io:format("line 6").

1. Open erlang source file test.erl
2. Open erlang shell in emacs with "C-c C-z"
3. Compile test.erl with debug_info
4. Select erlang node for distel with "C-c C-d n" - specify the emacs 
   erlang shell.
   Note#1: in my .emacs file, I do:
   (setq inferior-erlang-machine-options '("-sname" "emacs"))
   so that I have a node name of "emacs" for the erlang shell.
   Note#2: You should be able to use any erlang node to replicate this test 
   as the problem is a distel one; however, this test case uses the emacs 
   erlang shell.
5. Toggle interpreting "on" in test.erl with "C-c C-d i"
6. Toggle a breakpoint "on" for a line in test with "C-x SPC"
7. In the emacs erlang shell, run test:test(). to hit the breakpoint
8. The edb process monitor window will pop up - press enter on the test.erl 
   process
9. In the edbproc debugging window, press "c" to continue - function will 
   run to completion
10. Kill the emacs erlang shell buffer with "M-x kill-buffer"
11. In the test.erl source buffer, open a new erlang shell in emacs with 
    "C-c C-z"
12. Select erlang node for distel with "C-c C-d n" - specify the emacs 
    erlang shell
13. Toggle interpreting "on" with "C-c C-d i" in the test.erl buffer
14. Toggle a breakpoint "on" for a line in test with "C-x SPC"

At this point, you will get the error: "Module is not interpreted,
can't set breakpoints."  You can try toggling interpreting on and off
a few more times; however, you will not be able to set a breakpoint or
debug this or any other module. If you apply the patch that I sent in
my last email to erl-choose-nodename in erl-service.el and re-load the
erl-choose-nodename function, you can then retry steps 12-14 above and
will be able to successfully set a breakpoint and start debugging
again.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/