Refactoring for clearer API around the Analysis Lifecycle and support for pulling datatypes from server #151
+1,811
−1,419
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a clearer split between the 3 levels of guarantees about the relation between a local Ghidra
Programand an analysis on the server (referenced by anAnalysisID):AnalysisIDassociated with theProgramat all: Available actions are basically limited to starting an analysis.Program. Either by creating a new analysis or associating an existing one. In this state there are no guarantees made about the state of the analysis. It might still be running, or it might have already failed with an error. Actions related to querying the status of an analysis require at least this.Programand the immutableFunctionIDs have been associated with the local functions in Ghidra. This is needed for the core product features like searching for matches, AI decomp.Level 2 is guaranteed by obtaining a
ProgramWithIDobject from theGhidraRevengService. The only method to obtain an instance of this class isGhidraRevengService#getKnownProgram(Program)which returns anOptional<ProgramWithID>that will only be non-empty if theProgramis associated with anAnalysisIDinternally.Level 3 is guaranteed by obtaining an
AnalysedProgramfromGhidraRevengService#getAnalysedProgram(Program)Methods on the service now have type signatures that encode what they require, i.e. requesting the AI decompiled code requires a
FunctionIDand the only way to obtain a function ID is to query it from theAnalysedPrograminstance. The caller thus has to obtain anAnalysedProgramfirst, forcing them to explicitly handle the case where an empty Optional is returned i.e. when no finished analysis is available for thisProgram. This also makes the error cases clearer: AFunctionIDmight not be available because the analysis didn't successfully finish, or it might not be available because the local (thunk) function does not have an associatedFunctionIDon the server side.Additionally, this PR implements the feature to pull datatypes together with function names from the server, via a dedicated pull method. This method is designed to be called repeatedly and simply does nothing if no changes were found (and in this case does not even create an empty transaction).