Ghidra is a software reverse engineering (SRE) framework
GT-3112 - PDB Universal Reader/Analyzer - 116 commits
ghizard9a4e870875ba
diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/plugin/core/analysis/PdbUniversalAnalyzer.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/plugin/core/analysis/PdbUniversalAnalyzer.javaindex 8d9e579318..219a3e7ba3 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/plugin/core/analysis/PdbUniversalAnalyzer.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/plugin/core/analysis/PdbUniversalAnalyzer.java@@ -181,7 +181,7 @@ public class PdbUniversalAnalyzer extends AbstractAnalyzer {"If checked, attempts to apply function parameters and local variables for program functions.";private boolean applyFunctionVariables;- // Sets the composite layout choice.+ // Sets the composite layout.// Legacy// - similar to existing DIA-based PDB Analyzer, only placing current composite direct// members (none from parent classes.@@ -196,11 +196,11 @@ public class PdbUniversalAnalyzer extends AbstractAnalyzer {// Complex// - Puts all current class members and 'direct' parents' 'direct' components into an// encapsulating 'direct' container- private static final String OPTION_NAME_COMPOSITE_LAYOUT_CHOICE = "Composite Layout Choice";- private static final String OPTION_DESCRIPTION_COMPOSITE_LAYOUT_CHOICE =+ private static final String OPTION_NAME_COMPOSITE_LAYOUT = "Composite Layout Choice";+ private static final String OPTION_DESCRIPTION_COMPOSITE_LAYOUT ="Legacy layout like original PDB Analyzer. Warning: other choices have no compatibility" +" guarantee with future Ghidra releases or minor PDB Analyzer changes";- private ObjectOrientedClassLayoutChoice compositeLayoutChoice;+ private ObjectOrientedClassLayout compositeLayout;//==============================================================================================// Additional instance data@@ -397,8 +397,8 @@ public class PdbUniversalAnalyzer extends AbstractAnalyzer {OPTION_DESCRIPTION_ALLOW_DEMOTE_MANGLED_PRIMARY);options.registerOption(OPTION_NAME_APPLY_FUNCTION_VARIABLES, applyFunctionVariables,null, OPTION_DESCRIPTION_APPLY_FUNCTION_VARIABLES);- options.registerOption(OPTION_NAME_COMPOSITE_LAYOUT_CHOICE, compositeLayoutChoice, null,- OPTION_DESCRIPTION_COMPOSITE_LAYOUT_CHOICE);+ options.registerOption(OPTION_NAME_COMPOSITE_LAYOUT, compositeLayout, null,+ OPTION_DESCRIPTION_COMPOSITE_LAYOUT);}}@@ -464,8 +464,7 @@ public class PdbUniversalAnalyzer extends AbstractAnalyzer {OPTION_NAME_ALLOW_DEMOTE_MANGLED_PRIMARY, allowDemotePrimaryMangledSymbol);applyFunctionVariables =options.getBoolean(OPTION_NAME_APPLY_FUNCTION_VARIABLES, applyFunctionVariables);- compositeLayoutChoice =- options.getEnum(OPTION_NAME_COMPOSITE_LAYOUT_CHOICE, compositeLayoutChoice);+ compositeLayout = options.getEnum(OPTION_NAME_COMPOSITE_LAYOUT, compositeLayout);}setPdbApplicatorOptions();}@@ -565,7 +564,7 @@ public class PdbUniversalAnalyzer extends AbstractAnalyzer {allowDemotePrimaryMangledSymbol =PdbApplicatorOptions.DEFAULT_ALLOW_DEMOTE_PRIMARY_MANGLED_SYMBOLS;applyFunctionVariables = PdbApplicatorOptions.DEFAULT_APPLY_FUNCTION_VARIABLES;- compositeLayoutChoice = PdbApplicatorOptions.DEFAULT_CLASS_LAYOUT_CHOICE;+ compositeLayout = PdbApplicatorOptions.DEFAULT_CLASS_LAYOUT;}private void setPdbApplicatorOptions() {@@ -578,7 +577,7 @@ public class PdbUniversalAnalyzer extends AbstractAnalyzer {remapAddressUsingExistingPublicMangledSymbols);pdbApplicatorOptions.setAllowDemotePrimaryMangledSymbols(allowDemotePrimaryMangledSymbol);pdbApplicatorOptions.setApplyFunctionVariables(applyFunctionVariables);- pdbApplicatorOptions.setClassLayoutChoice(compositeLayoutChoice);+ pdbApplicatorOptions.setClassLayout(compositeLayout);}private boolean confirmDirectory(File path) {diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/BaseClassTypeApplier.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/BaseClassTypeApplier.javaindex b73f72eeae..696873cfda 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/BaseClassTypeApplier.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/BaseClassTypeApplier.java@@ -28,18 +28,6 @@ import ghidra.util.exception.CancelledException;*/public class BaseClassTypeApplier extends MsTypeApplier {- private static AbstractMsType validateType(AbstractMsType type)- throws IllegalArgumentException {- if (!(type instanceof AbstractBaseClassMsType) &&- !(type instanceof AbstractVirtualBaseClassMsType) &&- !(type instanceof AbstractIndirectVirtualBaseClassMsType)) {- throw new IllegalArgumentException(- "PDB Incorrectly applying " + type.getClass().getSimpleName() + " to " +- BaseClassTypeApplier.class.getSimpleName());- }- return type;- }-/*** Constructor for base class applier.* @param applicator {@link PdbApplicator} for which this class is working.@@ -144,4 +132,16 @@ public class BaseClassTypeApplier extends MsTypeApplier {// do nothing at the moment.}+ private static AbstractMsType validateType(AbstractMsType type)+ throws IllegalArgumentException {+ if (!(type instanceof AbstractBaseClassMsType) &&+ !(type instanceof AbstractVirtualBaseClassMsType) &&+ !(type instanceof AbstractIndirectVirtualBaseClassMsType)) {+ throw new IllegalArgumentException(+ "PDB Incorrectly applying " + type.getClass().getSimpleName() + " to " ++ BaseClassTypeApplier.class.getSimpleName());+ }+ return type;+ }+}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CompositeTypeApplier.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CompositeTypeApplier.javaindex 130daaba15..fa25c1540a 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CompositeTypeApplier.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CompositeTypeApplier.java@@ -46,7 +46,6 @@ public class CompositeTypeApplier extends AbstractComplexTypeApplier {private static boolean applyBaseClasses = true;//private static boolean applyBaseClasses = false;- private boolean isDeferred = false;private CppCompositeType classType;// private final static DataType NO_TYPE_DATATYPE =@@ -330,7 +329,7 @@ public class CompositeTypeApplier extends AbstractComplexTypeApplier {// TODO: Investigate. We should do this check for some classes somewhere. Should// we do it here. Set breakpoint here to investigate.}- classType.createLayout(applicator.getPdbApplicatorOptions().getClassLayoutChoice(),+ classType.createLayout(applicator.getPdbApplicatorOptions().getClassLayout(),applicator.getVbtManager(), applicator.getCancelOnlyWrappingMonitor());}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeType.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeType.javaindex df7247a2b1..13cbb5d41d 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeType.java@@ -51,7 +51,7 @@ public class CppCompositeType {private Composite composite;private CategoryPath categoryPath;- private ObjectOrientedClassLayout classLayout = ObjectOrientedClassLayout.UNKNOWN;+ private ObjectOrientedClassLayout classLayout = null;private List<ClassPdbMember> memberData;@@ -583,30 +583,31 @@ public class CppCompositeType {return builder.toString();}- public ObjectOrientedClassLayout getLayout(ObjectOrientedClassLayoutChoice layoutOptions) {- if (classLayout == ObjectOrientedClassLayout.UNKNOWN) {+ public ObjectOrientedClassLayout getLayout(+ ObjectOrientedClassLayout layoutOptions) {+ if (classLayout == null) {classLayout = determineClassLayout(layoutOptions);}return classLayout;}private ObjectOrientedClassLayout determineClassLayout(- ObjectOrientedClassLayoutChoice layoutOptions) {+ ObjectOrientedClassLayout layoutOptions) {ObjectOrientedClassLayout initialLayoutDetermination;- if (layoutOptions.getClassLayout() == ObjectOrientedClassLayout.MEMBERS_ONLY) {+ if (layoutOptions == ObjectOrientedClassLayout.MEMBERS_ONLY) {return ObjectOrientedClassLayout.MEMBERS_ONLY;}else if (getNumLayoutBaseClasses() == 0) {- initialLayoutDetermination = ObjectOrientedClassLayout.BASIC;+ initialLayoutDetermination = ObjectOrientedClassLayout.BASIC_SIMPLE_COMPLEX;}else if (getNumLayoutVirtualBaseClasses() == 0) {- initialLayoutDetermination = ObjectOrientedClassLayout.SIMPLE;+ initialLayoutDetermination = ObjectOrientedClassLayout.SIMPLE_COMPLEX;}else {initialLayoutDetermination = ObjectOrientedClassLayout.COMPLEX;}- ObjectOrientedClassLayout classLyoutOption = layoutOptions.getClassLayout();- return classLyoutOption.compareTo(initialLayoutDetermination) >= 0 ? classLyoutOption+ ObjectOrientedClassLayout classLayoutOption = layoutOptions;+ return classLayoutOption.compareTo(initialLayoutDetermination) >= 0 ? classLayoutOption: initialLayoutDetermination;}@@ -629,7 +630,7 @@ public class CppCompositeType {//----------------------------------------------------------------------------------------------//----------------------------------------------------------------------------------------------- public void createLayout(ObjectOrientedClassLayoutChoice layoutOptions, VbtManager vbtManager,+ public void createLayout(ObjectOrientedClassLayout layoutOptions, VbtManager vbtManager,TaskMonitor monitor) throws PdbException, CancelledException {if (vbtManager instanceof PdbVbtManager) { // Information from PDB/program symbols// TODO: both same for now@@ -643,7 +644,7 @@ public class CppCompositeType {//----------------------------------------------------------------------------------------------//----------------------------------------------------------------------------------------------- public void createVbtBasedLayout(ObjectOrientedClassLayoutChoice layoutOptions,+ public void createVbtBasedLayout(ObjectOrientedClassLayout layoutOptions,VbtManager vbtManager, TaskMonitor monitor) throws PdbException, CancelledException {CategoryPath cn;hasDirect = false;@@ -651,13 +652,13 @@ public class CppCompositeType {case MEMBERS_ONLY:addLayoutPdbMembers(memberData, layoutMembers);break;- case BASIC:+ case BASIC_SIMPLE_COMPLEX:addLayoutPdbMembers(memberData, layoutMembers);insertVirtualFunctionTablePointers(memberData);break;// TODO: evaluate... not really getting difference I thought we could get... so far// BASIC and SIMPLE seem to yield the same results. I might be doing something wrong.- case SIMPLE:+ case SIMPLE_COMPLEX:case COMPLEX:cn = createDirectCategoryPath(this);Composite directDataType = new StructureDataType(cn.getParent(), cn.getName(), 0,@@ -698,7 +699,8 @@ public class CppCompositeType {}directClassLength = getCompositeLength(directDataType);}- if (getLayout(layoutOptions) == ObjectOrientedClassLayout.SIMPLE) {+ if (getLayout(+ layoutOptions) == ObjectOrientedClassLayout.SIMPLE_COMPLEX) {// Not using the dummy/direct type (only used it to get the// directClassLength), so remove it and add the members to the main// type instead.@@ -768,7 +770,7 @@ public class CppCompositeType {//----------------------------------------------------------------------------------------------//----------------------------------------------------------------------------------------------- public void createSpeculativeLayout(ObjectOrientedClassLayoutChoice layoutOptions,+ public void createSpeculativeLayout(ObjectOrientedClassLayout layoutOptions,VbtManager vbtManager, TaskMonitor monitor) throws PdbException, CancelledException {// Speculative Layout uses recursion to try to know the order of members. However, MSFT// rearranges the order of the Base Class records such that they are not necessarily in@@ -783,14 +785,14 @@ public class CppCompositeType {case MEMBERS_ONLY:addLayoutPdbMembers(memberData, layoutMembers);break;- case BASIC:+ case BASIC_SIMPLE_COMPLEX:cn = composite.getCategoryPath();addLayoutPdbMembers(memberData, layoutMembers);insertVirtualFunctionTablePointers(memberData);break;// TODO: evaluate... not really getting difference I thought we could get... so far// BASIC and SIMPLE seem to yield the same results. I might be doing something wrong.- case SIMPLE:+ case SIMPLE_COMPLEX:case COMPLEX:cn = createDirectCategoryPath(this);Composite directDataType = new StructureDataType(cn.getParent(), cn.getName(), 0,@@ -834,7 +836,8 @@ public class CppCompositeType {}directClassLength = getCompositeLength(directDataType);}- if (getLayout(layoutOptions) == ObjectOrientedClassLayout.SIMPLE) {+ if (getLayout(+ layoutOptions) == ObjectOrientedClassLayout.SIMPLE_COMPLEX) {// Not using the dummy/direct type (only used it to get the// directClassLength), so remove it and add the members to the main// type instead.@@ -1349,7 +1352,8 @@ public class CppCompositeType {return attributes;}- ObjectOrientedClassLayout getLayoutMode(ObjectOrientedClassLayoutChoice layoutOptions) {+ ObjectOrientedClassLayout getLayoutMode(+ ObjectOrientedClassLayout layoutOptions) {return baseClassType.getLayout(layoutOptions);}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/NestedTypeApplier.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/NestedTypeApplier.javaindex 3efb7eaf80..bffd709ee3 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/NestedTypeApplier.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/NestedTypeApplier.java@@ -27,17 +27,8 @@ import ghidra.util.exception.CancelledException;* Applier for {@link AbstractNestedTypeMsType} and {@link AbstractNestedTypeExtMsType} types.*/public class NestedTypeApplier extends MsTypeApplier {- private MsTypeApplier nestedTypeDefinitionApplier = null;- private static AbstractMsType validateType(AbstractMsType type)- throws IllegalArgumentException {- if (!(type instanceof AbstractNestedTypeMsType) &&- !(type instanceof AbstractNestedTypeExtMsType)) {- throw new IllegalArgumentException("PDB Incorrectly applying " +- type.getClass().getSimpleName() + " to " + NestedTypeApplier.class.getSimpleName());- }- return type;- }+ private MsTypeApplier nestedTypeDefinitionApplier = null;/*** Constructor for nested type applier.@@ -168,4 +159,15 @@ public class NestedTypeApplier extends MsTypeApplier {MsTypeApplier getNestedTypeApplier() {return nestedTypeDefinitionApplier;}++ private static AbstractMsType validateType(AbstractMsType type)+ throws IllegalArgumentException {+ if (!(type instanceof AbstractNestedTypeMsType) &&+ !(type instanceof AbstractNestedTypeExtMsType)) {+ throw new IllegalArgumentException("PDB Incorrectly applying " ++ type.getClass().getSimpleName() + " to " + NestedTypeApplier.class.getSimpleName());+ }+ return type;+ }+}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ObjectOrientedClassLayout.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ObjectOrientedClassLayout.javaindex 9fc06a52af..f53b4bd7d1 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ObjectOrientedClassLayout.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ObjectOrientedClassLayout.java@@ -16,10 +16,30 @@package ghidra.app.util.pdb.pdbapplicator;/**- * Algorithm layout mechanism being used for a particular {@link CppCompositeType}. An initial- * value gets passed in to the algorithm but can be changed by the algorithm, based on class- * internal data.+ * PDB Analyzer user algorithmic choice for performing object oriented class layout.+ * <p>+ * Actual algorithms determination is as follows:+ * {@link #MEMBERS_ONLY} is a fixed setting. The others weigh the setting against the data+ * available in the class records. They all start out as {@link #COMPLEX} but fall back to a+ * more simplistic layout when the data permits:+ * <p> {@link #SIMPLE_COMPLEX} can fall back to "simple" and+ * <p> {@link #BASIC_SIMPLE_COMPLEX} can fall back to "simple" or "basic"*/-enum ObjectOrientedClassLayout {- UNKNOWN, MEMBERS_ONLY, BASIC, SIMPLE, COMPLEX+public enum ObjectOrientedClassLayout {+ MEMBERS_ONLY("Legacy"),+ BASIC_SIMPLE_COMPLEX("Complex with Basic Fallback"),+ SIMPLE_COMPLEX("Complex with Simple Fallback"),+ COMPLEX("Complex Always");++ private final String label;++ @Override+ public String toString() {+ return label;+ }++ private ObjectOrientedClassLayout(String label) {+ this.label = label;+ }+}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ObjectOrientedClassLayoutChoice.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ObjectOrientedClassLayoutChoice.javadeleted file mode 100644index feea4956c3..0000000000--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ObjectOrientedClassLayoutChoice.java+++ /dev/null@@ -1,56 +0,0 @@-/* ###- * IP: GHIDRA- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-package ghidra.app.util.pdb.pdbapplicator;--import java.util.HashMap;-import java.util.Map;--/**- * PDB Analyzer user algorithmic choice for performing object oriented class layout.- */-public enum ObjectOrientedClassLayoutChoice {- MEMBERS_ONLY("Legacy", 0, ObjectOrientedClassLayout.MEMBERS_ONLY),- BASIC_SIMPLE_COMPLEX("Complex with Basic Fallback", 1, ObjectOrientedClassLayout.BASIC),- SIMPLE_COMPLEX("Complex with Simple Fallback", 2, ObjectOrientedClassLayout.SIMPLE),- COMPLEX("Complex Always", 3, ObjectOrientedClassLayout.COMPLEX);-- private static final Map<Integer, ObjectOrientedClassLayoutChoice> BY_VALUE = new HashMap<>();- static {- for (ObjectOrientedClassLayoutChoice val : values()) {- BY_VALUE.put(val.value, val);- }- }-- private final String label;- private final int value;- private ObjectOrientedClassLayout classLayout;-- @Override- public String toString() {- return label;- }-- private ObjectOrientedClassLayoutChoice(String label, int value,- ObjectOrientedClassLayout classLayout) {- this.label = label;- this.value = value;- this.classLayout = classLayout;- }-- ObjectOrientedClassLayout getClassLayout() {- return classLayout;- }-}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbAddressManager.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbAddressManager.javaindex 4453964378..98f22a9dc4 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbAddressManager.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbAddressManager.java@@ -33,7 +33,7 @@ import ghidra.util.exception.CancelledException;*/public class PdbAddressManager {- private static final Address badAddress = Address.NO_ADDRESS; // using NO_ADDRESS as a marker+ private static final Address BAD_ADDRESS = Address.NO_ADDRESS; // using NO_ADDRESS as a marker//==============================================================================================private Map<Integer, Long> realAddressesBySection;@@ -306,10 +306,10 @@ public class PdbAddressManager {if (lookup == null) {remapAddressByAddress.put(address, remapAddress);}- else if (!lookup.equals(remapAddress) && lookup != badAddress) {+ else if (!lookup.equals(remapAddress) && lookup != BAD_ADDRESS) {applicator.appendLogMsg("Trying to map a mapped address to a new address... key: " +address + ", currentMap: " + lookup + ", newMap: " + remapAddress);- remapAddressByAddress.put(address, badAddress);+ remapAddressByAddress.put(address, BAD_ADDRESS);}}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicatorMetrics.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicatorMetrics.javaindex dd90917bcc..8e0f6942c6 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicatorMetrics.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicatorMetrics.java@@ -34,7 +34,7 @@ public class PdbApplicatorMetrics {* List of symbols seen (by their ID) as Global symbols.*///@formatter:off- private static final Set<Integer> expectedGlobalSymbols = Set.of(+ private static final Set<Integer> EXPECTED_GLOBAL_SYMBOLS = Set.of(// AbstractReferenceMsSymbolDataReferenceStMsSymbol.PDB_ID,DataReferenceMsSymbol.PDB_ID,@@ -79,7 +79,7 @@ public class PdbApplicatorMetrics {* List of symbols seen (by their ID) as Public symbols.*///@formatter:off- private static final Set<Integer> expectedLinkerSymbols = Set.of(+ private static final Set<Integer> EXPECTED_LINKER_SYMBOLS = Set.of(PeCoffSectionMsSymbol.PDB_ID,TrampolineMsSymbol.PDB_ID,ObjectNameMsSymbol.PDB_ID,@@ -123,7 +123,7 @@ public class PdbApplicatorMetrics {* @param symbol The symbol type witnessed.*/void witnessGlobalSymbolType(AbstractMsSymbol symbol) {- if (!expectedGlobalSymbols.contains(symbol.getPdbId())) {+ if (!EXPECTED_GLOBAL_SYMBOLS.contains(symbol.getPdbId())) {unexpectedGlobalSymbols.add(symbol.getClass());}}@@ -143,7 +143,7 @@ public class PdbApplicatorMetrics {* @param symbol The symbol type witnessed.*/void witnessLinkerSymbolType(AbstractMsSymbol symbol) {- if (!expectedLinkerSymbols.contains(symbol.getPdbId())) {+ if (!EXPECTED_LINKER_SYMBOLS.contains(symbol.getPdbId())) {// do nothing for now}}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicatorOptions.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicatorOptions.javaindex 44d71d276b..f6463ff54f 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicatorOptions.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicatorOptions.java@@ -34,14 +34,14 @@ public class PdbApplicatorOptions {// TODO: set the following to true if we come up with a reasonably good solutionpublic static final boolean DEFAULT_APPLY_FUNCTION_VARIABLES = false;- public static final ObjectOrientedClassLayoutChoice DEFAULT_CLASS_LAYOUT_CHOICE =- ObjectOrientedClassLayoutChoice.MEMBERS_ONLY;-// public static final OjbectOrientedClassLayoutChoice DEFAULT_CLASS_LAYOUT_CHOICE =-// OjbectOrientedClassLayoutChoice.BASIC_SIMPLE_COMPLEX;-// public static final OjbectOrientedClassLayoutChoice DEFAULT_CLASS_LAYOUT_CHOICE =-// OjbectOrientedClassLayoutChoice.SIMPLE_COMPLEX;-// public static final OjbectOrientedClassLayoutChoice DEFAULT_CLASS_LAYOUT_CHOICE =-// OjbectOrientedClassLayoutChoice.COMPLEX;+ public static final ObjectOrientedClassLayout DEFAULT_CLASS_LAYOUT =+ ObjectOrientedClassLayout.MEMBERS_ONLY;+// public static final OjbectOrientedClassLayout DEFAULT_CLASS_LAYOUT =+// ObjectOrientedClassLayout.BASIC_SIMPLE_COMPLEX;+// public static final OjbectOrientedClassLayout DEFAULT_CLASS_LAYOUT =+// ObjectOrientedClassLayout.SIMPLE_COMPLEX;+// public static final OjbectOrientedClassLayout DEFAULT_CLASS_LAYOUT =+// ObjectOrientedClassLayout.COMPLEX;//==============================================================================================private boolean applyCodeScopeBlockComments;@@ -53,7 +53,7 @@ public class PdbApplicatorOptions {private boolean applyFunctionVariables; // investigation. might produce bad results.- private ObjectOrientedClassLayoutChoice classLayoutChoice;+ private ObjectOrientedClassLayout classLayout;/*** Constructor@@ -73,7 +73,7 @@ public class PdbApplicatorOptions {remapAddressesUsingExistingPublicSymbols = DEFAULT_REMAP_ADDRESSES_USING_EXISTING_SYMBOLS;allowDemotePrimaryMangledSymbols = DEFAULT_ALLOW_DEMOTE_PRIMARY_MANGLED_SYMBOLS;applyFunctionVariables = DEFAULT_APPLY_FUNCTION_VARIABLES;- classLayoutChoice = DEFAULT_CLASS_LAYOUT_CHOICE;+ classLayout = DEFAULT_CLASS_LAYOUT;}/**@@ -196,18 +196,18 @@ public class PdbApplicatorOptions {/*** Set the class layout.- * @param classLayoutChoice composite layout choice+ * @param classLayout composite layout*/- public void setClassLayoutChoice(ObjectOrientedClassLayoutChoice classLayoutChoice) {- this.classLayoutChoice = classLayoutChoice;+ public void setClassLayout(ObjectOrientedClassLayout classLayout) {+ this.classLayout = classLayout;}/**- * Returns the choice for physically layout out classes.+ * Returns the physical layout out classes.* @return the class layout.*/- public ObjectOrientedClassLayoutChoice getClassLayoutChoice() {- return classLayoutChoice;+ public ObjectOrientedClassLayout getClassLayout() {+ return classLayout;}}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbRegisterNameToProgramRegisterMapper.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbRegisterNameToProgramRegisterMapper.javaindex 0d66a4df6f..db8676289d 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbRegisterNameToProgramRegisterMapper.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbRegisterNameToProgramRegisterMapper.java@@ -30,7 +30,7 @@ public class PdbRegisterNameToProgramRegisterMapper {// Only need to map names that are different (probably not counting case, as rsp and RSP// are equivalent.//@formatter:off- private static Map<String, String> registerNameMap = Map.of(+ private static final Map<String, String> REGISTER_NAME_MAP = Map.of(//"rsp", "RSP","fbp", "RBP");@@ -49,7 +49,7 @@ public class PdbRegisterNameToProgramRegisterMapper {if (register != null) {return register;}- String registerName = registerNameMap.get(pdbRegisterName);+ String registerName = REGISTER_NAME_MAP.get(pdbRegisterName);if (registerName == null) {registerName = pdbRegisterName;}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbResearch.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbResearch.javaindex 0a64a64229..2723897857 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbResearch.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbResearch.java@@ -41,6 +41,7 @@ public class PdbResearch {//==============================================================================================private static Set<Integer> debugIndexNumbers;+ private Set<Integer> developerDebugOrderIndexNumbers;//==============================================================================================/**@@ -333,8 +334,6 @@ public class PdbResearch {//==============================================================================================//==============================================================================================- private Set<Integer> developerDebugOrderIndexNumbers;-private void initDeveloperOrderRecordNumbers() {developerDebugOrderIndexNumbers = new TreeSet<>();diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/VirtualFunctionTablePointerTypeApplier.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/VirtualFunctionTablePointerTypeApplier.javaindex c096a6e7b6..cfcfab7680 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/VirtualFunctionTablePointerTypeApplier.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/VirtualFunctionTablePointerTypeApplier.java@@ -29,17 +29,6 @@ import ghidra.util.exception.CancelledException;*/public class VirtualFunctionTablePointerTypeApplier extends MsTypeApplier {- private static AbstractMsType validateType(AbstractMsType type)- throws IllegalArgumentException {- if (!(type instanceof AbstractVirtualFunctionTablePointerMsType) &&- !(type instanceof AbstractVirtualFunctionTablePointerWithOffsetMsType)) {- throw new IllegalArgumentException(- "PDB Incorrectly applying " + type.getClass().getSimpleName() + " to " +- VirtualFunctionTablePointerTypeApplier.class.getSimpleName());- }- return type;- }-/*** Constructor for enum type applier, for transforming a enum into a* Ghidra DataType.@@ -99,4 +88,15 @@ public class VirtualFunctionTablePointerTypeApplier extends MsTypeApplier {return null;}+ private static AbstractMsType validateType(AbstractMsType type)+ throws IllegalArgumentException {+ if (!(type instanceof AbstractVirtualFunctionTablePointerMsType) &&+ !(type instanceof AbstractVirtualFunctionTablePointerWithOffsetMsType)) {+ throw new IllegalArgumentException(+ "PDB Incorrectly applying " + type.getClass().getSimpleName() + " to " ++ VirtualFunctionTablePointerTypeApplier.class.getSimpleName());+ }+ return type;+ }+}diff --git a/Ghidra/Features/PDB/src/test/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeTypeTest.java b/Ghidra/Features/PDB/src/test/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeTypeTest.javaindex c30c5c8fdb..d1d4de31a1 100644--- a/Ghidra/Features/PDB/src/test/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeTypeTest.java+++ b/Ghidra/Features/PDB/src/test/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeTypeTest.java@@ -52,8 +52,8 @@ public class CppCompositeTypeTest extends AbstractGenericTest {private static VbtManager vbtManager32;private static VbtManager vbtManager64;// Note: Currently all test have expected results based on up the COMPLEX layout.- private static ObjectOrientedClassLayoutChoice classLayoutChoice =- ObjectOrientedClassLayoutChoice.COMPLEX;+ private static ObjectOrientedClassLayout classLayoutChoice =+ ObjectOrientedClassLayout.COMPLEX;static {BitFieldPackingImpl bitFieldPacking = new BitFieldPackingImpl();