GP-5879: Add callbacks to PcodeEmulator. Refactor for composition vice inheritance.

This commit is contained in:
Dan
2025-07-30 16:45:40 +00:00
parent c0127326f8
commit 72001639a8
162 changed files with 5298 additions and 5887 deletions

View File

@@ -13,18 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ghidra.app.plugin.core.debug.service.emulation.BytesDebuggerPcodeEmulator;
import ghidra.app.plugin.core.debug.service.emulation.BytesDebuggerPcodeEmulatorFactory;
import ghidra.app.plugin.core.debug.service.emulation.DefaultEmulatorFactory;
import ghidra.app.script.GhidraScript;
import ghidra.debug.api.emulation.DebuggerPcodeMachine;
import ghidra.debug.api.emulation.PcodeDebuggerAccess;
import ghidra.debug.flatapi.FlatDebuggerAPI;
import ghidra.pcode.emu.*;
import ghidra.pcode.exec.PcodeUseropLibrary;
import ghidra.pcode.exec.trace.TraceEmulationIntegration.Writer;
import ghidra.program.model.lang.Language;
public class InstallCustomLibraryScript extends GhidraScript implements FlatDebuggerAPI {
public static class CustomBytesDebuggerPcodeEmulator extends BytesDebuggerPcodeEmulator {
private CustomBytesDebuggerPcodeEmulator(PcodeDebuggerAccess access) {
super(access);
public static class CustomPcodeEmulator extends PcodeEmulator {
private CustomPcodeEmulator(Language language, PcodeEmulationCallbacks<byte[]> cb) {
super(language, cb);
}
@Override
@@ -35,10 +36,10 @@ public class InstallCustomLibraryScript extends GhidraScript implements FlatDebu
}
public static class CustomBytesDebuggerPcodeEmulatorFactory
extends BytesDebuggerPcodeEmulatorFactory {
extends DefaultEmulatorFactory {
@Override
public DebuggerPcodeMachine<?> create(PcodeDebuggerAccess access) {
return new CustomBytesDebuggerPcodeEmulator(access);
public PcodeMachine<?> create(PcodeDebuggerAccess access, Writer writer) {
return new CustomPcodeEmulator(access.getLanguage(), writer.callbacks());
}
}