Code Monkey home page Code Monkey logo

vscoctavedebugger's Introduction

VS Code Octave Debugger

This extension provides debugging support for Octave code. This is done by interfacing with octave-cli via stdin/stdout. Support for running Matlab code is also done through octave-cli. Make sure octave-cli is in your path environment variable. Note that octave-cli must be installed on your system. You can download it here. If you're using windows or scripts with UI elements such as plots and widgets, using octave-gui is recommended. For more details on plots check this page. You can use

    h = figure();
    plot();
    % ...
    waitfor(h);

to prevent the script from exiting, allowing continuous debugging of plots. Another option is to put while(waitforbuttonpress()==0) pause(1) end at the end of your script. See here for more details.

Do read the changelog to know what's new in this version. This extension has been tested with octave-5.1 and octave-6.1, so everything in between and perhaps more recent versions should also work. If it doesn't, or if a variable is not shown properly, etc, please do let me know over here. Additionally, please check the known issues on this page.

Though the following is not necessary to use this extension, I recommend the Octave extension for syntax highlighting. I prefer it over Matlab. Nicer colors. The following language extension supports code outline for the focused file Octave Hacking. We're still missing is the F12 "jump to definition" code navigation. If someone has time and wants to implement it here's a place to start.

Octave Debugger This extension supports actions:

  • continue, step, step in, step out,
  • breakpoints, conditional breakpoints,
  • variable inspection, variable editing
  • stack navigation and visualization
  • expression evaluation, via console input, watch UI, or mouse hover

The following types are currently supported:

If a type isn't supported, request it on the project repository.

Demo

If you want to edit the value of a variable be it scalar, array, or structure, you can double click on it in the VARIABLES view, and type in the new value. That expression will be evaluated and if successful the variable will be updated with the new value. You can also submit any command you like through the debug console as if you were typing directly into Octave.

More information about debugging with Octave can be found here.

Using Octave Debugger

  • Open the directory containing the project that you want to debug using everyone's favorite editor, visual studio code.
  • In the vsCode debug view click the DEBUG drop-down box and select "Add configuration...". See animation above.
  • Select "OctaveDebugger" from the menu that pops up.
  • The following is the default configuration which will debug the current selected file:
    "type": "OctaveDebugger",
    "request": "launch",
    "name": "Execute selected file.",
    "program": "${file}"
  • Open the file you wish to debug.
  • Set breakpoints as needed.
  • Press the DEBUG ▷ button or F5 to start debugging.
  • Open the DEBUG CONSOLE to view any output from your program or to interact with it. Commands will be sent directly to Octave.

Interactive Mode

In this mode octave will continue to execute beyond the script execution. Therefore, the "program" field can be empty as follows:

    "type": "OctaveDebugger",
    "request": "launch",
    "name": "Interactive Mode",
    "program": "",
    "octave": "octave-cli",
    "autoTerminate": false

Commands can be sent via the DEBUG CONSOLE. To enter this mode set "autoTerminate": false in the launch configuration. Note that octave will terminate only when either the stop □ button is pressed, or when an error occurs after the end of the script. To continue executing even on error, use the octave option "octaveArguments": [ "--interactive" ],. The main point of this mode is that variables will continue to be displayed in the VARIABLES and WATCHES view beyond the end of the script.

Debug Session Configuration Variables

  • Example:
    "type": "OctaveDebugger",
    "request": "launch",
    "name": "My Debug Config - free text",
    "program": "${file}",
    "octave": "/path/to/octave-cli",
    "sourceFolder": "${workspaceFolder}:/usr/local/matlab/code:/opt/local/matlab/more_code",
    "workingDirectory": "${workspaceFolder}"
  • "program" can be anything that can be evaluated, e.g. "path/to/file.m", or "functionName(value)". It defaults to ${file} which corresponds to the currently focused file. This is a vscode variable - see variables-reference. However, something like "functionName('/some/path/file.m')" probably won't work, as the plugin tries to parse the program directory from this value.
  • "octave" must point to the location where "octave-cli" or "octave-gui" is installed. This parameter is optional, and defaults to "octave-cli" which assumes that "octave-cli" is in your path. If that's not the case make sure to provide the full installation path.
  • "sourceFolder" is an optional parameter that defaults to "${workspaceFolder}". Basically it is added using "addpath()" before starting the "program". More than one directory can be added by separating them with pathsep() which defaults to :.

For example:

    "program": "foo",
    "sourceFolder": "${workspaceFolder}/A/B/C/"

