overturetool / overture

The Overture Tool
http://overturetool.org
GNU General Public License v3.0
48 stars 25 forks source link

Issue with debugging dcl statements #637

Open peterwvj opened 7 years ago

peterwvj commented 7 years ago

Overture will allow you to set a breakpoint on a dcl statement, like dcl x : nat := 123. But in the command line, you're not allowed to do that - it says that there are no breakable expressions or statements on that line (although in principle there are).

But the real problem is that if you debug a spec with a BP set on a dcl statement, you get errors or warnings in the log. You always get a warning, but you also sometimes get a fatal error.

This issue can be demonstrated using the following model:

operations
op: () ==> <CRITERIA>
op() ==
(
dcl x : <CRITERIA> := <CRITERIA>; <--- breakpoint here
return x
);

The stack traces you get look like:

Warning ErrorSetupDeferredBreakpoints:

org.overture.ide.debug.core.dbgp.exceptions.DbgpOpertionCanceledException: java.lang.InterruptedException: responsePacketWaiterTerminated
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpDebuggingEngineCommunicator.communicate(DbgpDebuggingEngineCommunicator.java:126)
at org.overture.ide.debug.core.dbgp.DbgpBaseCommands.communicate(DbgpBaseCommands.java:61)
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpBreakpointCommands.setBreakpoint(DbgpBreakpointCommands.java:132)
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpBreakpointCommands.setLineBreakpoint(DbgpBreakpointCommands.java:143)
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpCoreCommands.setLineBreakpoint(DbgpCoreCommands.java:138)
at org.overture.ide.debug.core.model.internal.VdmBreakpointManager.addBreakpoint(VdmBreakpointManager.java:166)
at org.overture.ide.debug.core.model.internal.VdmBreakpointManager.initializeSession(VdmBreakpointManager.java:538)
at org.overture.ide.debug.core.model.internal.VdmThreadManager.acceptDbgpThread(VdmThreadManager.java:336)
at org.overture.ide.debug.core.launching.DebugSessionAcceptor.acceptDbgpThread(DebugSessionAcceptor.java:226)
at org.overture.ide.debug.core.model.internal.DbgpService.clientConnected(DbgpService.java:200)
at org.overture.ide.debug.core.dbgp.DbgpServer$DbgpSessionJob.run(DbgpServer.java:176)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.InterruptedException: responsePacketWaiterTerminated
at org.overture.ide.debug.core.dbgp.internal.packets.DbgpPacketReceiver$ResponcePacketWaiter.waitPacket(DbgpPacketReceiver.java:88)
at org.overture.ide.debug.core.dbgp.internal.packets.DbgpPacketReceiver.getResponsePacket(DbgpPacketReceiver.java:211)
at org.overture.ide.debug.core.dbgp.internal.DbgpDebugingEngine.getResponsePacket(DbgpDebugingEngine.java:126)
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpDebuggingEngineCommunicator.receiveResponse(DbgpDebuggingEngineCommunicator.java:57)
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpDebuggingEngineCommunicator.communicate(DbgpDebuggingEngineCommunicator.java:87)
... 11 more

Or Error internalErrorLoggedFromVdmDebugPluginjava.net.SocketException: Connection reset by peer: socket write error

org.overture.ide.debug.core.dbgp.exceptions.DbgpIOException: java.net.SocketException: Connection reset by peer: socket write error
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpDebuggingEngineCommunicator.communicate(DbgpDebuggingEngineCommunicator.java:129)
at org.overture.ide.debug.core.dbgp.DbgpBaseCommands.communicate(DbgpBaseCommands.java:61)
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpContinuationCommands.execCommand(DbgpContinuationCommands.java:48)
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpContinuationCommands.run(DbgpContinuationCommands.java:58)
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpCoreCommands.run(DbgpCoreCommands.java:166)
at org.overture.ide.debug.core.model.internal.operations.DbgpResumeOperation.process(DbgpResumeOperation.java:38)
at org.overture.ide.debug.core.model.internal.operations.DbgpOperation$1.run(DbgpOperation.java:86)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
at java.io.BufferedOutputStream.flush(Unknown Source)
at org.overture.ide.debug.core.dbgp.internal.packets.DbgpPacketSender.sendCommand(DbgpPacketSender.java:63)
at org.overture.ide.debug.core.dbgp.internal.DbgpDebugingEngine.sendCommand(DbgpDebugingEngine.java:131)
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpDebuggingEngineCommunicator.sendRequest(DbgpDebuggingEngineCommunicator.java:51)
at org.overture.ide.debug.core.dbgp.internal.commands.DbgpDebuggingEngineCommunicator.communicate(DbgpDebuggingEngineCommunicator.java:86)
... 7 more

If you get the error, the Console displays:

Initialization: java.lang.NullPointerException
java.lang.NullPointerException
at org.overture.interpreter.debug.DBGPReader.quote(DBGPReader.java:834)
at org.overture.interpreter.debug.DBGPReader.errorResponse(DBGPReader.java:708)
at org.overture.interpreter.debug.DBGPReaderV2.process(DBGPReaderV2.java:720)
at org.overture.interpreter.debug.DBGPReader.run(DBGPReader.java:844)
at org.overture.interpreter.debug.DBGPReader.connect(DBGPReader.java:553)
at org.overture.interpreter.debug.DBGPReader.startup(DBGPReader.java:561)
at org.overture.interpreter.debug.DBGPReaderV2.main(DBGPReaderV2.java:533)
nickbattle commented 7 years ago

The expression and/or statement finders need to be enhanced to "find" the expression body of the assignment definition (the dcl). Just fixing that may be enough to solve this issue.

I did attempt to fix this, but there is something complicated going on between definition, statement and expression based finder visitors and I couldn't easily see how to fix it. This example is awkward, because we have a statement block that contains a definition that contains an expression.