-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Advanced Development Course Lab 5 solution doesn't compile and infinitely loops #2550
Comments
I'm assuming Lab5Script.java is somewhere in the repo. If it is you should submit a pull request with the correction. |
It is in the source - now that I am inspecting the source version (as opposed to the web version I was using), I see that in the commit which closed #1028 the infinite loop bug was fixed, but the compilation bug remains (I assume 9.3 introduced the bug). |
Here is alternate implementation:
|
The above solution avoids the infinite loop and is preferred to an incremental search which will be much slower. |
Sticking with the FlatProgramAPI and slower approach would look like this:
|
I have corrected the class files in source control to reflect the later example above which sticks with using the FlatProgramAPI. |
Describe the bug
The included solution for Lab 5 of the Advanced Development Course does not compile. This is because the function
getNextInstuction()
has not been defined. If that error is fixed, by for example replacing the line withinstruction = instruction.getNext()
, or using an instruction iterator to reassigninstruction
, the code has a logic error which causes an infinite loop to occur. The infinite loop occurs whenever the script encounters an instruction which is not of the formRegister <- Scalar
, because in those casesinstruction
is not updated before the continue statements.To Reproduce Compilation Error
Steps to reproduce the behavior:
Lab5Script.java
Expected behavior
The script compiles.
Example easy fix
Change the line
instruction = getNextInstruction();
toinstruction = instruction.getNext();
To Reproduce Infinite Loop Logic Error
Lab5Script.java
instruction = getNextInstruction();
withinstruction = instruction.getNext();
Expected behavior
The script adds EOL comments to instructions which are scalar values being placed into registers, and terminates.
Example easy fix (although this might make the solution less "clean")
Add a line before each of the three
continue;
lines which saysinstruction = instruction.getNext();
This allows the script to continue to evaluate instructions, instead of getting stuck on one, never updating which one is being evaluated.
Attachments
These problems are with the advanced development course lab 5 solution.
https://ghidra.re/courses/GhidraClass/AdvancedDevelopment/GhidraAdvancedDevelopment.html#60.0
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: