paulo-fernando-silva / vscOctaveDebugger

MIT License
35 stars 4 forks source link

Show variables after executing files without setting breakpoints #55

Closed happyTonakai closed 2 years ago

happyTonakai commented 3 years ago

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.

paulo-fernando-silva commented 3 years ago

Hi, let me see if I understand. You want to be able to have an interactive session with octave? As I understand, you could be referring to interacting with octave-gui without using a script file. If that's the case, the vscode debugging functionality doesn't allow for that. It would have to be hacked somehow.

If you're referring to octave-gui keeping the state of the variables after the script exits, that's about the same. vscode will clear its variable display area after the debugger exits. I can keep the debugger alive, but without a debugging session then things need to change a bit. Indeed, autoTerminate was meant to help with something like that, but unfortunately not quite the same. I can try to look into it. Might be an interesting feature. 🙂

happyTonakai commented 3 years ago

Sorry for the confusing statement. I mean keeping the state of the variables after pressing F5. For me keeping the debugger alive is preferred because I can then use the debug console to check the results and further do some maths.

In summary, what I want is not to exit the debugger after the script is executed. Setting a breakpoint on the last line can achieve this goal but it is a little bit cumbersome.

paulo-fernando-silva commented 3 years ago

Now, setting autoTerminate:false will put octave-cli in interactive mode. There's a short explanation in the readme. In this mode, either after your script exits, or if you don't run any script, octave will be left running, and the VARIABLES and WATCHES will still display octave's internal state. I'll close this request now. Do reopen it if you find any issues.

happyTonakai commented 3 years ago

Thank you sir. It works very well! Btw, I notice that in this mode

octave will terminate only when either the stop â–¡ button is pressed, or when an error occurs.

Is it possible to keep octave running after I set dbstop if error and an error occurs? This should be helpful when debugging.

paulo-fernando-silva commented 3 years ago

I see. I'll look into it.

paulo-fernando-silva commented 2 years ago

You should be able to continue in interactive mode even on error on the latest version of the plugin. You do need to add "octaveArguments": [ "--interactive" ], in your launch options. I'm not making this the default option because it has not been tested, and might cause issues. Let me know if this works for you. If you find problems, comment on the bug again.

happyTonakai commented 2 years ago

Great job! It works pretty well after setting dbstop if error and adding "octaveArguments": [ "--interactive" ] in my launch options. Thank you!