is equivalent to

    "program": "${workspaceFolder}/A/B/C/foo.m"
  • "workingDirectory" is another optional parameter. Octave will switch to this directory before running "program". In the following example program "foo" can exist anywhere under "${workspaceFolder}", but will be executed from "${workspaceFolder}/A/B/C/":
    "program": "foo",
    "sourceFolder": "${workspaceFolder}"
    "workingDirectory": "${workspaceFolder}/A/B/C/"
  • "splitFieldnamesOctaveStyle" this allows struct field names to be almost arbitrary (details). This option is not compatible with Matlab and so it's off by default (details).

Environment Variables and Octave Arguments

  • Consider the following configuration:
    "type": "OctaveDebugger",
    "request": "launch",
    "name": "Environment Check",
    "program": "env.m",
    "octave": "octave-cli",
    "octaveEnvironment": { "FOO": "bar", "VAR": "XPTO" },
    "workingDirectory": "${workspaceFolder}"
  • "octaveEnvironment" is added to the environment when the octave process is created. We can print those environment variables by running the program env.m defined as:
    printf('FOO: "%s"\n', getenv('FOO'));
    printf('VAR: "%s"\n', getenv('VAR'));
    printf('PATH: "%s"\n', getenv('PATH'));
  • The same can be achieved using:
    "type": "OctaveDebugger",
    "request": "launch",
    "name": "Environment Check",
    "program": "env.m",
    "octave": "export FOO=bar; octave-cli",
    "shell": true,
    "workingDirectory": "${workspaceFolder}"
  • "shell": true, is this variable's default value, so it can be omitted. If you set it to false, the above configuration will not run as export FOO=bar; octave-cli is a shell command, and is not a valid process name.

  • Another option is "octaveArguments": [ "FOO", "bar" ],. This passes "FOO" and "bar" as parameters to the octave process. For example, here's another way to manipulate paths:

    "type": "OctaveDebugger",
    "request": "launch",
    "name": "Execute foo in bar",
    "program": "foo.m",
    "octave": "octave-cli",
    "octaveArguments": [ "--path", "bar" ],
    "workingDirectory": "${workspaceFolder}"

Project Homepage

Source available here. Please submit bugs there too.

Known Issues

The following issues will likely not be fixed. For other open issues see here.

  • ans: Is not displayed in the variables view by default. You can still output it in the console or watch view.
  • stdinput when using octave version 5.1 or older: 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 workaround 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.
  • stdinput when using octave version 5.2 or newer: in this case pause(), kbhit(), and friends block octave waiting for direct keyboard input. Unfortunately the plugin can't send keypresses directly to the octave process. The plan is to implement a switch to open a background window to run octave-cli so the user can send direct keyboard input to that window. This is tracked in issue #34. For now if you're using octave 5.2 or newer you should avoid these keyboard functions.
  • plotting with qt or other plot frameworks might require you to add an infinite loop at the end of the program being debugged. For example, as mentioned at the top of this page, you can use h = figure(); plot(); waitfor(h); or while(waitforbuttonpress()==0) pause(1) end which hopefully exits when you press a key but not when you press a mouse button. Using either method will prevent the program from terminating, allowing the debug session to stay alive and the plot to update. The first method will exit when you close the plot, the second method will exit on key press. If the plot doesn't require an update, i.e. no interactive elements such as sliders, then setting a breakpoint on the last program instruction might be enough - just make sure that instruction is after the plot command. This seems to be an issue even when running plots from the cli, see Getting octave to plot when invoking a function from the command line and Octave: How to prevent plot window from closing itself?.
  • Octave will accept arbitrary strings as struct field names. When Octave field names are enabled using "splitFieldnamesOctaveStyle": true in the launch options, the only strings that can't be used as struct field names will be strings that match /\n? \[\d+,1\] = /. Using this kind of struct field names with this plugin is not recommended as it might lead to communication issues between the plugin and octave.
  • Support for setting breakpoints in classdefs is ongoing. The plugin includes support, but currently you need to build octave from source to get that functionality. This should be fixed soon.

History and Acknowledgements

I started this project back in December 2017 or January 2018, not quite sure anymore, when I was going through the exercises from the Andrew Ng's machine learning class, and other ML resources such as Stanford Machine Learning, Caltech Learning from Data, Deep Learning tutorial, and more from MIT and others.

Since vscode is the best editor around, but unfortunately there was no Octave debugger at the time, and since I had a long commute to work, I decided to use that time to develop this plugin. It was an on and off development process, but I would say that about 80% of it was done on the train while commuting to work or flying around the world. I really would like to thank Andrew and all the openclassroom and other similar projects (e.g. OpenCourseWare), and of course the people behind Octave and vscode.

