mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
Merge remote-tracking branch 'origin/GT-2974_ghizard_PDB_Analyzer_using_new_CategoryPath_forward_slash_capability'
This commit is contained in:
commit
fc488d80b2
2 changed files with 38 additions and 12 deletions
|
@ -19,6 +19,7 @@ import java.util.*;
|
|||
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import ghidra.app.util.SymbolPath;
|
||||
import ghidra.app.util.bin.format.pdb.PdbParserNEW.PdbXmlMember;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.graph.*;
|
||||
|
@ -110,9 +111,10 @@ public class ApplyDataTypes {
|
|||
|
||||
// namespace qualified name used for cache lookups
|
||||
DataType cachedDataType = pdbParser.getCachedDataType(compositeDefinition.name);
|
||||
SymbolPath symbolPath = new SymbolPath(compositeDefinition.name);
|
||||
if (!(cachedDataType instanceof Composite) ||
|
||||
!cachedDataType.getCategoryPath().equals(
|
||||
pdbParser.getCategory(compositeDefinition.name, true)) ||
|
||||
pdbParser.getCategory(symbolPath.getParent(), true)) ||
|
||||
!pdbParser.isCorrectKind(cachedDataType, compositeDefinition.kind)) {
|
||||
log.appendMsg("Error: Conflicting data type name: " + compositeDefinition.name);
|
||||
continue;
|
||||
|
@ -255,12 +257,15 @@ public class ApplyDataTypes {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
CompositeDefinition other = (CompositeDefinition) obj;
|
||||
return isClass == other.isClass && kind == other.kind && length == other.length &&
|
||||
SystemUtilities.isEqual(name, other.name);
|
||||
|
|
|
@ -84,7 +84,6 @@ public class PdbParserNEW {
|
|||
private PdbErrorReaderThread thread;
|
||||
private boolean parsed = false;
|
||||
|
||||
private String categoryPrefix;
|
||||
private CategoryPath pdbCategory;
|
||||
|
||||
/**
|
||||
|
@ -103,8 +102,7 @@ public class PdbParserNEW {
|
|||
public PdbParserNEW(File pdbFile, Program program, DataTypeManagerService service,
|
||||
PdbProgramAttributes programAttributes, boolean forceAnalysis, TaskMonitor monitor) {
|
||||
this.pdbFile = pdbFile;
|
||||
this.categoryPrefix = "/" + pdbFile.getName();
|
||||
this.pdbCategory = new CategoryPath(categoryPrefix);
|
||||
this.pdbCategory = new CategoryPath(CategoryPath.ROOT, pdbFile.getName());
|
||||
this.program = program;
|
||||
this.dataMgr = program.getDataTypeManager();
|
||||
this.service = service;
|
||||
|
@ -715,21 +713,26 @@ public class PdbParserNEW {
|
|||
}
|
||||
|
||||
Structure createStructure(String name, int length) {
|
||||
return new StructureDataType(getCategory(name, true), stripNamespace(name), length,
|
||||
SymbolPath path = new SymbolPath(name);
|
||||
return new StructureDataType(getCategory(path.getParent(), true), path.getName(), length,
|
||||
dataMgr);
|
||||
}
|
||||
|
||||
Union createUnion(String name) {
|
||||
return new UnionDataType(getCategory(name, true), stripNamespace(name), dataMgr);
|
||||
SymbolPath path = new SymbolPath(name);
|
||||
return new UnionDataType(getCategory(path.getParent(), true), path.getName(), dataMgr);
|
||||
}
|
||||
|
||||
TypedefDataType createTypeDef(String name, DataType baseDataType) {
|
||||
return new TypedefDataType(getCategory(name, true), stripNamespace(name), baseDataType,
|
||||
dataMgr);
|
||||
SymbolPath path = new SymbolPath(name);
|
||||
return new TypedefDataType(getCategory(path.getParent(), true), path.getName(),
|
||||
baseDataType, dataMgr);
|
||||
}
|
||||
|
||||
EnumDataType createEnum(String name, int length) {
|
||||
return new EnumDataType(getCategory(name, true), stripNamespace(name), length, dataMgr);
|
||||
SymbolPath path = new SymbolPath(name);
|
||||
return new EnumDataType(getCategory(path.getParent(), true), path.getName(), length,
|
||||
dataMgr);
|
||||
}
|
||||
|
||||
void createString(boolean isUnicode, Address address, MessageLog log, TaskMonitor monitor) {
|
||||
|
@ -999,6 +1002,24 @@ public class PdbParserNEW {
|
|||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link CategoryPath} associated with the namespace specified by the
|
||||
* {@link SymbolPath}, rooting it either at the Category Path root or the PDB Category.
|
||||
* @param symbolPath the {@link SymbolPath} input; can be null if no depth in path.
|
||||
* @param addPdbRoot True if PDB root category should be used, otherwise it will be omitted.
|
||||
* @return {@link CategoryPath} created for the input.
|
||||
*/
|
||||
CategoryPath getCategory(SymbolPath symbolPath, boolean addPdbRoot) {
|
||||
CategoryPath category = addPdbRoot ? pdbCategory : CategoryPath.ROOT;
|
||||
if (symbolPath != null) {
|
||||
List<String> names = symbolPath.asList();
|
||||
for (String name : names) {
|
||||
category = new CategoryPath(category, name);
|
||||
}
|
||||
}
|
||||
return category;
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
/* STATIC METHODS */
|
||||
/********************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue