vscOctaveDebugger
vscOctaveDebugger copied to clipboard
Pressing return does not advance from pause
I'm sorry if I just don't understand how this should work, but I cannot seem to get pause
to work with the debugger.
I'm using the following test code: test.m
fprintf('hello\n');
pause;
fprintf('world\n');
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "OctaveDebugger",
"request": "launch",
"name": "test.m",
"program": "test.m",
"octave": "octave-cli",
"sourceFolder": "${workspaceFolder}",
"autoTerminate": true
}
]
}
When I press F5, I only get "hello" in the Debug Console. Pressing enter only displays an arrow, and does not advance to "world". I have no breakpoints set in the code. I have also tried to type dbstep in the Debug Console and pressing enter, twice, with no luck. Pausing only displays "Pausing..." in the Debug Console, and then the session seems to die.
This is the output after pressing return three times
Strange, it works fine on my side. Can you add ,"verbose": true
to your launch cfg and post the log here?
From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"OctaveDebugger","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb","supportsProgressReporting":true})
To client: {"seq":0,"type":"event","event":"initialized"}
To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsConfigurationDoneRequest":true,"supportsEvaluateForHovers":true,"supportsConditionalBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsSetVariable":true,"supportsStepBack":false,"supportTerminateDebuggee":true}}
From client: setExceptionBreakpoints({"filters":[]})
To client: {"seq":0,"type":"response","request_seq":2,"command":"setExceptionBreakpoints","success":true}
From client: launch({"type":"OctaveDebugger","request":"launch","name":"Run pauseDebug","program":"pauseDebug.m","octave":"octave-cli","sourceFolder":"C:\\Users\\akkv\\Octave\\PauseDebug","autoTerminate":true,"verbose":true,"__sessionId":"a7d781ef-be2e-489d-96c5-15c6f0063cf3"})
Runtime: connecting to 'octave-cli'.
octave-cli:0> addpath('C:\Users\akkv\Octave\PauseDebug')
To client: {"seq":0,"type":"response","request_seq":3,"command":"launch","success":true}
From client: configurationDone(undefined)
To client: {"seq":0,"type":"response","request_seq":4,"command":"configurationDone","success":true}
octave-cli:1> addpath('.')
octave-cli:2> cd 'C:\Users\akkv\Octave\PauseDebug'
octave-cli:3> pauseDebug; printf("\nvsc-octave-debugger::end\n");
From client: threads(undefined)
To client: {"seq":0,"type":"response","request_seq":5,"command":"threads","success":true,"body":{"threads":[{"id":1,"name":"thread 1"}]}}
hello
From client: evaluate({"expression":"","context":"repl"})
octave-cli:4>
To client: {"seq":0,"type":"response","request_seq":6,"command":"evaluate","success":true,"body":{"result":"","variablesReference":0}}
From client: evaluate({"expression":"","context":"repl"})
octave-cli:5>
To client: {"seq":0,"type":"response","request_seq":7,"command":"evaluate","success":true,"body":{"result":"","variablesReference":0}}
Are you using the plugin version 0.4.3? That log looks like it's missing some lines.
Could you run it with , "logFilename": "${workspaceFolder}/log"
? Maybe we can get more info that way.
My current impression is that it failed to communicate with octave-cli
even though there's no visible error on the log.
It might be that the octave-cli
on your path has issues. You can try to replace octave-cli
by the entire path c:\foo\bar\octave-cli.exe
. Make sure to test that exe beforehand. Open a command line, run it, and run a command of any sort.
Path to cli is "C:/Octave/Octave-5.2.0/mingw64/bin/octave-cli.exe". Could it perhaps be wrong version? I tried running the program in the cli, and it worked fine. The extension version is 0.4.3, and I'm running VS Code 1.47.0.
Here is the log from the logfile.
2020-7-12, 11:46:26.418 UTC
[11:46:26.419 UTC] From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"OctaveDebugger","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb","supportsProgressReporting":true})
[11:46:26.419 UTC] To client: {"seq":0,"type":"event","event":"initialized"}
[11:46:26.419 UTC] To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsConfigurationDoneRequest":true,"supportsEvaluateForHovers":true,"supportsConditionalBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsSetVariable":true,"supportsStepBack":false,"supportTerminateDebuggee":true}}
[11:46:26.419 UTC] From client: setExceptionBreakpoints({"filters":[]})
[11:46:26.419 UTC] To client: {"seq":0,"type":"response","request_seq":2,"command":"setExceptionBreakpoints","success":true}
[11:46:26.419 UTC] From client: launch({"type":"OctaveDebugger","request":"launch","name":"Run pauseDebug","program":"pauseDebug.m","octave":"C:/Octave/Octave-5.2.0/mingw64/bin/octave-cli.exe","sourceFolder":"C:\\Users\\akkv\\Octave\\PauseDebug","autoTerminate":true,"verbose":true,"logFilename":"C:\\Users\\akkv\\Octave\\PauseDebug/log","__sessionId":"180be51e-5295-4115-8708-1176344eb035"})
[11:46:26.419 UTC] Runtime: connecting to 'C:/Octave/Octave-5.2.0/mingw64/bin/octave-cli.exe'.
[11:46:26.419 UTC] C:/Octave/Octave-5.2.0/mingw64/bin/octave-cli.exe:0> addpath('C:\Users\akkv\Octave\PauseDebug')
[11:46:26.419 UTC] To client: {"seq":0,"type":"response","request_seq":3,"command":"launch","success":true}
[11:46:26.419 UTC] From client: configurationDone(undefined)
[11:46:26.419 UTC] To client: {"seq":0,"type":"response","request_seq":4,"command":"configurationDone","success":true}
[11:46:26.419 UTC] C:/Octave/Octave-5.2.0/mingw64/bin/octave-cli.exe:1> addpath('.')
[11:46:26.419 UTC] C:/Octave/Octave-5.2.0/mingw64/bin/octave-cli.exe:2> cd 'C:\Users\akkv\Octave\PauseDebug'
[11:46:26.419 UTC] C:/Octave/Octave-5.2.0/mingw64/bin/octave-cli.exe:3> pauseDebug; printf("\nvsc-octave-debugger::end\n");
[11:46:26.429 UTC] From client: threads(undefined)
[11:46:26.429 UTC] To client: {"seq":0,"type":"response","request_seq":5,"command":"threads","success":true,"body":{"threads":[{"id":1,"name":"thread 1"}]}}
[11:46:26.756 UTC] hello
[11:46:28.860 UTC] From client: evaluate({"expression":"","context":"repl"})
[11:46:28.860 UTC] C:/Octave/Octave-5.2.0/mingw64/bin/octave-cli.exe:4>
[11:46:28.860 UTC] To client: {"seq":0,"type":"response","request_seq":6,"command":"evaluate","success":true,"body":{"result":"","variablesReference":0}}
[11:46:31.154 UTC] From client: disconnect({"restart":false})
[11:46:31.155 UTC] Killing Runtime.
[11:46:31.155 UTC] C:/Octave/Octave-5.2.0/mingw64/bin/octave-cli.exe:5> quit
[11:46:31.156 UTC] To client: {"seq":0,"type":"response","request_seq":7,"command":"disconnect","success":true}
[11:46:31.184 UTC] Runtime: C:/Octave/Octave-5.2.0/mingw64/bin/octave-cli.exe exited with code: null
[11:46:31.185 UTC] To client: {"seq":0,"type":"event","event":"terminated"}
This seems to be an issue specific to the windows version of octave. It seems that even though it takes commands from stdin/out when in pause it waits for direct input events. Since the plugin only uses stdin to communicate octave will remain locked in that state.
One way of reproducing this issue is to do the following in a bash shell on windows echo -e “test\n\n“ | octave-cli
from the directory containing test.m
.
I’ll have to figure out if there’s a workaround on windows to that. In the meanwhile I would say just don’t use pause while debugging on windows. Or maybe use a timeout pause(5)
I've found that Octave-5.2.0 had a patch applied that broke this functionality (or fixed it depending on the point of view). See bug here: https://savannah.gnu.org/bugs/?55029
You can install install the previous version that should work properly with the plugin: https://ftpmirror.gnu.org/octave/windows/octave-5.1.0-w64-64.7z
In the meanwhile I'll try to figure out a workaround.
Thanks for the effort you put into this.
@paulo-fernando-silva I tried v5.1.0 however now I'm getting the opposite effect. That is, when the pause command is found in an Octave program, it doesn't pause and instead just continues on as if it wasn't there...
I'm taking the Coursera ML course, here's what my launch.json looks like:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "OctaveDebugger",
"request": "launch",
"name": "Launch Program",
"program": "${fileBasenameNoExtension}",
"octave": "/bin/Octave-5.1.0.0/mingw64/bin/octave-cli.exe",
"sourceFolder": "${workspaceFolder}",
"workingDirectory": "/src/coursera/machinelearning/machine-learning-ex1/ex1",
"autoTerminate": true,
}
]
}
are you stepping over a pause? That's a known issue. Don't believe it can be avoided. On the plugin page I have a reference to it quote: stdinput: Currently if you're stepping you can't rely on stdinput from your Matlab/Octave code. For example, you can use functions like pause(), input(), keyboard(), etc, as long as it's not during a step over, step into, or step out. To work around this you can press F5 (continue), and pause() will wait for your input in the DEBUG CONSOLE. The issue comes from the communication that the plugin does with Octave in order to control execution. When using the console or continuing the execution no such communication exists. So you can step over/into/out using the DEBUG CONSOLE, by typing dbstep and pressing the RETURN key (see here for details). Then each new RETURN should work as a step directly. This is the way octave-cli works by default. Since the DEBUG CONSOLE just forwards your commands to octave-cli you can interact with it as if it was a normal terminal.
Does that help?