Re: recent commit breaks multi-module debugging

Bill Clementson <[email protected]> Fri, 22 Jun 2007 11:36:09 -0700
Newsgroups gmane.comp.lang.erlang.distel.devel
Message-ID <[email protected]>
Hi Matthias,

Matthias Radestock <[email protected]> writes:

> Bill Clementson wrote:
>> Matthias Radestock <[email protected]> writes:
>> 
>>> Bill Clementson <[email protected]> writes:
>>>
>>>> The problem is that when a node goes down during debugging and the
>>>> interpreting state is "on", when you re-connect to the node, you have
>>>> to turn interpreting "off".
>>> Why? When the node goes down, the interpreting status is turned off
>>> automatically by edb-monitor-cleanup.
>> 
>> After re-connecting to the node and reloading the module, the first
>> time that I press "C-c C-d i", interpreting is toggled "off".
>
> When you say "reloading the module", what do you mean? Are you using the 
>    distel's "C-c C-d L" for that?

Yes, usually; however, I sometimes manually reload as well. 

> If so that may explain why the value of edb-monitor-node makes a 
> difference, since erl-reload-module calls erl-reinterpret-module if the 
> node is eq to edb-monitor-node and the module is in the 
> interpreted-modules list. Otherwise erl-do-reload is called.
>
> There is definitely a bug in this code: it uses 'eq' for testing node 
> name equivalence, instead of 'equal'. We should fix that.

Aha, this might be part of the problem - see below.

> I still cannot figure out what impact your patch has on this though. It 
> should only make a difference if the module is in 
> edb-interpreted-modules, which it shouldn't be since that variable will 
> have been cleared when the node died.
>
> What is the value of edb-interpreted-modules / the 'interpreted' status 
> as shown in the modeline after the following?
>
> 1) kill node that is being debugged -> nil/not-interpreted for me.

same for me 

> 2) restart node -> nil/not-interpreted for me.

same for me

> 3) reload module -> nil/not-interpreted for me.

same for me - have to do "C-c C-d L" twice (first time loads distel modules into node)

> 4) toggle interpreting with "C-c C-d i" -> ((test "/tmp/test.erl")) / 
> interpreted for me

same for me

> 5) toggle interpreting again -> nil/not-interpreted for me.

same for me

> The results I get are correct. I suspect they will be different for you, 
> since you say that toggling interpreting after a node restart turns 
> interpreting *off*.
>
> NB: I ran the above without your edb-monitor-node clearing patch, and 
> with it; makes no difference. I ran the node from a separate shell 
> since, as I mentioned before, debugging nodes started from emacs does 
> not work for me at all.

That particular test scenario works for me as well (even without my patch). 

However, the following one doesn't:

1. kill node that is being debugged
2. restart node
3. toggle interpreting on with "C-c C-d i" twice 
   (first time loads distel modules into node) 
   **note that I didn't reload the module into the node before toggling
   interpreting on**. 
   I get a minibuffer message that interpreting is on (but nothing in 
   mode line).
4. toggle interpreting off with "C-c C-d i". 
   I get a message that interpreting is off (but nothing in 
   mode line).
5. reload module with "C-c C-d L"
6. toggle interpreting on with "C-c C-d i" 
   I get a minibuffer message that interpreting is on (but nothing in 
   mode line).

at this point, you can't toggle interpreting on/off at all (e.g. -
nothing shows up in the mode line although you do get minibuffer
messages indicating that interpreting is on/off) and trying to set a
breakpoint results in the "Module is not interpreted, can't set
breakpoints." error message).

So, perhaps the underlying issue relates to how (or whether) the
module has been loaded into the node before interpreting is turned on
for the first time. In my example above, I haven't loaded the module
at all and this effectively stuffs up debugging even if I subsequently
load the module and turn on interactivity again. That's one particular
failure scenario (hopefully, you should be able to replicate the above
as well). However, your comments about the bug in erl-reload-module
above point to another possible scenario (and maybe a clue as to why
my patch for clearing the node name was working for me) since I would
sometimes use "C-c C-d L" to reload the module in the node and
sometimes just compile or load it directly.

>>> So the only way for your patch to have any effect is if
>>> edb-monitor-live-p incorrectly returns t instead of nil at some point.
>>
>> In fact, my patch does have an effect for me in that I can now restart
>> debugging in distel when I reconnect to a node.
>
> I am not disputing that. But I do not understand *why*.

I thought that I had traced the problem to edb-start-monitor and the
monitor not receiving the correct interpreted status
messages. However, it may be that there is some sequence of
reload/start-interpreting actions that result in the edb monitor being
out-of-whack with reality.
 
>> Unfortunately, for some reason, you are not able to replicate the
>> problem that I was experiencing.
>
> I wonder whether the problem is related to running the node from inside 
> emacs. Do you see the same behaviour when debugging nodes that have been 
> started separately?

When I first encountered this problem, I was testing in the erlang
node inside of emacs. However, following your comments about the emacs
erlang shell, in my subsequent testing, I was starting the erlang node
from a terminal outside of emacs. So this does not appear to be an
issue that is related to the emacs erlang shell.

Could you please try the test scenario that I described above to see
whether it fails for you as well. If so, at least we will have a
common initial scenario that we can both work forward from.

Cheers,
Bill


-------------------------------------------------------------------------
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/