erlide_eclipse icon indicating copy to clipboard operation
erlide_eclipse copied to clipboard

Running erlang code only startup a console

Open sylane opened this issue 12 years ago • 6 comments

System: Ubuntu 12.10 64 bits, Eclipse 3.8 with erlide release and Erlang R16B.

When running, debugging or getting the coverage of an erlang module, erlide only startup a console. If the function is run form the started console it works fine but the function is not called automatically.

The erlang application is correctly configured with module, function and arguments, and when eclipse is requested to run it no exception are shown in the console:

19:13:34,294 F: (ErlangLaunchDelegate.java:90) : doLaunch runtime r16b
19:13:34,294 F: (ErlangLaunchDelegate.java:91) : doLaunch cookie erlide (erlide)
19:13:34,295 I: (RuntimeData.java:307) : Data:: org.erlide.backend.BackendData
19:13:34,295 I: (RuntimeData.java:316) : beamLocator         : org.erlide.model.BeamLocator@6b31d5c8
19:13:34,295 I: (RuntimeData.java:316) : launch              : org.eclipse.debug.core.Launch@3d914329
19:13:34,296 I: (RuntimeData.java:316) : projects            : [P/test]
19:13:34,296 I: (RuntimeData.java:316) : cookie              : erlide
19:13:34,296 I: (RuntimeData.java:316) : managed             : true
19:13:34,296 I: (RuntimeData.java:316) : restartable         : false
19:13:34,297 I: (RuntimeData.java:316) : startShell          : true
19:13:34,297 I: (RuntimeData.java:316) : console             : true
19:13:34,297 I: (RuntimeData.java:316) : interpretedModules  : [test:dummy.erl]
19:13:34,297 I: (RuntimeData.java:316) : nodeName            : dummy
19:13:34,298 I: (RuntimeData.java:316) : longName            : true
19:13:34,298 I: (RuntimeData.java:316) : extraArgs           : 
9:13:34,298 I: (RuntimeData.java:316) : workingDir          : .
19:13:34,298 I: (RuntimeData.java:316) : env                 : {}
19:13:34,299 I: (RuntimeData.java:316) : initialCall         : dummy:paftoto
19:13:34,299 I: (RuntimeData.java:316) : debugFlags          : [DISTRIBUTED_DEBUG, ATTACH_ON_BREAKPOINT]
19:13:34,299 I: (RuntimeData.java:316) : loadOnAllNodes      : true
19:13:34,300 I: (RuntimeData.java:316) : internal            : false
19:13:34,303 I: (RuntimeData.java:316) : runtimeInfo         : Runtime
19:13:34,303 I: (RuntimeData.java:316) : debug               : false
19:13:34,303 I: (RuntimeData.java:316) : reportErrors        : false
19:13:34,303 I: (RuntimeData.java:326) : ---------------
19:13:34,304 F: (ErlangLaunchDelegate.java:164) : START node :> [/usr/local/otp/r16b/bin/erl, -name, [email protected], -setcookie, erlide] *** /opt
19:13:34,305 F: (ErlangLaunchDelegate.java:183) : process is running
19:13:34,306 F: (ErlangLaunchDelegate.java:143) : Started erts: dummy >> dummy
19:13:34,306 F: (BackendManager.java:134) : create execution backend dummy
19:13:34,307 F: (BackendFactory.java:81) : Create backend dummy
19:13:34,308 F: (ErlRuntime.java:383) : using cookie 'erlide...'6 (info: 'erlide')
19:13:34,308 F: (ErlRuntime.java:468) : [email protected]: waiting connection to peer...
19:13:34,409 F: (ErlRuntime.java:164) : # [email protected] Worker-2
19:13:34,417 F: (ErlRuntime.java:103) : Node [email protected] is up
19:13:34,417 F: (ErlRuntime.java:164) : # [email protected] Worker-2
19:13:34,439 S: (ErlRuntime.java:551) : code server did not start in time for [email protected]
19:13:34,439 S: (ErlRuntime.java:476) : Could not connect to backend! Please check runtime settings.
19:13:34,456 F: (CodeManager.java:223) : adding /opt/eclipse/plugins/org.erlide.kernel.debugger_0.20.1.201304230851/ebin to code path for @658853650:: Runtime
19:13:34,475 F: (CodeManager.java:223) : adding /opt/eclipse/plugins/org.erlide.test_support_0.20.2.201304230851/ebin to code path for @658853650:: Runtime
19:13:34,490 F: (CodeManager.java:223) : adding /opt/eclipse/plugins/org.erlide.tracing.ttbe_0.1.6.201304230851/ebin to code path for @658853650:: Runtime
19:13:34,498 F: (CodeManager.java:223) : adding /opt/eclipse/plugins/org.erlide.tracing.erlang_0.2.8.201304230851/ebin to code path for @658853650:: Runtime
19:13:34,507 F: (CodeManager.java:223) : adding /opt/eclipse/plugins/org.erlide.kernel.ide_0.20.2.201304230851/ebin to code path for @658853650:: Runtime
19:13:34,520 F: (CodeManager.java:223) : adding /opt/eclipse/plugins/org.erlide.kernel.common_0.20.1.201304230851/ebin to code path for @658853650:: Runtime
19:13:34,526 F: (CodeManager.java:223) : adding /opt/eclipse/plugins/org.erlide.cover.erlang_0.2.4.201304230851/ebin to code path for @658853650:: Runtime
19:13:34,536 F: (CodeManager.java:223) : adding /opt/eclipse/plugins/org.erlide.wrangler.core_0.9.9.201304230851/wrangler/ebin to code path for @658853650:: Runtime
19:13:34,542 F: (CodeManager.java:223) : adding /opt/eclipse/plugins/org.erlide.wrangler.core_0.9.9.201304230851/wrangler/app to code path for @658853650:: Runtime
19:13:34,547 F: (CodeManager.java:223) : adding /opt/eclipse/plugins/org.erlide.kernel.builder_0.20.1.201304230851/ebin to code path for @658853650:: Runtime
19:13:34,548 F: (Backend.java:180) : initialize [email protected]: true
19:13:34,560 F: (Backend.java:281) : backend [email protected]: add path /home/sylane/workspace/test/ebin
19:13:34,566 F: (Backend.java:407) : calling startup function dummy:paf
19:13:34,567 F: (ErlConsoleManager.java:42) : console ADDED to org.erlide.backend.BackendData@1ac7c44d

