From 6a006ac085dcfa89a2b42513179f6190f06ffd91 Mon Sep 17 00:00:00 2001 From: ghidra1 Date: Wed, 7 Dec 2022 14:10:10 -0500 Subject: [PATCH] GP-1945 Eliminate use of blank component names (zero-length bitfields) --- .../merge/datatypes/DataTypeMerge3Test.java | 10 +- .../model/data/StructureDataTypeTest.java | 210 +++++++-------- .../program/model/data/UnionDataTypeTest.java | 14 +- .../bin/format/pdb/CompositeMemberTest.java | 14 +- .../database/data/DataTypeComponentDB.java | 5 +- .../model/data/AlignedStructureInspector.java | 5 +- .../program/model/data/CompositeInternal.java | 6 +- .../program/model/data/DataTypeComponent.java | 12 +- .../model/data/DataTypeComponentImpl.java | 2 +- .../model/data/InternalDataTypeComponent.java | 8 +- .../model/data/ReadOnlyDataTypeComponent.java | 5 - .../database/data/StructureDBTest.java | 242 +++++++++--------- .../program/database/data/UnionDBTest.java | 30 +-- 13 files changed, 281 insertions(+), 282 deletions(-) diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/merge/datatypes/DataTypeMerge3Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/merge/datatypes/DataTypeMerge3Test.java index fb487f4186..3f639ca382 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/merge/datatypes/DataTypeMerge3Test.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/merge/datatypes/DataTypeMerge3Test.java @@ -2209,13 +2209,13 @@ public class DataTypeMerge3Test extends AbstractDataTypeMergeTest { assertEquals("/Category1/Category2/CoolUnion\n" + "pack(disabled)\n" + "Union CoolUnion {\n" + - " 0 qword 8 null \"\"\n" + + " 0 qword 8 \"\"\n" + " 0 byte:4(4) 1 BF1 \"my bf1\"\n" + " 0 byte:2(6) 1 BF2 \"my bf2\"\n" + - " 0 word 2 null \"\"\n" + - " 0 undefined * * * * * 4 null \"\"\n" + - " 0 DLL_Table 96 null \"\"\n" + - " 0 DLL_Table *32 4 null \"\"\n" + + " 0 word 2 \"\"\n" + + " 0 undefined * * * * * 4 \"\"\n" + + " 0 DLL_Table 96 \"\"\n" + + " 0 DLL_Table *32 4 \"\"\n" + "}\n" + "Size = 96 Actual Alignment = 1\n", union.toString()); //@formatter:on diff --git a/Ghidra/Features/Base/src/test/java/ghidra/program/model/data/StructureDataTypeTest.java b/Ghidra/Features/Base/src/test/java/ghidra/program/model/data/StructureDataTypeTest.java index 58704140f9..5a60944385 100644 --- a/Ghidra/Features/Base/src/test/java/ghidra/program/model/data/StructureDataTypeTest.java +++ b/Ghidra/Features/Base/src/test/java/ghidra/program/model/data/StructureDataTypeTest.java @@ -510,7 +510,7 @@ public class StructureDataTypeTest extends AbstractGTest { "pack()\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 2 word 2 null \"Comment2\"\n" + + " 2 word 2 \"Comment2\"\n" + " 4 byte 1 field4 \"Comment4\"\n" + " 5 char[0] 0 flex \"FlexComment\"\n" + "}\n" + @@ -525,7 +525,7 @@ public class StructureDataTypeTest extends AbstractGTest { "pack()\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 2 word 2 null \"Comment2\"\n" + + " 2 word 2 \"Comment2\"\n" + " 4 byte 1 field4 \"Comment4\"\n" + " 8 int[0] 0 flex \"FlexComment\"\n" + "}\n" + @@ -552,7 +552,7 @@ public class StructureDataTypeTest extends AbstractGTest { " 4 int:0(0) 0 \"zero bitfield 1\"\n" + " 4 int:3(0) 1 bf2 \"bf1Comment\"\n" + " 5 byte 1 field1 \"Comment1\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 byte 1 field4 \"Comment4\"\n" + "}\n" + "Size = 12 Actual Alignment = 4", struct); @@ -569,7 +569,7 @@ public class StructureDataTypeTest extends AbstractGTest { " 4 int:0(0) 0 \"zero bitfield 2\"\n" + " 4 int:3(0) 1 bf2 \"bf1Comment\"\n" + " 5 byte 1 field1 \"Comment1\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 byte 1 field4 \"Comment4\"\n" + "}\n" + "Size = 12 Actual Alignment = 4", struct); @@ -586,13 +586,13 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + " 8 int:3(0) 1 bf1 \"bf1Comment\"\n" + -// " 9 undefined 1 null \"\"\n" + -// " 10 undefined 1 null \"\"\n" + -// " 11 undefined 1 null \"\"\n" + +// " 9 undefined 1 \"\"\n" + +// " 10 undefined 1 \"\"\n" + +// " 11 undefined 1 \"\"\n" + "}\n" + "Size = 12 Actual Alignment = 1", struct); //@formatter:on @@ -604,14 +604,14 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + " 8 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 8 int:3(3) 1 bf2 \"bf2Comment\"\n" + -// " 9 undefined 1 null \"\"\n" + -// " 10 undefined 1 null \"\"\n" + -// " 11 undefined 1 null \"\"\n" + +// " 9 undefined 1 \"\"\n" + +// " 10 undefined 1 \"\"\n" + +// " 11 undefined 1 \"\"\n" + "}\n" + "Size = 12 Actual Alignment = 1", struct); //@formatter:on @@ -627,15 +627,15 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + -// " 8 undefined 1 null \"\"\n" + -// " 9 undefined 1 null \"\"\n" + +// " 8 undefined 1 \"\"\n" + +// " 9 undefined 1 \"\"\n" + " 10 int:3(0) 1 bf1 \"bf1Comment\"\n" + -// " 11 undefined 1 null \"\"\n" + -// " 12 undefined 1 null \"\"\n" + -// " 13 undefined 1 null \"\"\n" + +// " 11 undefined 1 \"\"\n" + +// " 12 undefined 1 \"\"\n" + +// " 13 undefined 1 \"\"\n" + "}\n" + "Size = 14 Actual Alignment = 1", struct); //@formatter:on @@ -647,16 +647,16 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + -// " 8 undefined 1 null \"\"\n" + -// " 9 undefined 1 null \"\"\n" + +// " 8 undefined 1 \"\"\n" + +// " 9 undefined 1 \"\"\n" + " 10 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 10 int:3(3) 1 bf2 \"bf2Comment\"\n" + -// " 11 undefined 1 null \"\"\n" + -// " 12 undefined 1 null \"\"\n" + -// " 13 undefined 1 null \"\"\n" + +// " 11 undefined 1 \"\"\n" + +// " 12 undefined 1 \"\"\n" + +// " 13 undefined 1 \"\"\n" + "}\n" + "Size = 14 Actual Alignment = 1", struct); //@formatter:on @@ -672,12 +672,12 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -691,13 +691,13 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -711,12 +711,12 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -739,12 +739,12 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -773,12 +773,12 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(5) 1 bf1 \"bf1Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -792,13 +792,13 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(5) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(2) 1 bf2 \"bf2Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -812,12 +812,12 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(5) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(2) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(3) 3 bf3 \"bf3Comment\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -831,12 +831,12 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(5) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(2) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(3) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(0) 2 bf4 \"bf4Comment\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -859,13 +859,13 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + - " 2 float 4 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + + " 2 float 4 \"\"\n" + " 6 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 6 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 6 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 8 int:11(5) 2 bf4 \"bf4Comment\"\n" + - " 10 word 2 null \"Comment2\"\n" + + " 10 word 2 \"Comment2\"\n" + " 12 dword 4 field3 \"\"\n" + " 16 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1083,12 +1083,12 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1102,10 +1102,10 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + -// " 2 undefined 1 null \"\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + +// " 2 undefined 1 \"\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + " 5 dword 4 field3 \"\"\n" + " 9 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1143,12 +1143,12 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1162,7 +1162,7 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + @@ -1180,7 +1180,7 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + @@ -1197,9 +1197,9 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + +// " 3 undefined 1 \"\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + " 6 dword 4 field3 \"\"\n" + " 10 byte 1 field4 \"Comment4\"\n" + @@ -1214,11 +1214,11 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + " 6 dword 4 field3 \"\"\n" + " 10 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1232,11 +1232,11 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + -// " 2 undefined 1 null \"\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + +// " 2 undefined 1 \"\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + " 6 dword 4 field3 \"\"\n" + " 10 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1250,10 +1250,10 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + -// " 2 undefined 1 null \"\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + +// " 2 undefined 1 \"\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + " 5 dword 4 field3 \"\"\n" + " 9 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1483,7 +1483,7 @@ public class StructureDataTypeTest extends AbstractGTest { * pack(disabled) * Structure TestStruct { * 0 byte 1 field1 "Comment1" - * 1 word 2 null "Comment2" + * 1 word 2 "Comment2" * 3 dword 4 field3 "" * 7 byte 1 field4 "Comment4" * } @@ -1491,7 +1491,7 @@ public class StructureDataTypeTest extends AbstractGTest { */ DataTypeComponent dtc = struct.getComponentAt(3); - assertEquals(" 2 3 dword 4 field3 null", dtc.toString()); + assertEquals(" 2 3 dword 4 field3 ", dtc.toString()); dtc = struct.getComponentAt(4); // offcut assertNull(dtc); @@ -1512,7 +1512,7 @@ public class StructureDataTypeTest extends AbstractGTest { * pack(disabled) * Structure TestStruct { * 0 byte 1 field1 "Comment1" - * 1 word 2 null "Comment2" + * 1 word 2 "Comment2" * 3 dword 4 field3 "" * 7 byte 1 field4 "Comment4" * 8 char[0] 0 zarray1 "" @@ -1523,7 +1523,7 @@ public class StructureDataTypeTest extends AbstractGTest { */ dtc = struct.getComponentAt(8); - assertEquals(" 5 8 long 4 field4 null", dtc.toString()); + assertEquals(" 5 8 long 4 field4 ", dtc.toString()); dtc = struct.getComponentAt(9); // offcut assertNull(dtc); @@ -1539,7 +1539,7 @@ public class StructureDataTypeTest extends AbstractGTest { * pack(disabled) * Structure Test { * 0 byte 1 field1 "Comment1" - * 2 word 2 null "Comment2" + * 2 word 2 "Comment2" * 4 dword 4 field3 "" * 8 byte 1 field4 "Comment4" * 9 char[0] 0 zarray1 "" @@ -1557,14 +1557,14 @@ public class StructureDataTypeTest extends AbstractGTest { struct.setPackingEnabled(false); dtc = struct.getComponentAt(9); // undefined at offset of zero-length component - assertEquals(" 5 9 undefined 1 null null", dtc.toString()); + assertEquals(" 5 9 undefined 1 ", dtc.toString()); } @Test public void testGetComponentContaining() { DataTypeComponent dtc = struct.getComponentContaining(4); - assertEquals(" 2 3 dword 4 field3 null", dtc.toString()); + assertEquals(" 2 3 dword 4 field3 ", dtc.toString()); assertEquals(8, struct.getLength()); @@ -1582,7 +1582,7 @@ public class StructureDataTypeTest extends AbstractGTest { * pack(disabled) * Structure TestStruct { * 0 byte 1 field1 "Comment1" - * 1 word 2 null "Comment2" + * 1 word 2 "Comment2" * 3 dword 4 field3 "" * 7 byte 1 field4 "Comment4" * 8 char[0] 0 zarray1 "" @@ -1593,10 +1593,10 @@ public class StructureDataTypeTest extends AbstractGTest { */ dtc = struct.getComponentContaining(8); - assertEquals(" 5 8 long 4 field4 null", dtc.toString()); + assertEquals(" 5 8 long 4 field4 ", dtc.toString()); dtc = struct.getComponentContaining(9); // offcut - assertEquals(" 5 8 long 4 field4 null", dtc.toString()); + assertEquals(" 5 8 long 4 field4 ", dtc.toString()); dtc = struct.getComponentContaining(12); // end-of-struct assertNull(dtc); @@ -1609,7 +1609,7 @@ public class StructureDataTypeTest extends AbstractGTest { * pack(disabled) * Structure Test { * 0 byte 1 field1 "Comment1" - * 2 word 2 null "Comment2" + * 2 word 2 "Comment2" * 4 dword 4 field3 "" * 8 byte 1 field4 "Comment4" * 9 char[0] 0 zarray1 "" @@ -1627,14 +1627,14 @@ public class StructureDataTypeTest extends AbstractGTest { struct.setPackingEnabled(false); dtc = struct.getComponentContaining(9); // undefined at offset of zero-length component - assertEquals(" 5 9 undefined 1 null null", dtc.toString()); + assertEquals(" 5 9 undefined 1 ", dtc.toString()); } @Test public void testGetComponentsContaining() { List components = struct.getComponentsContaining(4); - assertEquals("[ 2 3 dword 4 field3 null]", components.toString()); + assertEquals("[ 2 3 dword 4 field3 ]", components.toString()); struct.add(new ArrayDataType(CharDataType.dataType, 0, -1), "zarray1", null); struct.add(new LongDataType(), "field4", null); @@ -1651,7 +1651,7 @@ public class StructureDataTypeTest extends AbstractGTest { * pack(disabled) * Structure Test { * 0 byte 1 field1 "Comment1" - * 2 word 2 null "Comment2" + * 2 word 2 "Comment2" * 4 dword 4 field3 "" * 8 byte 1 field4 "Comment4" * 9 char[0] 0 zarray1 "" @@ -1663,14 +1663,14 @@ public class StructureDataTypeTest extends AbstractGTest { // DatatypeComponent.toString: components = struct.getComponentsContaining(9); - assertEquals("[ 5 9 char[0] 0 zarray1 null, 6 9 undefined 1 null null]", + assertEquals("[ 5 9 char[0] 0 zarray1 , 6 9 undefined 1 ]", components.toString()); components = struct.getComponentsContaining(10); - assertEquals("[ 7 10 undefined 1 null null]", components.toString()); + assertEquals("[ 7 10 undefined 1 ]", components.toString()); components = struct.getComponentsContaining(16); - assertEquals("[ 10 16 long[0] 0 zarray2 null]", components.toString()); + assertEquals("[ 10 16 long[0] 0 zarray2 ]", components.toString()); } @@ -1953,14 +1953,14 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure TestStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + -// " 8 undefined 1 null \"\"\n" + +// " 8 undefined 1 \"\"\n" + " 9 Foo:4(0) 1 MyBit1 \"bitComment1\"\n" + " 9 Foo:3(4) 1 MyBit2 \"bitComment2\"\n" + " 9 Foo:2(7) 2 MyBit3 \"bitComment3\"\n" + -// " 11 undefined 1 null \"\"\n" + +// " 11 undefined 1 \"\"\n" + " 12 Foo[0] 0 myFlex \"flexComment\"\n" + "}\n" + "Size = 12 Actual Alignment = 1", struct); @@ -1978,14 +1978,14 @@ public class StructureDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Structure bigStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + -// " 8 undefined 1 null \"\"\n" + +// " 8 undefined 1 \"\"\n" + " 9 Foo:4(0) 1 MyBit1 \"bitComment1\"\n" + " 9 Foo:3(4) 1 MyBit2 \"bitComment2\"\n" + " 9 Foo:2(7) 2 MyBit3 \"bitComment3\"\n" + -// " 11 undefined 1 null \"\"\n" + +// " 11 undefined 1 \"\"\n" + " 12 Foo[0] 0 myFlex \"flexComment\"\n" + "}\n" + "Size = 12 Actual Alignment = 1", newStruct); diff --git a/Ghidra/Features/Base/src/test/java/ghidra/program/model/data/UnionDataTypeTest.java b/Ghidra/Features/Base/src/test/java/ghidra/program/model/data/UnionDataTypeTest.java index 0937e2fc48..ddfbe019c8 100644 --- a/Ghidra/Features/Base/src/test/java/ghidra/program/model/data/UnionDataTypeTest.java +++ b/Ghidra/Features/Base/src/test/java/ghidra/program/model/data/UnionDataTypeTest.java @@ -152,7 +152,7 @@ public class UnionDataTypeTest extends AbstractGTest { CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" + "pack(disabled)\n" + "Union TestUnion {\n" + - " 0 short 2 null \"\"\n" + + " 0 short 2 \"\"\n" + " 0 int:2(0) 1 bf1 \"bf1Comment\"\n" + "}\n" + "Size = 2 Actual Alignment = 1", union); @@ -174,7 +174,7 @@ public class UnionDataTypeTest extends AbstractGTest { CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" + "pack()\n" + "Union TestUnion {\n" + - " 0 short 2 null \"\"\n" + + " 0 short 2 \"\"\n" + " 0 int:2(0) 1 bf1 \"bf1Comment\"\n" + "}\n" + "Size = 4 Actual Alignment = 4", union); @@ -192,7 +192,7 @@ public class UnionDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 int:4(0) 1 bf1 \"bf1Comment\"\n" + " 0 byte:4(0) 1 bf2 \"bf2Comment\"\n" + " 0 dword 4 field3 \"\"\n" + @@ -215,7 +215,7 @@ public class UnionDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 int:4(4) 1 bf1 \"bf1Comment\"\n" + " 0 byte:4(4) 1 bf2 \"bf2Comment\"\n" + " 0 dword 4 field3 \"\"\n" + @@ -272,10 +272,10 @@ public class UnionDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 dword 4 field3 \"\"\n" + " 0 byte 1 field4 \"Comment4\"\n" + - " 0 struct_1 11 null \"\"\n" + + " 0 struct_1 11 \"\"\n" + "}\n" + "Size = 11 Actual Alignment = 1", union); //@formatter:on @@ -288,7 +288,7 @@ public class UnionDataTypeTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 byte 1 field4 \"Comment4\"\n" + "}\n" + "Size = 2 Actual Alignment = 1", union); diff --git a/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb/CompositeMemberTest.java b/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb/CompositeMemberTest.java index 8fe4a8b13d..f0d2e6acb4 100644 --- a/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb/CompositeMemberTest.java +++ b/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb/CompositeMemberTest.java @@ -224,7 +224,7 @@ public class CompositeMemberTest extends AbstractGhidraHeadlessIntegrationTest "/struct\n" + "pack()\n" + "Structure struct {\n" + - " 0 struct_u_0 1 null \"\"\n" + + " 0 struct_u_0 1 \"\"\n" + "}\n" + "Size = 1 Actual Alignment = 1\n" + "/struct/struct_u_0\n" + @@ -508,8 +508,8 @@ public class CompositeMemberTest extends AbstractGhidraHeadlessIntegrationTest "/struct\n" + "pack()\n" + "Structure struct {\n" + - " 0 struct_u_0 1 null \"\"\n" + - " 8 struct_u_8 8 null \"\"\n" + + " 0 struct_u_0 1 \"\"\n" + + " 8 struct_u_8 8 \"\"\n" + "}\n" + "Size = 16 Actual Alignment = 8\n" + "/struct/struct_u_0\n" + @@ -702,11 +702,11 @@ public class CompositeMemberTest extends AbstractGhidraHeadlessIntegrationTest "/MoreComplicated_s\n" + "pack()\n" + "Structure MoreComplicated_s {\n" + - " 0 MoreComplicated_s_u_0 1 null \"\"\n" + - " 8 MoreComplicated_s_u_8 8 null \"\"\n" + - " 16 MoreComplicated_s_u_16 16 null \"\"\n" + + " 0 MoreComplicated_s_u_0 1 \"\"\n" + + " 8 MoreComplicated_s_u_8 8 \"\"\n" + + " 16 MoreComplicated_s_u_16 16 \"\"\n" + " 32 char[10] 10 beef \"\"\n" + - " 44 MoreComplicated_s_u_44 12 null \"\"\n" + + " 44 MoreComplicated_s_u_44 12 \"\"\n" + "}\n" + "Size = 56 Actual Alignment = 8\n" + "/MoreComplicated_s/MoreComplicated_s_u_0\n" + diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeComponentDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeComponentDB.java index 67d3dc89f5..4ddf4d2350 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeComponentDB.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeComponentDB.java @@ -208,10 +208,7 @@ class DataTypeComponentDB implements InternalDataTypeComponent { @Override public String getFieldName() { - if (isZeroBitFieldComponent()) { - return ""; - } - if (record != null) { + if (record != null && !isZeroBitFieldComponent()) { return record.getString(ComponentDBAdapter.COMPONENT_FIELD_NAME_COL); } return null; diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedStructureInspector.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedStructureInspector.java index 54bcd669cb..662b654a47 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedStructureInspector.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedStructureInspector.java @@ -133,10 +133,7 @@ public class AlignedStructureInspector extends AlignedStructurePacker { @Override public String getDefaultFieldName() { - if (isZeroBitFieldComponent()) { - return ""; - } - return DEFAULT_FIELD_NAME_PREFIX + "_0x" + Integer.toHexString(getOffset()); + return component.getDefaultFieldName(); } @Override diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/CompositeInternal.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/CompositeInternal.java index e397e171e5..dcaeab0d78 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/CompositeInternal.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/CompositeInternal.java @@ -195,7 +195,11 @@ public interface CompositeInternal extends Composite { buffer.append(")"); } buffer.append(pad + dtc.getLength()); - buffer.append(pad + dtc.getFieldName()); + String name = dtc.getFieldName(); + if (name == null) { + name = ""; + } + buffer.append(pad + name); String comment = dtc.getComment(); if (comment == null) { comment = ""; diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataTypeComponent.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataTypeComponent.java index d80521721f..121d33eeb7 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataTypeComponent.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataTypeComponent.java @@ -100,8 +100,10 @@ public interface DataTypeComponent { public void setComment(String comment); /** - * Get the name of the field name as a component of a Data Type. - * @return the name as a component of another Data Type. + * Get this component's field name within its parent. + * If this method returns null {@link #getDefaultFieldName()} can be used to obtain a default + * generated field name. + * @return this component's field name within its parent or null if one has not been set. */ public String getFieldName(); @@ -118,12 +120,12 @@ public interface DataTypeComponent { public void setFieldName(String fieldName) throws DuplicateNameException; /** - * Returns a default Field name. Used only if a field name is not set. - * @return default field name + * Returns a default field name for this component. Used only if a field name is not set. + * @return default field name (may be null for nameless fields such as a zero-length bitfield). */ public default String getDefaultFieldName() { if (isZeroBitFieldComponent()) { - return ""; + return null; } String name = DEFAULT_FIELD_NAME_PREFIX + getOrdinal(); if (getParent() instanceof Structure) { diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataTypeComponentImpl.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataTypeComponentImpl.java index d979629820..f25861ccfc 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataTypeComponentImpl.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataTypeComponentImpl.java @@ -121,7 +121,7 @@ public class DataTypeComponentImpl implements InternalDataTypeComponent, Seriali @Override public String getFieldName() { if (isZeroBitFieldComponent()) { - return ""; + return null; } return fieldName; } diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/InternalDataTypeComponent.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/InternalDataTypeComponent.java index 540fd06305..4c03640b6e 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/InternalDataTypeComponent.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/InternalDataTypeComponent.java @@ -41,9 +41,13 @@ public interface InternalDataTypeComponent extends DataTypeComponent { buffer.append("(" + ((BitFieldDataType) c.getDataType()).getBitOffset() + ")"); } buffer.append(" " + c.getLength()); - buffer.append(" " + c.getFieldName()); + String name = c.getFieldName(); + if (name == null) { + name = ""; + } + buffer.append(" " + name); String cmt = c.getComment(); - buffer.append(" " + ((cmt != null) ? ("\"" + cmt + "\"") : cmt)); + buffer.append(" " + ((cmt != null) ? ("\"" + cmt + "\"") : "")); return buffer.toString(); } diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/ReadOnlyDataTypeComponent.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/ReadOnlyDataTypeComponent.java index 9c12719ad0..eba4b3e118 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/ReadOnlyDataTypeComponent.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/ReadOnlyDataTypeComponent.java @@ -113,11 +113,6 @@ public class ReadOnlyDataTypeComponent implements DataTypeComponent, Serializabl return fieldName; } - @Override - public String getDefaultFieldName() { - return "field_" + getOrdinal(); - } - @Override public void setFieldName(String fieldName) throws DuplicateNameException { // ignore - read-only diff --git a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/data/StructureDBTest.java b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/data/StructureDBTest.java index a9a34abf62..2f8fc607d4 100644 --- a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/data/StructureDBTest.java +++ b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/data/StructureDBTest.java @@ -526,7 +526,7 @@ public class StructureDBTest extends AbstractGTest { "pack()\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 2 word 2 null \"Comment2\"\n" + + " 2 word 2 \"Comment2\"\n" + " 4 byte 1 field4 \"Comment4\"\n" + " 5 char[0] 0 flex \"FlexComment\"\n" + "}\n" + @@ -541,7 +541,7 @@ public class StructureDBTest extends AbstractGTest { "pack()\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 2 word 2 null \"Comment2\"\n" + + " 2 word 2 \"Comment2\"\n" + " 4 byte 1 field4 \"Comment4\"\n" + " 8 int[0] 0 flex \"FlexComment\"\n" + "}\n" + @@ -568,7 +568,7 @@ public class StructureDBTest extends AbstractGTest { " 4 int:0(0) 0 \"zero bitfield 1\"\n" + " 4 int:3(0) 1 bf2 \"bf1Comment\"\n" + " 5 byte 1 field1 \"Comment1\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 byte 1 field4 \"Comment4\"\n" + "}\n" + "Size = 12 Actual Alignment = 4", struct); @@ -585,7 +585,7 @@ public class StructureDBTest extends AbstractGTest { " 4 int:0(0) 0 \"zero bitfield 2\"\n" + " 4 int:3(0) 1 bf2 \"bf1Comment\"\n" + " 5 byte 1 field1 \"Comment1\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 byte 1 field4 \"Comment4\"\n" + "}\n" + "Size = 12 Actual Alignment = 4", struct); @@ -602,13 +602,13 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + " 8 int:3(0) 1 bf1 \"bf1Comment\"\n" + -// " 9 undefined 1 null \"\"\n" + -// " 10 undefined 1 null \"\"\n" + -// " 11 undefined 1 null \"\"\n" + +// " 9 undefined 1 \"\"\n" + +// " 10 undefined 1 \"\"\n" + +// " 11 undefined 1 \"\"\n" + "}\n" + "Size = 12 Actual Alignment = 1", struct); //@formatter:on @@ -620,14 +620,14 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + " 8 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 8 int:3(3) 1 bf2 \"bf2Comment\"\n" + -// " 9 undefined 1 null \"\"\n" + -// " 10 undefined 1 null \"\"\n" + -// " 11 undefined 1 null \"\"\n" + +// " 9 undefined 1 \"\"\n" + +// " 10 undefined 1 \"\"\n" + +// " 11 undefined 1 \"\"\n" + "}\n" + "Size = 12 Actual Alignment = 1", struct); //@formatter:on @@ -639,14 +639,14 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + " 8 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 8 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 9 byte:3(0) 1 bf3 \"bf3Comment\"\n" + -// " 10 undefined 1 null \"\"\n" + -// " 11 undefined 1 null \"\"\n" + +// " 10 undefined 1 \"\"\n" + +// " 11 undefined 1 \"\"\n" + "}\n" + "Size = 12 Actual Alignment = 1", struct); //@formatter:on @@ -662,15 +662,15 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + -// " 8 undefined 1 null \"\"\n" + -// " 9 undefined 1 null \"\"\n" + +// " 8 undefined 1 \"\"\n" + +// " 9 undefined 1 \"\"\n" + " 10 int:3(0) 1 bf1 \"bf1Comment\"\n" + -// " 11 undefined 1 null \"\"\n" + -// " 12 undefined 1 null \"\"\n" + -// " 13 undefined 1 null \"\"\n" + +// " 11 undefined 1 \"\"\n" + +// " 12 undefined 1 \"\"\n" + +// " 13 undefined 1 \"\"\n" + "}\n" + "Size = 14 Actual Alignment = 1", struct); //@formatter:on @@ -682,16 +682,16 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + -// " 8 undefined 1 null \"\"\n" + -// " 9 undefined 1 null \"\"\n" + +// " 8 undefined 1 \"\"\n" + +// " 9 undefined 1 \"\"\n" + " 10 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 10 int:3(3) 1 bf2 \"bf2Comment\"\n" + -// " 11 undefined 1 null \"\"\n" + -// " 12 undefined 1 null \"\"\n" + -// " 13 undefined 1 null \"\"\n" + +// " 11 undefined 1 \"\"\n" + +// " 12 undefined 1 \"\"\n" + +// " 13 undefined 1 \"\"\n" + "}\n" + "Size = 14 Actual Alignment = 1", struct); //@formatter:on @@ -707,12 +707,12 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -726,13 +726,13 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -746,12 +746,12 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -774,12 +774,12 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -793,13 +793,13 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:0(0) 0 \"zero bitfield\"\n" + // field name discarded " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -828,12 +828,12 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(5) 1 bf1 \"bf1Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -847,13 +847,13 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(5) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(2) 1 bf2 \"bf2Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -867,12 +867,12 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(5) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(2) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(3) 3 bf3 \"bf3Comment\"\n" + -// " 5 undefined 1 null \"\"\n" + - " 6 word 2 null \"Comment2\"\n" + +// " 5 undefined 1 \"\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -886,12 +886,12 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(5) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(2) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(3) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(0) 2 bf4 \"bf4Comment\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -905,13 +905,13 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:0(7) 0 \"zero bitfield\"\n" + // field name discarded " 2 int:3(5) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(2) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(3) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(0) 2 bf4 \"bf4Comment\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -936,13 +936,13 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + - " 2 float 4 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + + " 2 float 4 \"\"\n" + " 6 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 6 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 6 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 8 int:11(5) 2 bf4 \"bf4Comment\"\n" + - " 10 word 2 null \"Comment2\"\n" + + " 10 word 2 \"Comment2\"\n" + " 12 dword 4 field3 \"\"\n" + " 16 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1167,7 +1167,7 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + " 8 Foo:4(0) 1 MyBit1 \"bitComment\"\n" + @@ -1184,12 +1184,12 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + -// " 8 undefined 1 null \"\"\n" + -// " 9 undefined 1 null \"\"\n" + -// " 10 undefined 1 null \"\"\n" + +// " 8 undefined 1 \"\"\n" + +// " 9 undefined 1 \"\"\n" + +// " 10 undefined 1 \"\"\n" + "}\n" + "Size = 11 Actual Alignment = 1", struct); //@formatter:on @@ -1212,7 +1212,7 @@ public class StructureDBTest extends AbstractGTest { "pack()\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 2 word 2 null \"Comment2\"\n" + + " 2 word 2 \"Comment2\"\n" + " 4 byte 1 field4 \"Comment4\"\n" + " 8 Foo[0] 0 flex \"FlexComment\"\n" + "}\n" + @@ -1231,7 +1231,7 @@ public class StructureDBTest extends AbstractGTest { "pack()\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 2 word 2 null \"Comment2\"\n" + + " 2 word 2 \"Comment2\"\n" + " 4 byte 1 field4 \"Comment4\"\n" + " 5 byte[0] 0 flex \"FlexComment\"\n" + "}\n" + @@ -1257,7 +1257,7 @@ public class StructureDBTest extends AbstractGTest { "pack()\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 2 word 2 null \"Comment2\"\n" + + " 2 word 2 \"Comment2\"\n" + " 4 dword 4 field3 \"\"\n" + " 8 byte 1 field4 \"Comment4\"\n" + " 9 Foo:4(0) 1 MyBit1 \"bitComment1\"\n" + @@ -1274,7 +1274,7 @@ public class StructureDBTest extends AbstractGTest { "pack()\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 2 word 2 null \"Comment2\"\n" + + " 2 word 2 \"Comment2\"\n" + " 4 dword 4 field3 \"\"\n" + " 8 byte 1 field4 \"Comment4\"\n" + " 9 char:4(0) 1 MyBit1 \"bitComment1\"\n" + @@ -1330,14 +1330,14 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + -// " 8 undefined 1 null \"\"\n" + +// " 8 undefined 1 \"\"\n" + " 9 Foo:4(0) 1 MyBit1 \"bitComment1\"\n" + " 9 Foo:3(4) 1 MyBit2 \"bitComment2\"\n" + " 9 Foo:2(7) 2 MyBit3 \"bitComment3\"\n" + -// " 11 undefined 1 null \"\"\n" + +// " 11 undefined 1 \"\"\n" + " 12 Foo[0] 0 myFlex \"flexComment\"\n" + "}\n" + "Size = 12 Actual Alignment = 1", struct); @@ -1354,14 +1354,14 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure bigStruct {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 1 word 2 null \"Comment2\"\n" + + " 1 word 2 \"Comment2\"\n" + " 3 dword 4 field3 \"\"\n" + " 7 byte 1 field4 \"Comment4\"\n" + -// " 8 undefined 1 null \"\"\n" + +// " 8 undefined 1 \"\"\n" + " 9 Foo:4(0) 1 MyBit1 \"bitComment1\"\n" + " 9 Foo:3(4) 1 MyBit2 \"bitComment2\"\n" + " 9 Foo:2(7) 2 MyBit3 \"bitComment3\"\n" + -// " 11 undefined 1 null \"\"\n" + +// " 11 undefined 1 \"\"\n" + " 12 Foo[0] 0 myFlex \"flexComment\"\n" + "}\n" + "Size = 12 Actual Alignment = 1", newStruct); @@ -1454,12 +1454,12 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1473,10 +1473,10 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + -// " 2 undefined 1 null \"\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + +// " 2 undefined 1 \"\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + " 5 dword 4 field3 \"\"\n" + " 9 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1504,12 +1504,12 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + - " 6 word 2 null \"Comment2\"\n" + + " 6 word 2 \"Comment2\"\n" + " 8 dword 4 field3 \"\"\n" + " 12 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1523,7 +1523,7 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:3(3) 1 bf2 \"bf2Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + @@ -1541,7 +1541,7 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + " 2 int:15(6) 3 bf3 \"bf3Comment\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + @@ -1558,9 +1558,9 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + +// " 3 undefined 1 \"\"\n" + " 4 int:11(5) 2 bf4 \"bf4Comment\"\n" + " 6 dword 4 field3 \"\"\n" + " 10 byte 1 field4 \"Comment4\"\n" + @@ -1575,11 +1575,11 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + " 2 int:3(0) 1 bf1 \"bf1Comment\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + " 6 dword 4 field3 \"\"\n" + " 10 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1593,11 +1593,11 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + -// " 2 undefined 1 null \"\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + -// " 5 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + +// " 2 undefined 1 \"\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + +// " 5 undefined 1 \"\"\n" + " 6 dword 4 field3 \"\"\n" + " 10 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1611,10 +1611,10 @@ public class StructureDBTest extends AbstractGTest { "pack(disabled)\n" + "Structure Test {\n" + " 0 byte 1 field1 \"Comment1\"\n" + -// " 1 undefined 1 null \"\"\n" + -// " 2 undefined 1 null \"\"\n" + -// " 3 undefined 1 null \"\"\n" + -// " 4 undefined 1 null \"\"\n" + +// " 1 undefined 1 \"\"\n" + +// " 2 undefined 1 \"\"\n" + +// " 3 undefined 1 \"\"\n" + +// " 4 undefined 1 \"\"\n" + " 5 dword 4 field3 \"\"\n" + " 9 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -1760,7 +1760,7 @@ public class StructureDBTest extends AbstractGTest { * pack(disabled) * Structure TestStruct { * 0 byte 1 field1 "Comment1" - * 1 word 2 null "Comment2" + * 1 word 2 "Comment2" * 3 dword 4 field3 "" * 7 byte 1 field4 "Comment4" * } @@ -1768,7 +1768,7 @@ public class StructureDBTest extends AbstractGTest { */ DataTypeComponent dtc = struct.getComponentAt(3); - assertEquals(" 2 3 dword 4 field3 null", dtc.toString()); + assertEquals(" 2 3 dword 4 field3 ", dtc.toString()); dtc = struct.getComponentAt(4); // offcut assertNull(dtc); @@ -1789,7 +1789,7 @@ public class StructureDBTest extends AbstractGTest { * pack(disabled) * Structure TestStruct { * 0 byte 1 field1 "Comment1" - * 1 word 2 null "Comment2" + * 1 word 2 "Comment2" * 3 dword 4 field3 "" * 7 byte 1 field4 "Comment4" * 8 char[0] 0 zarray1 "" @@ -1800,7 +1800,7 @@ public class StructureDBTest extends AbstractGTest { */ dtc = struct.getComponentAt(8); - assertEquals(" 5 8 long 4 field4 null", dtc.toString()); + assertEquals(" 5 8 long 4 field4 ", dtc.toString()); dtc = struct.getComponentAt(9); // offcut assertNull(dtc); @@ -1816,7 +1816,7 @@ public class StructureDBTest extends AbstractGTest { * pack(disabled) * Structure Test { * 0 byte 1 field1 "Comment1" - * 2 word 2 null "Comment2" + * 2 word 2 "Comment2" * 4 dword 4 field3 "" * 8 byte 1 field4 "Comment4" * 9 char[0] 0 zarray1 "" @@ -1834,14 +1834,14 @@ public class StructureDBTest extends AbstractGTest { struct.setPackingEnabled(false); dtc = struct.getComponentAt(9); // undefined at offset of zero-length component - assertEquals(" 5 9 undefined 1 null null", dtc.toString()); + assertEquals(" 5 9 undefined 1 ", dtc.toString()); } @Test public void testGetComponentContaining() { DataTypeComponent dtc = struct.getComponentContaining(4); - assertEquals(" 2 3 dword 4 field3 null", dtc.toString()); + assertEquals(" 2 3 dword 4 field3 ", dtc.toString()); assertEquals(8, struct.getLength()); @@ -1859,7 +1859,7 @@ public class StructureDBTest extends AbstractGTest { * pack(disabled) * Structure TestStruct { * 0 byte 1 field1 "Comment1" - * 1 word 2 null "Comment2" + * 1 word 2 "Comment2" * 3 dword 4 field3 "" * 7 byte 1 field4 "Comment4" * 8 char[0] 0 zarray1 "" @@ -1870,10 +1870,10 @@ public class StructureDBTest extends AbstractGTest { */ dtc = struct.getComponentContaining(8); - assertEquals(" 5 8 long 4 field4 null", dtc.toString()); + assertEquals(" 5 8 long 4 field4 ", dtc.toString()); dtc = struct.getComponentContaining(9); // offcut - assertEquals(" 5 8 long 4 field4 null", dtc.toString()); + assertEquals(" 5 8 long 4 field4 ", dtc.toString()); dtc = struct.getComponentContaining(12); // end-of-struct assertNull(dtc); @@ -1886,7 +1886,7 @@ public class StructureDBTest extends AbstractGTest { * pack(disabled) * Structure Test { * 0 byte 1 field1 "Comment1" - * 2 word 2 null "Comment2" + * 2 word 2 "Comment2" * 4 dword 4 field3 "" * 8 byte 1 field4 "Comment4" * 9 char[0] 0 zarray1 "" @@ -1904,14 +1904,14 @@ public class StructureDBTest extends AbstractGTest { struct.setPackingEnabled(false); dtc = struct.getComponentContaining(9); // undefined at offset of zero-length component - assertEquals(" 5 9 undefined 1 null null", dtc.toString()); + assertEquals(" 5 9 undefined 1 ", dtc.toString()); } @Test public void testGetComponentsContaining() { List components = struct.getComponentsContaining(4); - assertEquals("[ 2 3 dword 4 field3 null]", components.toString()); + assertEquals("[ 2 3 dword 4 field3 ]", components.toString()); struct.add(new ArrayDataType(CharDataType.dataType, 0, -1), "zarray1", null); struct.add(new LongDataType(), "field4", null); @@ -1928,7 +1928,7 @@ public class StructureDBTest extends AbstractGTest { * pack(disabled) * Structure Test { * 0 byte 1 field1 "Comment1" - * 2 word 2 null "Comment2" + * 2 word 2 "Comment2" * 4 dword 4 field3 "" * 8 byte 1 field4 "Comment4" * 9 char[0] 0 zarray1 "" @@ -1940,14 +1940,14 @@ public class StructureDBTest extends AbstractGTest { // DatatypeComponent.toString: components = struct.getComponentsContaining(9); - assertEquals("[ 5 9 char[0] 0 zarray1 null, 6 9 undefined 1 null null]", + assertEquals("[ 5 9 char[0] 0 zarray1 , 6 9 undefined 1 ]", components.toString()); components = struct.getComponentsContaining(10); - assertEquals("[ 7 10 undefined 1 null null]", components.toString()); + assertEquals("[ 7 10 undefined 1 ]", components.toString()); components = struct.getComponentsContaining(16); - assertEquals("[ 10 16 long[0] 0 zarray2 null]", components.toString()); + assertEquals("[ 10 16 long[0] 0 zarray2 ]", components.toString()); } diff --git a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/data/UnionDBTest.java b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/data/UnionDBTest.java index 2dce5112dc..6a0f1d6566 100644 --- a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/data/UnionDBTest.java +++ b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/data/UnionDBTest.java @@ -52,7 +52,7 @@ public class UnionDBTest extends AbstractGTest { private void transitionToBigEndian() { - Union unionClone = (Union) union.clone(null); + Union unionClone = union.clone(null); dataMgr.remove(union, TaskMonitor.DUMMY); DataOrganizationImpl dataOrg = (DataOrganizationImpl) dataMgr.getDataOrganization(); @@ -170,7 +170,7 @@ public class UnionDBTest extends AbstractGTest { CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" + "pack(disabled)\n" + "Union TestUnion {\n" + - " 0 short 2 null \"\"\n" + + " 0 short 2 \"\"\n" + " 0 int:2(0) 1 bf1 \"bf1Comment\"\n" + "}\n" + "Size = 2 Actual Alignment = 1", union); @@ -192,7 +192,7 @@ public class UnionDBTest extends AbstractGTest { CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" + "pack()\n" + "Union TestUnion {\n" + - " 0 short 2 null \"\"\n" + + " 0 short 2 \"\"\n" + " 0 int:2(0) 1 bf1 \"bf1Comment\"\n" + "}\n" + "Size = 4 Actual Alignment = 4", union); @@ -210,7 +210,7 @@ public class UnionDBTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 int:4(0) 1 bf1 \"bf1Comment\"\n" + " 0 byte:4(0) 1 bf2 \"bf2Comment\"\n" + " 0 dword 4 field3 \"\"\n" + @@ -233,7 +233,7 @@ public class UnionDBTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 int:4(4) 1 bf1 \"bf1Comment\"\n" + " 0 byte:4(4) 1 bf2 \"bf2Comment\"\n" + " 0 dword 4 field3 \"\"\n" + @@ -257,7 +257,7 @@ public class UnionDBTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 Foo:4(0) 1 bf1 \"bf1Comment\"\n" + " 0 Foo:4(0) 1 bf2 \"bf2Comment\"\n" + " 0 dword 4 field3 \"\"\n" + @@ -273,7 +273,7 @@ public class UnionDBTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 dword 4 field3 \"\"\n" + " 0 byte 1 field4 \"Comment4\"\n" + "}\n" + @@ -296,7 +296,7 @@ public class UnionDBTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 Foo:4(0) 1 bf1 \"bf1Comment\"\n" + " 0 Foo:4(0) 1 bf2 \"bf2Comment\"\n" + " 0 dword 4 field3 \"\"\n" + @@ -312,7 +312,7 @@ public class UnionDBTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 char:4(0) 1 bf1 \"bf1Comment\"\n" + " 0 char:4(0) 1 bf2 \"bf2Comment\"\n" + " 0 dword 4 field3 \"\"\n" + @@ -329,7 +329,7 @@ public class UnionDBTest extends AbstractGTest { @Test public void testCloneRetainIdentity() throws Exception { - Union unionCopy = (Union) union.clone(null); + Union unionCopy = union.clone(null); assertNull(unionCopy.getDataTypeManager()); assertEquals(4, union.getLength()); } @@ -369,10 +369,10 @@ public class UnionDBTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 dword 4 field3 \"\"\n" + " 0 byte 1 field4 \"Comment4\"\n" + - " 0 struct_1 11 null \"\"\n" + + " 0 struct_1 11 \"\"\n" + "}\n" + "Size = 11 Actual Alignment = 1", union); //@formatter:on @@ -385,7 +385,7 @@ public class UnionDBTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field1 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 byte 1 field4 \"Comment4\"\n" + "}\n" + "Size = 2 Actual Alignment = 1", union); @@ -426,7 +426,7 @@ public class UnionDBTest extends AbstractGTest { "pack(disabled)\n" + "Union Replaced {\n" + " 0 byte 1 field0 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 dword 4 field2 \"\"\n" + " 0 int:4(0) 1 MyBit1 \"bitComment1\"\n" + " 0 int:3(0) 1 MyBit2 \"bitComment2\"\n" + @@ -441,7 +441,7 @@ public class UnionDBTest extends AbstractGTest { "pack(disabled)\n" + "Union TestUnion {\n" + " 0 byte 1 field0 \"Comment1\"\n" + - " 0 word 2 null \"Comment2\"\n" + + " 0 word 2 \"Comment2\"\n" + " 0 dword 4 field2 \"\"\n" + " 0 int:4(0) 1 MyBit1 \"bitComment1\"\n" + " 0 int:3(0) 1 MyBit2 \"bitComment2\"\n" +