Closed joel-matthias closed 1 month ago
@joel-matthias this feature is not implemented yet. I will be working on it the next few days and give you updates.
I look forward to this update. Thanks
@joel-matthias I just released a new version of the debugger, implementing this feature. Please give me your feedback on the change.
The debugger does allow input from the debug output window however, there seems to be a problem with displaying output from the script. If I single step through every line of the script, the output displays correctly, but if I skip over parts of the script, the output seems to get delayed. e.g. I have a function that prints a prompt and then accepts a keyboard info. If I step into the function, the print output is displayed and then the script waits for the keyboard input. But if I step over the function, the function waits for keyboard input, but the prompt text does not get displayed in the output. The output does eventually get displayed once I step over the next line. So it seems like the output is getting buffered and not getting flushed until the next line is stepped over. I hope this helps. I can probably create a script to demonstrate the issue if you need me to.
Hi @joel-matthias. I think you will need to provide a sample script. I have not been able to reproduce this issue so far.
print("Enter something\n");
my $response =
When I run this in the debugger, the debugger output window does NOT display 'Enter something' until I input a value then it displays the value I entered followed by 'Enter something' and 'Your response was ...'
Thanks
Joel
On Sun, Oct 15, 2023 at 10:09 AM Johannes Ritter @.***> wrote:
Hi @joel-matthias https://github.com/joel-matthias. I think you will need to provide a sample script. I have not been able to reproduce this issue so far.
— Reply to this email directly, view it on GitHub https://github.com/Nihilus118/perl-debug-adapter/issues/9#issuecomment-1763418863, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAEBDRUPPVMVF2BI4MM3A3X7P4CPANCNFSM6AAAAAA53GI57Y . You are receiving this because you were mentioned.Message ID: @.***>
Hi @joel-matthias,
unfortunately I am not able to reproduce this behavior with this launch config:
{ "type": "perl", "request": "launch", "name": "Perl Debug", "program": "${workspaceFolder}/${relativeFile}", "stopOnEntry": false, "trace": true }
I get the following output:
Could you enable trace aswell and show me what is output on your machine? The code for sending to Debugger output to the debug console is very simple and I am not sure what could be changed about it.
// send the script output to the debug console
this._session.stdout!.on('data', (data) => {
this.logSendEvent(new OutputEvent(data.toString().replace(ansiSeq, ''), 'stdout'));
});
@joel-matthias I was finally able to reproduce the weird behaviour you are describing. It seems like buffering of some kind is only happening on Linux systems. I believe it has something to do with the Node runtime there. I am not a Node expert, but I will try to find some more information on this topic and a potential fix.
Ok, thanks for the update.
On Tue, Nov 14, 2023, 9:18 AM Johannes Ritter @.***> wrote:
@joel-matthias https://github.com/joel-matthias I was finally able to reproduce the weird behaviour you are describing. It seems like buffering of some kind is only happening on Linux systems. I believe it has something to do with the Node runtime there. I am not a Node expert, but I will try to find some more information on this topic and a potential fix.
— Reply to this email directly, view it on GitHub https://github.com/Nihilus118/perl-debug-adapter/issues/9#issuecomment-1810436776, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAEBDTXQBYYLWREEOTO6ODYEODVHAVCNFSM6AAAAAA53GI572VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJQGQZTMNZXGY . You are receiving this because you were mentioned.Message ID: @.***>
Hi @joel-matthias,
I finally have some good news. The problem is not with the debug adapter, but with Perl itself as it buffers output by default.
While the buffer is flushed after every print
statement on Windows, this is not the case for Unix systems. Disabling buffering inside the Perl script like so fixed the issue on my test machine:
use strict;
use warnings;
$| = 1;
print "Enter a number: ";
my $input = <STDIN>;
print $input . "\n";
Please tell me if this fixes the issue for you aswell.
I could disable all buffering during the debug session by sending $| = 1;
to the debug console once on startup but I don't think that this is a good idea.
I think the smartest way to fix this is to add another parameter to the launch config that lets the user toggle buffering on or off. Having buffered mode as default.
What is your opinion on that?
Hi @joel-matthias,
I just released a new version of the debugger that disables buffering to STDOUT by default. Please give it a try.
Closing this issue due to inactivity. Please feel free to reopen if the current solution does not fully address your needs.
It doesn't seem possible to enter text when the following code runs:
my $op = <STDIN>;
What am I missing?