Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0: Post-merge fixes for tests involving assembly.

Dand9476f62e713
diff --git a/Ghidra/Debug/Debugger/ghidra_scripts/PopulateDemoTrace.java b/Ghidra/Debug/Debugger/ghidra_scripts/PopulateDemoTrace.java
index f2fc538b0d..475f58764e 100644
--- a/Ghidra/Debug/Debugger/ghidra_scripts/PopulateDemoTrace.java
+++ b/Ghidra/Debug/Debugger/ghidra_scripts/PopulateDemoTrace.java
@@ -386,7 +386,7 @@ public class PopulateDemoTrace extends GhidraScript {
* A call to "exit" results in the immediate termination of the calling thread.
*/
Assembler asm = Assemblers.getAssembler(trace.getFixedProgramView(snap));
- InstructionBlock mainBlock = asm.assemble(mainLabel.getAddress(), //
+ Iterator<Instruction> mainBlock = asm.assemble(mainLabel.getAddress(), //
"PUSH RBP", //
"MOV RBP,RSP", //
"CALL clone", //
@@ -404,7 +404,7 @@ public class PopulateDemoTrace extends GhidraScript {
"MOV dword ptr [RSP+8],0x21646c", //
"CALL exit" //
);
- mainBlock.forEach(mainInstructions::add);
+ mainBlock.forEachRemaining(mainInstructions::add);
/**
* Stub out "clone"
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/test/java/ghidra/pcode/exec/trace/TracePcodeEmulatorTest.java b/Ghidra/Debug/Framework-TraceModeling/src/test/java/ghidra/pcode/exec/trace/TracePcodeEmulatorTest.java
index eaae7cb2f0..f1fa0b729f 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/test/java/ghidra/pcode/exec/trace/TracePcodeEmulatorTest.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/test/java/ghidra/pcode/exec/trace/TracePcodeEmulatorTest.java
@@ -21,6 +21,7 @@ import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.math.BigInteger;
import java.nio.ByteBuffer;
+import java.util.Iterator;
import java.util.List;
import org.junit.Test;
@@ -33,7 +34,9 @@ import ghidra.app.plugin.assembler.sleigh.sem.AssemblyPatternBlock;
import ghidra.app.plugin.processors.sleigh.SleighLanguage;
import ghidra.pcode.emu.PcodeThread;
import ghidra.pcode.exec.*;
-import ghidra.program.model.lang.*;
+import ghidra.program.model.lang.Register;
+import ghidra.program.model.lang.RegisterValue;
+import ghidra.program.model.listing.Instruction;
import ghidra.test.AbstractGhidraHeadlessIntegrationTest;
import ghidra.trace.database.ToyDBTraceBuilder;
import ghidra.trace.model.memory.TraceMemoryFlag;
@@ -76,9 +79,13 @@ public class TracePcodeEmulatorTest extends AbstractGhidraHeadlessIntegrationTes
Range.atLeast(0L), tb.range(0x00100000, 0x0010ffff),
TraceMemoryFlag.READ, TraceMemoryFlag.WRITE);
Assembler asm = Assemblers.getAssembler(tb.trace.getFixedProgramView(0));
- InstructionBlock block =
+ Iterator<Instruction> block =
asm.assemble(tb.addr(0x00400000), assembly.toArray(String[]::new));
- Msg.info(this, "Assembly ended at: " + block.getMaxAddress());
+ Instruction last = null;
+ while (block.hasNext()) {
+ last = block.next();
+ }
+ Msg.info(this, "Assembly ended at: " + last.getMaxAddress());
PcodeExecutor<byte[]> exec =
TraceSleighUtils.buildByteExecutor(tb.trace, 0, thread, 0);
PcodeProgram initProg = SleighProgramCompiler.compileProgram(