-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I/O fails in debug mode when CONSOLE not defined #14
Comments
Ugh, OK. Here is a historical perspective; you might enjoy it. I don't know how much of this survives, but the original idea for "debugging" a Befunge program (i.e. viewing the playfield, the stack, and the input/output all at the same time) relied a feature of the Amiga shell: redirection to a newly-opened console window. You could give a string like Looking at the code now, I see "stackfile", whose purpose was definitely being able to view the stack in another console window, while the program executed. "inputfile" and "outputfile" would have been similar (though I'm not sure why they couldn't have just been done with file redirection.) I don't see a "playfieldfile", -- so I think the idea was that And note that, under the assumption that you have given an I am fairly certain the I agree something should be done to at least stop it from exhibiting different behaviour in debug mode, I'm just not sure what, yet. I'll start a branch for this but, at the rate I'm going, it might not make it in for v2.24. |
That is really interesting. I'd often wondered why you had all those options for redirecting stuff to a file. It makes a lot more sense now. And if I've understood you correctly, simple file redirection wouldn't have been an option (at least for output), since you'd still need the standard output stream to produce the debugging view. You can actually get a similar setup working in Linux by outputting to a file which you view with As for the patches, I can understand you wanting to leave this for another time. The more I think about it the more I dislike the approach I was taking. There are just too many edge cases where it doesn't quite work. |
OK, so clearly I don't know much about Linux. :) After a bit more investigating, I discovered you can actually redirect both input and output to another terminal simply by specifying the device name as the target filename. In case this is news to you too, you can get the device name with the
You'll also probably want to do something in the output terminal to prevent the input being consumed by the shell itself. I just used Interestingly this also works in the Windows Subsystem for Linux, but I don't think there's an equivalent in the native Windows shell. |
I did expect something like that was possible; way back in the circa-1993 era, the university I was attending had an actual multi-user Unix system, and at some point when several of us were logged in at the same time, I looked up what my tty device was, set it world-writeable with A more sensible approach in the modern world would probably be to redirect output to a named pipe, and then cat that from another terminal. Or open a server socket and have the user telnet or netcat on it. Either way, if one wanted to try to simulate Amiga's Anyway, I think this issue will stay in the "Doctor, it hurts when I do this / Well don't do that then" state for 2.24. |
If bef is compiled without the CONSOLE define, and you try to debug a program which uses any of the input/output commands, the code won't be interpreted correctly. It's not just that the I/O commands aren't supported - the problem is that they leave the stack in the wrong state. The output commands don't pop anything, and the input commands don't push anything.
As a minimal "fix", you could just include a pop for the output commands, and maybe push -1 for the input commands. In case it's not obvious what I mean, here's a possible patch:
nocon-patch-1.txt
If you want to make a bit more effort though, it is possible to get quite close to the conio implementation using just ANSI escape sequences. I've put together a basic patch showing how that could work:
nocon-patch-2.txt
But that's just a proof-of-concept - you can see that there's a lot of code duplication going on which is in desperate need of refactoring. That level of change I think is best left to you, though, assuming you even what to do anything with this issue.
The text was updated successfully, but these errors were encountered: