Skip to content

Commit

Permalink
GP-0 corrected Data pointer stacking test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
ghidra1 committed Jan 30, 2024
1 parent 60fc7a3 commit b3c19de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -483,16 +483,17 @@ public void testCreateCompoundUndefinedPointer() {
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();
Expand Down Expand Up @@ -557,16 +558,17 @@ public void testCreateCompoundDefinedPointer() {
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();
Expand Down Expand Up @@ -630,8 +632,8 @@ public void testCreateDataOnDefaultPointer()

// 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ public static Data createData(Program program, Address addr, DataType newType, i
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()) {
Expand All @@ -185,10 +189,6 @@ public static Data createData(Program program, Address addr, DataType newType, i
}
}

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 =
Expand Down

0 comments on commit b3c19de

Please sign in to comment.