Merge remote-tracking branch 'origin/GP-1306_ghidra1_ComponentCountIssue' into patch

This commit is contained in:
ghidra1 2021-09-27 17:40:48 -04:00
commit f4721d969c
3 changed files with 13 additions and 11 deletions

View File

@ -86,7 +86,8 @@ class StructureDB extends CompositeDB implements StructureInternal {
structLength = record.getIntValue(CompositeDBAdapter.COMPOSITE_LENGTH_COL);
structAlignment = record.getIntValue(CompositeDBAdapter.COMPOSITE_ALIGNMENT_COL);
computedAlignment = -1;
numComponents = record.getIntValue(CompositeDBAdapter.COMPOSITE_NUM_COMPONENTS_COL);
numComponents = isPackingEnabled() ? components.size()
: record.getIntValue(CompositeDBAdapter.COMPOSITE_NUM_COMPONENTS_COL);
}
@Override
@ -127,7 +128,7 @@ class StructureDB extends CompositeDB implements StructureInternal {
DataTypeComponentDB dtc = null;
try {
if (dataType == DataType.DEFAULT) {
// FIXME: verify - does not appear to modify structure
// assume non-packed structure (non-stored undefined component)
dtc = new DataTypeComponentDB(dataMgr, componentAdapter, this, key,
numComponents, structLength);
}
@ -238,8 +239,8 @@ class StructureDB extends CompositeDB implements StructureInternal {
}
private void doGrowStructure(int amount) {
if (!isPackingEnabled()) {
numComponents += amount;
if (isPackingEnabled()) {
throw new AssertException("only valid for non-packed");
}
record.setIntValue(CompositeDBAdapter.COMPOSITE_NUM_COMPONENTS_COL, numComponents);
structLength += amount;
@ -2033,7 +2034,7 @@ class StructureDB extends CompositeDB implements StructureInternal {
StructurePackResult packResult =
AlignedStructurePacker.packComponents(this, components);
changed = packResult.componentsChanged;
changed |= updateComposite(packResult.numComponents, packResult.structureLength,
changed |= updateComposite(components.size(), packResult.structureLength,
packResult.alignment, !isAutoChange);
}

View File

@ -83,7 +83,8 @@ public class AlignedStructurePacker {
InternalDataTypeComponent dataTypeComponent = componentIterator.next();
DataType componentDt = dataTypeComponent.getDataType();
if (DataType.DEFAULT == componentDt) {
componentIterator.remove(); // remove default components.
// transform improper DEFAULT datatype use to Undefined1
dataTypeComponent.setDataType(Undefined1DataType.dataType);
componentsChanged = true;
}
++componentCount;

View File

@ -548,8 +548,7 @@ public class StructureDataType extends CompositeDataTypeImpl implements Structur
if (isPackingEnabled()) {
return;
}
numComponents += amount;
structLength += amount;
doGrowStructure(amount);
repack(false);
notifySizeChanged();
}
@ -1518,7 +1517,7 @@ public class StructureDataType extends CompositeDataTypeImpl implements Structur
(numComponents != packResult.numComponents);
structLength = packResult.structureLength;
structAlignment = packResult.alignment;
numComponents = packResult.numComponents;
numComponents = components.size();
}
if (changed && notify) {
@ -1566,9 +1565,10 @@ public class StructureDataType extends CompositeDataTypeImpl implements Structur
}
private void doGrowStructure(int amount) {
if (!isPackingEnabled()) {
numComponents += amount;
if (isPackingEnabled()) {
throw new AssertException("only valid for non-packed");
}
numComponents += amount;
structLength += amount;
}