-
Notifications
You must be signed in to change notification settings - Fork 0
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
Unicode support for string directives #1
Conversation
The following program demonstrates the unicode being loaded correctly in directives, the unicode escape being implemented, and printing correctly:
|
I took a look at why open broke. You are leaving a null byte at the end of every string. rars/rars/riscv/syscalls/NullString.java Lines 74 to 75 in de9205a
Just to inform you guys on how to find bugs like this, my process was:
So, a debugger and a source reference for the Java API were useful tools. But you found the right line, so my tip would be to print stack traces if a line in question is throwing. |
Also your code for handling Assembling the following throws an exception on the command line and fails to log an error to the console. Your substring call just doesn't check to make sure there are enough characters.
|
@TheThirdOne rars/rars/riscv/syscalls/NullString.java Lines 73 to 77 in de9205a
This was incredibly helpful thank you for this. Would you mind recommending me a debugger which you find works well with RARS?
Sorry about this. This was definitely a sloppy implementation. Like I mentioned previously I'm quite unfamiliar with java and thus the error handling but I will work on this. Thank you for your detailed feedback and help it is very much appreciated. |
I'm glad it was helpful. I have been using Intellij as an IDE when working on RARS, so I have used its debugging features, but any other IDE (Eclipse, Netbeans, ...) should have similar features. If you don't want to use an IDE for it, jdb seems like a good solution but it is command line only. JSwat might work but is discontinued and apparently does not work for Java 8 which is required for running RARS. |
@TheThirdOne We got the IntelliJ IDE but we are having trouble in the Build/Run/Debug configurations. What should it be? I used a JAR application configuration giving it the build-jar.sh for build and the jar file to run but debugging and breakpoints doesn't work with that. |
Noticed that the original pull request which added unicode support for the printstring syscall appears to have broken the open syscall. When stepping through the example File I/O code, which is provided in the syscalls tab of the f1 help in rars, the open file syscall returns -1 in a0 indicating that the file was not opened successfully. Because this problem appears to have started with the modifications in the original pull request they remain in this update. @rmnattas and I narrowed the issue down to the line 447 in the following:
rars/rars/util/SystemIO.java
Lines 415 to 456 in d057f77
From there we noticed that if we replace
filename
with"testout.txt"
the file is created/opened successfully and will then write to the file successfully. We see that openfile is called in:rars/rars/riscv/syscalls/SyscallOpen.java
Lines 45 to 49 in d057f77
which uses the
NullString.get()
method that was modified in the original pull request. We don't think its an issue with the utf-8 encoding because the filename bytes are loaded correctly in memory andFileOutputStream()
is able to create a file with a utf-8 encoded name in a java simulator. As of right now we are still looking into this issue but wanted to update with these new changes. Any advice into what this problem may be would be appreciated.