GP-0: Fixed various Debugger and Assembler test issues

This commit is contained in:
Dan 2022-06-27 14:32:19 -04:00 committed by ghidra1
parent 547a729feb
commit 8ab6690dff
10 changed files with 78 additions and 36 deletions

View file

@ -200,7 +200,8 @@ public abstract class AbstractAssemblyTest extends AbstractGenericTest {
*/
protected void checkAllExact(AssemblyResolutionResults rr, Collection<String> disassembly,
long addr, String ctxstr) {
final AssemblyPatternBlock ctx = (ctxstr == null ? context.getDefault()
Address address = lang.getDefaultSpace().getAddress(addr);
final AssemblyPatternBlock ctx = (ctxstr == null ? context.getDefaultAt(address)
: AssemblyPatternBlock.fromString(ctxstr)).fillMask();
dbg.println("Checking each: " + disassembly + " ctx:" + ctx);
boolean gotOne = false;
@ -316,6 +317,7 @@ public abstract class AbstractAssemblyTest extends AbstractGenericTest {
protected void runTest(String assembly, String instr, Collection<String> disassembly, long addr,
String ctxstr, boolean checkOneCompat, boolean checkAllExact,
boolean checkAllSyntaxErrs, boolean checkAllSemanticErrs) {
Address address = lang.getDefaultSpace().getAddress(addr);
// A sanity check, first
if (instr != null) {
@ -323,9 +325,8 @@ public abstract class AbstractAssemblyTest extends AbstractGenericTest {
if (!ins.isFullMask()) {
throw new RuntimeException("Desired instruction bytes should be fully-defined");
}
final AssemblyPatternBlock ctx =
(ctxstr == null ? context.getDefault() : AssemblyPatternBlock.fromString(ctxstr))
.fillMask();
final AssemblyPatternBlock ctx = (ctxstr == null ? context.getDefaultAt(address)
: AssemblyPatternBlock.fromString(ctxstr)).fillMask();
try {
String disstr;
PseudoInstruction psins = disassemble(addr, ins.getVals(), ctx.getVals());
@ -374,12 +375,11 @@ public abstract class AbstractAssemblyTest extends AbstractGenericTest {
try {
if (ctxstr == null) {
assembler.assembleLine(lang.getDefaultSpace().getAddress(addr), assembly);
assembler.assembleLine(address, assembly);
}
else {
SleighAssembler sas = (SleighAssembler) assembler;
sas.assembleLine(lang.getDefaultSpace().getAddress(addr), assembly,
AssemblyPatternBlock.fromString(ctxstr));
sas.assembleLine(address, assembly, AssemblyPatternBlock.fromString(ctxstr));
}
}
catch (AssemblySemanticException e) {

View file

@ -207,7 +207,8 @@ public abstract class AssemblyTestCase extends AbstractGenericTest {
*/
protected void checkAllExact(AssemblyResolutionResults rr, Collection<String> disassembly,
long addr, String ctxstr) {
final AssemblyPatternBlock ctx = (ctxstr == null ? context.getDefault()
Address address = lang.getDefaultSpace().getAddress(addr);
final AssemblyPatternBlock ctx = (ctxstr == null ? context.getDefaultAt(address)
: AssemblyPatternBlock.fromString(ctxstr)).fillMask();
dbg.println("Checking each: " + disassembly + " ctx:" + ctx);
boolean gotOne = false;
@ -323,6 +324,7 @@ public abstract class AssemblyTestCase extends AbstractGenericTest {
protected void runTest(String assembly, String instr, Collection<String> disassembly, long addr,
String ctxstr, boolean checkOneCompat, boolean checkAllExact,
boolean checkAllSyntaxErrs, boolean checkAllSemanticErrs) {
Address address = lang.getDefaultSpace().getAddress(addr);
// A sanity check, first
if (instr != null) {
@ -330,7 +332,7 @@ public abstract class AssemblyTestCase extends AbstractGenericTest {
if (!ins.isFullMask()) {
throw new RuntimeException("Desired instruction bytes should be fully-defined");
}
final AssemblyPatternBlock ctx = (ctxstr == null ? context.getDefault()
final AssemblyPatternBlock ctx = (ctxstr == null ? context.getDefaultAt(address)
: AssemblyPatternBlock.fromString(ctxstr)).fillMask();
try {
String disstr;
@ -380,12 +382,11 @@ public abstract class AssemblyTestCase extends AbstractGenericTest {
try {
if (ctxstr == null) {
assembler.assembleLine(lang.getDefaultSpace().getAddress(addr), assembly);
assembler.assembleLine(address, assembly);
}
else {
SleighAssembler sas = (SleighAssembler) assembler;
sas.assembleLine(lang.getDefaultSpace().getAddress(addr), assembly,
AssemblyPatternBlock.fromString(ctxstr));
sas.assembleLine(address, assembly, AssemblyPatternBlock.fromString(ctxstr));
}
}
catch (AssemblySemanticException e) {