GP-0 corrected Data pointer stacking test failures

This commit is contained in:
ghidra1 2024-01-30 09:02:08 -05:00
parent 60fc7a35c2
commit b3c19de3dd
2 changed files with 14 additions and 12 deletions

View File

@ -483,16 +483,17 @@ public class CreateDataCmdTest extends AbstractGenericTest {
pdt = (Pointer) dt;
assertNull(pdt.getDataType());
// When default pointer is stacked, the resulting pointer size will match
// the outmost pointer size - in this case that is 1-byte
cmd = new CreateDataCmd(addr, false, true, new PointerDataType());
cmd.applyTo(program);
d = listing.getDataAt(addr);
assertNotNull(d);
assertTrue(d.isDefined());
assertEquals(addr.getPointerSize(), d.getLength());
assertEquals(1, d.getLength());
dt = d.getDataType();
assertTrue(dt instanceof Pointer);
assertEquals(addr.getPointerSize(), dt.getLength());
assertEquals(1, dt.getLength());
pdt = (Pointer) dt;
dt = pdt.getDataType();
@ -557,16 +558,17 @@ public class CreateDataCmdTest extends AbstractGenericTest {
pdt = (Pointer) dt;
assertTrue(pdt.getDataType() instanceof ByteDataType);
// When default pointer is stacked, the resulting pointer size will match
// the outmost pointer size - in this case that is 1-byte
cmd = new CreateDataCmd(addr, false, true, new PointerDataType());
cmd.applyTo(program);
d = listing.getDataAt(addr);
assertNotNull(d);
assertTrue(d.isDefined());
assertEquals(addr.getPointerSize(), d.getLength());
assertEquals(1, d.getLength());
dt = d.getDataType();
assertTrue(dt instanceof Pointer);
assertEquals(addr.getPointerSize(), dt.getLength());
assertEquals(1, dt.getLength());
pdt = (Pointer) dt;
dt = pdt.getDataType();
@ -630,8 +632,8 @@ public class CreateDataCmdTest extends AbstractGenericTest {
// Add external reference from pointer
program.getReferenceManager()
.addExternalReference(addr, "OtherFile", "ExtLabel", null,
SourceType.USER_DEFINED, 0, RefType.DATA);
.addExternalReference(addr, "OtherFile", "ExtLabel", null, SourceType.USER_DEFINED,
0, RefType.DATA);
// Undefined* becomes Byte*
cmd = new CreateDataCmd(addr, false, true, new ByteDataType());

View File

@ -166,6 +166,10 @@ public final class DataUtilities {
Reference extRef = null;
if (!isParentData(data, addr)) {
if (!stackPointers && isDataClearingDenied(existingType, clearMode)) {
throw new CodeUnitInsertionException("Could not create Data at address " + addr);
}
existingLength = data.getLength();
if (data.isDefined()) {
@ -185,10 +189,6 @@ public final class DataUtilities {
}
}
if (!stackPointers && isDataClearingDenied(existingType, clearMode)) {
throw new CodeUnitInsertionException("Could not create Data at address " + addr);
}
// TODO: This can probably be eliminated
// Check for external reference on pointer
extRef =