paulo-fernando-silva / vscoctavedebugger Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi,
first, thanks for a great plugin - not having to switch between Octave GUI and VSCode is quite handy.
After some tinkering I've landed with the following launch configuration, which allows me to simply press F5 to launch the currently open file, even if it's using functions from other files in the same directory - similarly to how it works in the Octave GUI.
Additionally I've managed[1] to get the QT plots to mostly[2] work under Windows.
"launch": {
"version": "0.2.0",
"configurations": [{
"type": "OctaveDebugger",
"request": "launch",
"name": "Octave Debugger",
"program": "${fileBasename}",
"octave": "\"C:/Program Files/GNU Octave/Octave-6.3.0/mingw64/bin/octave-gui\"",
"sourceFolder": "${workspaceFolder}",
"workingDirectory": "${fileDirname}",
"autoTerminate": true
}]
}
Would you consider updating the default values for program
and workingDirectory
of the automatically-populated launch configuration?
Additionally I think including this octave
path example in the Readme would help other Windows users (the escaped inner quotes are crucial!).
I've seen the #51 but as it passes the whole filename along with the path to the program
, I think it won't work if the program uses functions from neighboring files.
[1] After spending way too much time debugging and tinkering with environment variables - apparently simply calling octave-gui
instead of octave-cli
allows using QT without setting anything else (no env variables, no paths etc).
[2] With autoTerminate: true
the plot windows close as soon as the program ends, with false
they stay on but closing them doesn't work (only stopping the debug); also their contents is not updating (e.g. resising the window doesn't resize the graph) - I believe this is #24?
That messes up the debug session, e.g. adds additional calls to the stack, and potentially has other side effects.
Some users seem to report that they were able to run it on windows I believe, but I tried today and it crashed.
Currently, octave doesn't support setting breakpoints in classdefs using line numbers.
Bug here https://savannah.gnu.org/bugs/?46451
Hello,
Note that I needed to reload my VSCode to work.
Maybe it can be great to put it in the README.md
Currently stuff like char ("an apple", "two pears")
isn't handled properly. These are visualized as a row vector, i.e. same as strcat ("an apple", "two pears")
.
I believe this wasn't showing before, but it's quite annoying.
This is probably the most important remaining issue. For some reason octave doesn't print the termination tag or any other output if I step on the last program line. Therefore I can't know the program actually ended.
Extension Info:
Name: Octave Debugger
Id: paulosilva.vsc-octave-debugger
Description: Debug Octave and Matlab code in Visual Studio Code.
Version: 0.4.7
Publisher: Paulo Silva
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=paulosilva.vsc-octave-debugger
Octave Info:
I have installed GNU Octave in E:\Octave-6.1.0
directory. octave-cli resides in E:\Octave-6.1.0\mingw64\bin
.
I wrote a simple Hello World Script and named it "myscript.m" inside my folder: D:\Harsh\Study\Sem4\ITW-2
.
Issue:
Every time I run the script using the debugger, it gives a warning and an error in Debug Console, that is as follows:
warning: addpath: D:HarshStudySem4ITW-2: No such file or directory
error: D:HarshStudySem4ITW-2: No such file or directory
Runtime: octave-cli exited with code: 1
Configuration:
My launch.json is configured as:
{
// 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": "Run Octave",
"program": "${fileBasename}",
"octave": "octave-cli",
"sourceFolder": "${workspaceFolder}",
"autoTerminate": true
}
]
}
Clearly, backslashes from path are removed; D:\Harsh\Study\Sem4\ITW-2
becomes D:HarshStudySem4ITW-2
.
I need help regarding this. I am still very very new to octave. Please assist.
It seems the properties access modifiers, private, protected, public, are also applied in debugging mode. This prevents the debugger from inspecting the value of those properties depending on scope.
I installed Octave 6.3.0 on my laptop which is running Windows 10. When I tried to debug my .m file, the sentence shown on the debug console.
What must I do to make octave-cli or octave-gui to be recognized as an internal or external command? Or what is the problem that I am facing? How to fix the problem?
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.
Hi,
first of all, thanks for providing this extension. :)
I like to use the qt toolkit for ploting an advanced figure with buttons and sliders. It's possible to start the octave-cli with qt, when using "octave-gui --no-gui" as cmd command.
https://octave.org/doc/v4.4.0/Command-Line-Options.html
Therefor I've tried the same with your tool:
"octave": "C:/Octave/Octave-5.1.0.0/mingw64/bin/octave-gui --no-gui"
Error Message:
Could not connect to 'C:/Octave/Octave-5.1.0.0/mingw64/bin/octave-gui --no-gui'! Check path.
only using "octave-gui"
"octave": "C:/Octave/Octave-5.1.0.0/mingw64/bin/octave-gui"
Error Message:
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
I've also tried to modify the Runtime.js to add this command parameter:
code snipped from Runtime.js:
start(program, workingDirectory) {
this._program = program;
this.addFolder(path_1.dirname(program));
this.cwd(workingDirectory);
// This is just like a deferred sync command.
// The program executes and then echoes the terminator tag.
const terminator = this.echo(Runtime.TERMINATOR);
this.execute(${fsutils_1.functionFromPath(program+" --no-gui")};${terminator}
);
Error Message:
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Is there an option to add command parameters? Or are there other methods to solve this issue?
Greetings
If a try show a plot i cant, because i cant use pause or input and if a does the plot crashes
I can't set breakpoints in VSCode 1.28.2 and macOS Mojave 10.14.1.
@PeterEnis1234 writes in original issue
Same problem on Windows
so it looks like it's not OS specific.
simple gif
to demonstrate it on a project with 2 files:
/c++
/c++/hallo.c
/octave
/octave/hallo.m
Readme suggests
h = figure();
plot();
% ...
waitfor(h);
or while(waitforbuttonpress()==0) pause(1) end
this
Is there any way the extension can make plots not close without adding any additional codes in the file?
Thank you for sharing this extension.
It seems that when I use matlab functions which do not exist in octave (e.g. a function from a matlab toolbox), the debugger issues an error.
Is my assumption correct, that the extension can only be used for functions which exist in octave?
E.g. in a file with a single line octave will happily step once and stop at "line 2".
This is not for the plugin but more for the repository management.
The problem is while this extension uses the 'octave' language, Octave formatter uses 'Octave'. That made both extensions could only be used exclusively.
https://marketplace.visualstudio.com/items?itemName=tusindfryd.octave-formatter
Only saw this once or twice. Might not be an issue currently.
Hi
I am running the debugger on a mac with high sierra.
I installed octave 4.4.1 via the app dmg installer from the web site.
In my app folder, I have
Octave-4.4.1.app
Octave-cli.app
Octave-gui.app
When I run debug, I get the above error.
Any thoughts on where I went wrong?
Hello,
~/Projects/HOME/Learn ML AndrewNg/machine-learning-ex1/ex1
${workspaceFolder}
is ~/Projects/HOME/Learn ML AndrewNg
ex1.m
file"configurations": [
{
"type": "OctaveDebugger",
"request": "launch",
"name": "Function or file to execute.",
"program": "${file}",
"octave": "octave-cli",
"sourceFolder": "${workspaceFolder}",
"autoTerminate": true
}
]
If I follow the same steps WITHOUT setting a breakpoint, the ex1 file runs fine
Hello! I have the following launch.json:
{
// 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": "Octave",
"program": "main.m",
"octave": "octave-cli",
"sourceFolder": "${workspaceFolder}",
"autoTerminate": true
}
]
}
and the this Octave script:
clear all
function z = l(xx, i, x)
n = size(x);
pr = 1;
for j = [1:1:(i - 1) (i + 1):1:n(1)]
pr = pr * (xx - x(j)) / (x(i) - x(j));
end
z = pr;
end
function z = L(xx, x, y)
n = size(x);
sum = 0;
for i = 1:1:n(1)
sum = sum + l(xx, i, x) * y(i);
end
z = sum;
end
n = 4;
x = [1 3 5 7]';
y = [2 2 4 4]';
L(2, x, y)
L(4, x, y)
L(6, x, y)
disp("Hello world!")
When I click Run > Start Debugging
program runs instead of fall in debug mode. What am I missing?
Octave version: 6.2.0/6.1.0
VS Code version: 1.53.2
Not sure if this is a bug or if it's working as expected. But it seems that stack calls always come in pairs and they ask for the same thing.
Currently the entire contents of a variable are requested. This might be a CPU intensive operation for very large matrices for example. Ideally we should only get the number of variables asked by vscode.
Also need to decide when to resolve the contents of the children. At request time, only for leaf children, or maybe at the 2D level for a ND matrix. That changes how soon we can preview the matrix contents on hover.
Ok I know the pause command causes issues with the debugger, but the readme states that the debugger will just skip over pause statements.
This doesn't seem to be happening to me with v0.3.14. The debugger get's stuck at the pause statement and doesn't even produce any output (even though there is a printf()
right before the first pause).
For context, I'm trying to debug ex1.m
from Andrew Ng's ML class.
I was looking for Octave debugger and came across this pluging. However, I can't make it work on macOS with VSCode 1.28.2. Issues so far:
.m
file{
// 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": "Octave",
"program": "${workspaceFolder}/test",
// "program": "${workspaceFolder}/${command:AskForProgramName}",
"stopOnEntry": true,
"octave": "/full/path/to/bin/octave-cli",
"sourceFolder": "${workspaceFolder}"
}
]
}
but trying to run debugger does not give anything. I don't see anything in logs either.
Using a front slash in a function argument in "program" in the Debug Session Configuration leads to an internal syntax error:
For example:
...
"program": "test_function(\"test/test\")",
...
Just a general performance optimization. Right now each variable is fetched individually. That makes parsing simpler and less error prone, but it does make things orders or magnitude slower than fetching everything in as few inter-process messages as possible.
Hi. I wish to watch my variables after executing my code just like MATLAB or Octave GUI.
I've set autoTerminate
to false
but it seems not working. My launch.json is as follows
"configurations": [
{
"type": "OctaveDebugger",
"request": "launch",
"name": "Octave Debugger",
"program": "${file}",
"octave": "octave-cli",
"autoTerminate": false
}
]
My simple test code is
a = 1:5;
b = a;
and if I set a breakpoint at the second line , I can see the local variable
But if I clear the breakpoints and run again, there is no variables any more.
Here's the log file. log20210802_161801.txt
Thank you.
When the function or script fails to run due to a compile error, the debug session can't execute. Right now the session exits with no feedback.
Workspace paths with quotes, which are valid file paths, fail with error:
parse error:
syntax error
>>> addpath('/path/with/quote/doesn't/work')
Runtime: octave-cli exited with code: 1
Note that I can use octave just fine running the octave
command inside the directory in question.
Hi Paulo,
I see that in your README you're recommending other Octave VS Code extensions for syntax highlighting and the like. Would you consider checking out my Octave Hacking extension and maybe including that in the list of recommendations?
Octave Hacking improves on the other Octave language support extensions in the VS Code Marketplace by:
Cheers, and thank you for writing this extension!
Andrew Janke
In multiroot workspaces, e.g. a c++ project together with a matlab project, if the user tries to run a debug session for the matlab project, vscode sends all set breakpoints including those set in the c++ project to the debugger extension being launched.
Seems like simply ignoring the non-matlab files or even sending back a breakpoint with unverified or verified flag still leaves vscode waiting for something, and configurationDoneRequest never gets called. Manually removing all breakpoints from the c++ project seems to work though.
Seems it wouldn't be too hard to also support matlab.
The regex change, I just don't know how much yet.
While trying out the extension for a class, I was happy to see this extension providing debugging support for Octave. I tried the example provided in the readme.md and was able to stop on the first breakpoint and continue using dbcont. However, I am unable to
Are these features from another extension? If not, how may I enable them?
Thank you for your hard work making this extension, it has already been very useful!
MacOS Catalina
Extensions: Octave Hacking, Octave (Toasty Technologies), and Octave Debugger
octave-cli does exist at the location specified in launch.json.
Sample.m
function output = Sample(input)
x = [-10:0.1:10];
y = rand(size(x));
output = [x' y'];
end
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "OctaveDebugger",
"request": "launch",
"name": "Sample",
"program": "Sample",
"octave": "/usr/local/bin/octave-cli",
"sourceFolder": "${workspaceFolder}",
},
]
}
All of the images are from the same time. (no interaction in between the pictures)
When starting the code, no plot is displayed:
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
mesh(X,Y,Z)
Works only if i add an pause
to the end.
VS Code version: 1.28.2
Hi,
until e37c0ee I could pass environment variables by prepending the "octave" setting with e.g. export DISPLAY=:22; octave
.
With shell
not set to true
this doesn't work anymore.
Is there any other way to pass environment variables to octave? I couldn't find a working solution.
When running the debugger, I receive a warning produced by the addpath that sets up the required path directories:
warning: addpath: c:\Users\...\Code\Homework:C:\Users\...\Code\MATLAB Scripts: No such file or directory
(note that ... has replaced long intermediate filepaths with identifying information)
The issue here is that the two paths are being separated by the :
character rather than the pathsep()
value. My octave installation returns ;
when running pathsep()
, which I suspect to be due to me running on a Windows OS. If I manually run addpath with the same string, but with the ;
between the two paths, it works as it should, though I would prefer to not explicitly run addpath at the start of all my scripts.
I took at look at the source, but I don't know Typescript or VSC extensions at all, and couldn't see where this character was being added. The comment on this line however claims to separate explicitly with the :
, so I will believe that.
vscOctaveDebugger/src/Commands.ts
Line 26 in 70a03e0
If there is a configuration fix that I have overlooked that would address this problem, please let me know.
Some larger Octave projects have their code split out into multiple directories. At least having one main source directory and a separate examples/test/scratch directory doesn't seem uncommon. Would you consider adding support for passing an array of multiple directories to the sourceFolder
option in the debug configuration?
Octave version: 6.2.0/6.1.0
VS Code version: 1.53.2
Logs: log20210213_173042.txt
PATH variable: /cygdrive/c/Program Files/GNU Octave/Octave-6.2.0/mingw64/bin:/home/Alvin/.local/bin:/cygdrive/c/Program Files/Mono/bin:/usr/local/bin:/usr/bin:/usr/bin/python:/cygdrive/c/tools/ruby30/bin:/cygdrive/c/Python39/Scripts:/cygdrive/c/Python39:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static:/cygdrive/c/ProgramData/chocolatey/bin:/cygdrive/c/Program Files/Microsoft VS Code/bin:/cygdrive/c/Program Files (x86)/GtkSharp/2.12/bin:/cygdrive/c/Program Files/dotnet:/cygdrive/c/Program Files/nodejs:/cygdrive/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/cygdrive/c/Program Files/PowerShell/7:/cygdrive/c/ProgramData/chocolatey/lib/dotnet.script/dotnet.script:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/Program Files/Mono/bin:/usr/local/bin:/usr/bin:/usr/bin/python:/cygdrive/c/tools/ruby30/bin:/cygdrive/c/Python39/Scripts:/cygdrive/c/Python39:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static:/cygdrive/c/ProgramData/chocolatey/bin:/cygdrive/c/Program Files/Microsoft VS Code/bin:/cygdrive/c/Program Files (x86)/GtkSharp/2.12/bin:/cygdrive/c/Program Files/dotnet:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/Program Files/nodejs:/cygdrive/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/cygdrive/c/Program Files/PowerShell/7:/usr/bin/python:/cygdrive/c/tools/ruby30/bin:/cygdrive/c/Python39/Scripts:/cygdrive/c/Python39:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static:/cygdrive/c/ProgramData/chocolatey/bin:/cygdrive/c/Program Files/Microsoft VS Code/bin:/cygdrive/c/Program Files (x86)/GtkSharp/2.12/bin:/cygdrive/c/Program Files/dotnet:/cygdrive/c/Program File:/cygdrive/c/Users/Alvin/.dotnet/tools
launch.json:
{
// 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": "Octave",
"program": "main.m",
"octave": "octave-cli",
"sourceFolder": "${workspaceFolder}",
"autoTerminate": true,
"logFilename": "${workspaceFolder}/log",
"verbose": true
}
]
}
program:
clear all
function z = l(xx, i, x)
n = size(x);
pr = 1;
for j = [1:1:(i - 1) (i + 1):1:n(1)]
pr = pr * (xx - x(j)) / (x(i) - x(j));
endfor
z = pr;
endfunction
function z = L(xx, x, y)
n = size(x);
sum = 0;
for i = 1:1:n(1)
sum = sum + l(xx, i, x) * y(i);
endfor
z = sum;
endfunction
n = 4;
x = [1 3 5 7]';
y = [2 2 4 4]';
L(2, x, y)
L(4, x, y)
L(6, x, y)
disp("Hello world!")
But I can run octave-cli
from any place via terminal directly without any problems. So I don't understand why it happens.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.