GP-301 PDB - use consistent anonymous function naming with DWARF. Helps

to reduce datatype conflicts.
This commit is contained in:
ghidra1 2020-10-26 19:25:57 -04:00
parent 0086c4c77a
commit f7e219b96a
7 changed files with 156 additions and 67 deletions

View file

@ -38,7 +38,7 @@ public class PdbCategories {
private CategoryPath baseModuleTypedefsCategory;
private List<CategoryPath> typedefCategories = new ArrayList<>();
private int anonymousFunctionCount;
// private int anonymousFunctionCount;
//==============================================================================================
// NOTE: a TODO could be to add optional GUID and AGE values. This could be as sub-categories
@ -59,7 +59,7 @@ public class PdbCategories {
setTypedefCategoryPaths(moduleNames);
anonymousFunctionsCategory = new CategoryPath(pdbRootCategory, "!_anon_funcs_");
anonymousFunctionCount = 0;
// anonymousFunctionCount = 0;
anonymousTypesCategory = new CategoryPath(pdbRootCategory, "!_anon_types_");
}
@ -190,22 +190,22 @@ public class PdbCategories {
return anonymousTypesCategory;
}
/**
* Returns the name of what should be the next Anonymous Function (based on the count of
* the number of anonymous functions) so that there is a unique name for the function.
* @return the name for the next anonymous function.
*/
public String getNextAnonymousFunctionName() {
return String.format("_func_%08X", anonymousFunctionCount);
}
/**
* Updates the count of the anonymous functions. This is a separate call from
* {@link #getNextAnonymousFunctionName()} because the count should only be updated after
* the previous anonymous function has been successfully created/stored.
*/
public void incrementNextAnonymousFunctionName() {
anonymousFunctionCount++;
}
// /**
// * Returns the name of what should be the next Anonymous Function (based on the count of
// * the number of anonymous functions) so that there is a unique name for the function.
// * @return the name for the next anonymous function.
// */
// public String getNextAnonymousFunctionName() {
// return String.format("_func_%08X", anonymousFunctionCount);
// }
//
// /**
// * Updates the count of the anonymous functions. This is a separate call from
// * {@link #getNextAnonymousFunctionName()} because the count should only be updated after
// * the previous anonymous function has been successfully created/stored.
// */
// public void incrementNextAnonymousFunctionName() {
// anonymousFunctionCount++;
// }
}

View file

@ -15,6 +15,7 @@
*/
package ghidra.app.util.pdb.pdbapplicator;
import ghidra.app.util.DataTypeNamingUtil;
import ghidra.app.util.bin.format.pdb2.pdbreader.PdbException;
import ghidra.app.util.bin.format.pdb2.pdbreader.RecordNumber;
import ghidra.app.util.bin.format.pdb2.pdbreader.type.AbstractMsType;
@ -42,12 +43,12 @@ public abstract class AbstractFunctionTypeApplier extends MsTypeApplier {
*/
public AbstractFunctionTypeApplier(PdbApplicator applicator, AbstractMsType msType) {
super(applicator, msType);
String funcName = applicator.getNextAnonymousFunctionName();
// String funcName = applicator.getNextAnonymousFunctionName();
functionDefinition = new FunctionDefinitionDataType(
applicator.getAnonymousFunctionsCategory(), funcName, applicator.getDataTypeManager());
applicator.getAnonymousFunctionsCategory(), "_func", applicator.getDataTypeManager());
// Updating before trying to apply... if applyFunction fails, then this name will go
// unused for the most part, but we also will not get a conflict on the name.
applicator.incrementNextAnonymousFunctionName();
// applicator.incrementNextAnonymousFunctionName();
dataType = functionDefinition;
}
@ -191,7 +192,13 @@ public abstract class AbstractFunctionTypeApplier extends MsTypeApplier {
argsListApplier.applyTo(this);
}
setCallingConvention(applicator, callingConvention, hasThisPointer);
DataTypeNamingUtil.setMangledAnonymousFunctionName(functionDefinition, "_func");
setApplied();
// resolvedDataType = applicator.resolveHighUse(dataType);
// if (resolvedDataType != null) {
// resolved = true;
// }
}
private boolean setReturnType() {

View file

@ -516,23 +516,23 @@ public class PdbApplicator {
return categoryUtils.getAnonymousTypesCategory();
}
/**
* Returns the name of what should be the next Anonymous Function (based on the count of
* the number of anonymous functions) so that there is a unique name for the function.
* @return the name for the next anonymous function.
*/
String getNextAnonymousFunctionName() {
return categoryUtils.getNextAnonymousFunctionName();
}
// /**
// * Returns the name of what should be the next Anonymous Function (based on the count of
// * the number of anonymous functions) so that there is a unique name for the function.
// * @return the name for the next anonymous function.
// */
// String getNextAnonymousFunctionName() {
// return categoryUtils.getNextAnonymousFunctionName();
// }
/**
* Updates the count of the anonymous functions. This is a separate call from
* {@link #getNextAnonymousFunctionName()} because the count should only be updated after
* the previous anonymous function has been successfully created/stored.
*/
void incrementNextAnonymousFunctionName() {
categoryUtils.incrementNextAnonymousFunctionName();
}
// /**
// * Updates the count of the anonymous functions. This is a separate call from
// * {@link #getNextAnonymousFunctionName()} because the count should only be updated after
// * the previous anonymous function has been successfully created/stored.
// */
// void incrementNextAnonymousFunctionName() {
// categoryUtils.incrementNextAnonymousFunctionName();
// }
private PdbCategories setPdbCatogoryUtils(String pdbFilename)
throws CancelledException, PdbException {