The same happens when configuring only the module and function without arguments.

sylane avatar May 19 '13 17:05 sylane

The only weird things I see is: code server did not start in time for [email protected]

sylane avatar May 19 '13 17:05 sylane

How do you test that your function is called at startup? io:format is not a reliable way to do that.

vladdu avatar May 19 '13 17:05 vladdu

ok, you are right on this, thank you. If I write to a file I can see that my code is called. What made me think it wasn't working in the first place was that breakpoint were not working. But it seems breakpoint are working every second times I debug the module. It works one time out of two and the console are accumulating themselves.

I am playing with eunit/coverage/tracing and until now I wasn't able to make anything works. I tough these problems were all related to the same issue, but it seems it is not the case.

If the console output is not reliable how am I supposed to see the output of eunit tests ?

sylane avatar May 19 '13 18:05 sylane

I tried debugging with an external module with the command:

erl -pa /opt/eclipse/plugins/org.erlide.tracing.ttbe_0.1.6.201304230851/ebin -n-pa /opt/eclipse/plugs/org.erlide.kernel.debugger_0.20.1.201304230851/ebin -name dummy -setcookie dummy

The first time I debug the module everything works fine.

But the second time the external node shows the error:

=ERROR REPORT==== 19-May-2013::20:27:42 ===
Error in process  on node '[email protected]' with exit value: {badarg,[{erlang,register,[erlide_builder,],[]},{erlide_batch,start,2,[]},{erlide_kernel_common,startup,4,[]}]}

Then the next time it works and son on and so on.

sylane avatar May 19 '13 18:05 sylane

I will comment a little more tomorrow, but when you use a startup function, you need to start a new node every time in order to run it.

The debug workflow is: start node, [] enter your "foo:bar().", check result or have the breakpoint trigger, correct code in editor, save (which compiles and reloads the code) and go to [] .

Don't start the node every time. If you have to do it, make sure you stop the previous instance.

vladdu avatar May 19 '13 18:05 vladdu

For an external module, you may want to restart the node from scratch, then like I said: stop the previous console. This will stop the debugger and it will not crash next time you start.

It's not obvious what one should do, so I created https://erlide-tools.assembla.com/spaces/erlide/tickets/1216 to track the issue.

Thanks!

vladdu avatar May 20 '13 08:05 vladdu