vscoctavedebugger's People

Contributors

apjanke avatar dependabot[bot] avatar paulo-fernando-silva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscoctavedebugger's Issues

'octave-cli' is not recognized as an internal or external command

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.

image

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?

Sometimes program launch/debug fails with 4294967295 exit code

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.

Process only the exact number of child variables requested by vscode.

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.

The editor could not be opened because the file was not found

Hi there,

I have a project with two main files directly located in the workspace folder and other scripts defined in folders inside the workspace. Something like this:

Workspace/
--run_ALG.m
--run_GEN.m
--src/
---- problematic_file.m
...
"I'm using the Octave debugger on my Windows machine. I get this warning when the debugger tries to access a file that is in the workspace but under the src folder:
image

I think the problem has to do with the debugger not detecting the src folder content. If I move the file to the workspace directory, the problem disappears. I've tried different launch.json options, adding the src path directly to the sourceFolder variable using ';' as a separator, as is the output of the Octave pathsep() command:
"octave:1> pathsep()
ans = ;"

I've also tried with ":" just in case this was the problem...
I do not know what the problem is and why it is not detecting the folder. Maybe a prelaunch task is needed where all the paths must be added?
Thanks in advance!
PD: here the launch.json as it is right now (only adding the workspace gives the same problem):
image

Debugger gets stuck at `pause` statements

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.

Show variables after executing files without setting breakpoints

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
image

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.

debug with qt graphic toolkit windows

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

cant show any plot

If a try show a plot i cant, because i cant use pause or input and if a does the plot crashes

Terminate on step beyond program end.

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.

Handling multiroot breakpoints.

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.

https://stackoverflow.com/questions/53158385/how-to-properly-handle-breakpoints-in-multiroot-workspaces

plot not working

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

Name-check Octave Hacking?

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:

  • adding Outline View navigation support
  • doing some customizations and improvements on the syntax definition beyond what the original TextMate language bundle provides (which is what the other extensions seem to be using, unmodified), and
  • providing some snippets for common code structures

Cheers, and thank you for writing this extension!

Andrew Janke

Debugging Variables, stepping, watch

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

  1. View variables in the debug view (or watch view)
  2. View variable values via hovering over the variable in the editor
  3. Use the stepping debugging provided by VSCode while on a breakpoint.

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)

image
image
image

Fails with quote in workspace path

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.

addpath on workingDirectory results in Invalid Path

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.

// We can pass multiple directories here separated by :

If there is a configuration fix that I have overlooked that would address this problem, please let me know.

command not found: octave-cli

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?

local variables does not show dimensions?

I remember when I first started using this a few days the local variable shows the dimensions but now it doesn't .

Screen Shot 2020-04-18 at 12 18 37 AM

Any idea how i can get the local variables to show the dimensions?

Default launch configuration

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?

Why two stack requests?

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.

Support multiple sourceFolders?

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?

Add feedback for error cases.

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.

Question about compatibility of matlab debugging

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?

Add `reload` to README.md

Hello,

Note that I needed to reload my VSCode to work.

Maybe it can be great to put it in the README.md

Merge scope fetch into a single command.

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.

Debugging doesn't work as expected

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?

image

Octave version: 6.2.0/6.1.0
VS Code version: 1.53.2

log20210213_165627.txt

multidimensional strings support

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").

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
image

remove_all_breakpoint_in_file: unable to find function ex1

Hello,

  1. I have Andrew Ng's course files on my Mac:
    ~/Projects/HOME/Learn ML AndrewNg/machine-learning-ex1/ex1
    my ${workspaceFolder} is ~/Projects/HOME/Learn ML AndrewNg
  2. I open ex1.m file
  3. Create config as follows:
"configurations": [
        {
            "type": "OctaveDebugger",
            "request": "launch",
            "name": "Function or file to execute.",
            "program": "${file}",
            "octave": "octave-cli",
            "sourceFolder": "${workspaceFolder}",
            "autoTerminate": true
        }
    ]
  1. Set breakpoint at line 33 which is warmUpExercise()
  2. press the Run button
  3. Get the error message in the debug console:
    error: remove_all_breakpoint_in_file: unable to find function ex1
    Runtime: octave-cli exited with code: 1

If I follow the same steps WITHOUT setting a breakpoint, the ex1 file runs fine

Can't inspect non-public properties in debugger.

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.

error: No such file or directory on Windows 10

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.

Passing environment variables to octave

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.

can't make this work with VSCode 1.28.2

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:

  • no red bullet points to set for each line in .m file
  • I setup a launch target
{
  // 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.