diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateFunctionCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateFunctionCmd.java index abfe214c04..a0a935b7d8 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateFunctionCmd.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateFunctionCmd.java @@ -22,12 +22,7 @@ import ghidra.framework.model.DomainObject; import ghidra.program.database.function.OverlappingFunctionException; import ghidra.program.model.address.*; import ghidra.program.model.block.*; -import ghidra.program.model.lang.Register; -import ghidra.program.model.lang.RegisterValue; import ghidra.program.model.listing.*; -import ghidra.program.model.mem.MemoryBlock; -import ghidra.program.model.pcode.PcodeOp; -import ghidra.program.model.pcode.Varnode; import ghidra.program.model.symbol.*; import ghidra.util.Msg; import ghidra.util.exception.*; @@ -202,7 +197,8 @@ public class CreateFunctionCmd extends BackgroundCommand { tmpSource = oldSym.getSource(); Namespace oldParentNamespace = oldSym.getParentNamespace(); // A function can't have another function as its parent. - if (oldParentNamespace.getSymbol().getSymbolType() != SymbolType.FUNCTION) { + if (oldParentNamespace.getSymbol() + .getSymbolType() != SymbolType.FUNCTION) { nameSpace = oldParentNamespace; } } @@ -354,7 +350,7 @@ public class CreateFunctionCmd extends BackgroundCommand { * @param body - body of function * @param nameSource - source of the name * @param bodyChangeMap - change map to restore other affected functions bodies if this fails - * @param monitor + * @param monitor task monitor * @return * @throws OverlappingFunctionException * @throws DuplicateNameException @@ -403,7 +399,7 @@ public class CreateFunctionCmd extends BackgroundCommand { * @param entry - entry point of new function * @param body - new functions body * @param bodyChangeMap - map of functions that have their bodies changed by creating this function - * @param monitor + * @param monitor task monitor * @return * @throws CancelledException * @throws OverlappingFunctionException @@ -435,7 +431,7 @@ public class CreateFunctionCmd extends BackgroundCommand { * * @param entry * @param body - * @param monitor + * @param monitor task monitor * @return the new body, or null if body could not be created and need to abort function creation. * * @throws CancelledException @@ -498,7 +494,7 @@ public class CreateFunctionCmd extends BackgroundCommand { * * @param entry function entry point to check for thunk * @param body new function body - * @param monitor + * @param monitor task monitor * @return true if the entry resolved to a thunk * * @throws OverlappingFunctionException @@ -506,7 +502,8 @@ public class CreateFunctionCmd extends BackgroundCommand { private boolean resolveThunk(Address entry, AddressSetView body, TaskMonitor monitor) throws OverlappingFunctionException { - Address thunkedAddr = CreateThunkFunctionCmd.getThunkedExternalFunctionAddress(program, entry); + Address thunkedAddr = + CreateThunkFunctionCmd.getThunkedExternalFunctionAddress(program, entry); if (thunkedAddr == null) { thunkedAddr = CreateThunkFunctionCmd.getThunkedAddr(program, entry); } @@ -591,6 +588,7 @@ public class CreateFunctionCmd extends BackgroundCommand { /** * Find the function body by following all flows other than a call from the * entry point. + * @param monitor task monitor * @param program the program where the function is being created. * @param entry entry point to start tracing flow * @@ -650,6 +648,7 @@ public class CreateFunctionCmd extends BackgroundCommand { * @param monitor task monitor * @return true if successful, false if cancelled or unable to fixup function or * no function found containing the start address of the indicated instruction + * @throws CancelledException if the function fixup is cancelled. */ public static boolean fixupFunctionBody(Program program, Instruction start_inst, TaskMonitor monitor) throws CancelledException { @@ -680,7 +679,8 @@ public class CreateFunctionCmd extends BackgroundCommand { AddressSetView newBody = getFunctionBody(program, entry, false, monitor); // function could now be a thunk, since someone is calling this because of a potential body flow change - if (!func.isThunk() && resolveThunk(program, entry, newBody, monitor)) { + if (func.getSignatureSource() == SourceType.DEFAULT && !func.isThunk() && + resolveThunk(program, entry, newBody, monitor)) { // function flow might have changed, and could now be a thunk, without the body changing. // don't worry about it below, because if there is an overlapping body, something strange // going on, and the function should still be a thunk diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/Module.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/Module.java index 31178b221f..6206b4340a 100644 --- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/Module.java +++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/Module.java @@ -339,6 +339,7 @@ public class Module { pdb.checkCanceled(); AbstractMsSymbol symbol = symbolIterator.next(); writer.append(symbol.toString()); + writer.append("\n"); } writer.write("End Symbols-------------------------------------------------\n"); } diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/TypeProgramInterface.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/TypeProgramInterface.java index 346599b13b..b77d77559e 100644 --- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/TypeProgramInterface.java +++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/TypeProgramInterface.java @@ -118,7 +118,7 @@ public abstract class TypeProgramInterface implements TPI { /** * Retrieves the {@link AbstractMsType} record indicated by the recordNumber. The record must * already have been parsed and inserted into the list - * @param recordNumber Rrcord number to look up + * @param recordNumber record number to look up * @return {@link AbstractMsType} pertaining to the record number */ @Override diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/symbol/AbstractCompile2MsSymbol.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/symbol/AbstractCompile2MsSymbol.java index 8fee03bef5..6734ec6c69 100644 --- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/symbol/AbstractCompile2MsSymbol.java +++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/symbol/AbstractCompile2MsSymbol.java @@ -257,7 +257,7 @@ public abstract class AbstractCompile2MsSymbol extends AbstractMsSymbol { builder.append( "\n Compiled for edit and continue: " + (compiledForEditAndContinue ? "yes" : "no")); builder.append( - "\n Compiled withoug debugging info: " + (notCompiledWithDebugInfo ? "yes" : "no")); + "\n Compiled without debugging info: " + (notCompiledWithDebugInfo ? "yes" : "no")); builder.append( "\n Compiled with LTCG: " + (compiledWithLinkTimeCodeGeneration ? "yes" : "no")); builder.append( diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/symbol/Compile3MsSymbol.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/symbol/Compile3MsSymbol.java index 077dd1b060..3e22ed0aa3 100644 --- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/symbol/Compile3MsSymbol.java +++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/symbol/Compile3MsSymbol.java @@ -287,7 +287,7 @@ public class Compile3MsSymbol extends AbstractMsSymbol { builder.append( "\n Compiled for edit and continue: " + (compiledForEditAndContinue ? "yes" : "no")); builder.append( - "\n Compiled withoug debugging info: " + (notCompiledWithDebugInfo ? "yes" : "no")); + "\n Compiled without debugging info: " + (notCompiledWithDebugInfo ? "yes" : "no")); builder.append( "\n Compiled with LTCG: " + (compiledWithLinkTimeCodeGeneration ? "yes" : "no")); builder.append( diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/FunctionSymbolApplier.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/FunctionSymbolApplier.java index f5f43c697f..484eac9c29 100644 --- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/FunctionSymbolApplier.java +++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/FunctionSymbolApplier.java @@ -252,14 +252,8 @@ public class FunctionSymbolApplier extends MsSymbolApplier { } private boolean applyFunction(TaskMonitor monitor) { - Listing listing = applicator.getProgram().getListing(); - applicator.createSymbol(address, getName(), true); - - function = listing.getFunctionAt(address); - if (function == null) { - function = createFunction(monitor); - } + function = createFunction(monitor); if (function == null) { return false; } diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/LabelSymbolApplier.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/LabelSymbolApplier.java index 7ece6ff033..aaa8e0e0fb 100644 --- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/LabelSymbolApplier.java +++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/LabelSymbolApplier.java @@ -142,14 +142,8 @@ public class LabelSymbolApplier extends MsSymbolApplier { } private boolean applyFunction(Address address, String name, TaskMonitor monitor) { - Listing listing = applicator.getProgram().getListing(); - applicator.createSymbol(address, name, true); - - function = listing.getFunctionAt(address); - if (function == null) { - function = createFunction(address, monitor); - } + function = createFunction(address, monitor); if (function == null) { return false; } diff --git a/Ghidra/Features/PDB/src/main/java/pdb/LoadPdbTask.java b/Ghidra/Features/PDB/src/main/java/pdb/LoadPdbTask.java index 166b5092a1..55855951e2 100644 --- a/Ghidra/Features/PDB/src/main/java/pdb/LoadPdbTask.java +++ b/Ghidra/Features/PDB/src/main/java/pdb/LoadPdbTask.java @@ -158,6 +158,8 @@ class LoadPdbTask extends Task { return false; } + // We need to kick off any byte analyzers (like getting import symbols), as they typically + // won't get kicked off by our loading of the PDB. private void scheduleAdditionalAnalysis() { AddressSetView addrs = program.getMemory(); @@ -169,16 +171,14 @@ class LoadPdbTask extends Task { scheduleDemangler(manager, analysisProperties, addrs); } - // DemanglerAnalyzer is a byte analyzer (like getting import symbols), so it won't get - // kicked off by our laying down symbols. private void scheduleDemangler(AutoAnalysisManager manager, Options analysisProperties, AddressSetView addrs) { MicrosoftDemanglerAnalyzer demanglerAnalyzer = new MicrosoftDemanglerAnalyzer(); String analyzerName = demanglerAnalyzer.getName(); - String defaultValueAsString = analysisProperties.getValueAsString(analyzerName); + String valueAsString = analysisProperties.getValueAsString(analyzerName); - // Do not demangle if the demangler analyzer is turned off - if (!Boolean.parseBoolean(defaultValueAsString)) { + // Only schedule analyzer if enabled + if (!Boolean.parseBoolean(valueAsString)) { return; } manager.scheduleOneTimeAnalysis(demanglerAnalyzer, addrs); diff --git a/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/DummyPdb700.java b/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/DummyPdb700.java index 929a265007..acef5afda9 100644 --- a/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/DummyPdb700.java +++ b/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/DummyPdb700.java @@ -55,7 +55,7 @@ public class DummyPdb700 extends Pdb700 { } /** - * Set @code true} to make existing debug information available; when set false, + * Set {@code true} to make existing debug information available; when set false, * {@link #getDebugInfo()} returns null (as though it does not exist) * @param setAvailable {@code true} to return actual value; @code false} to have it return null */ diff --git a/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/msf/StubMsf.java b/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/msf/StubMsf.java index d76a54b2c7..b9fbb92e1b 100644 --- a/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/msf/StubMsf.java +++ b/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/msf/StubMsf.java @@ -19,14 +19,14 @@ import java.io.IOException; import javax.help.UnsupportedOperationException; -import ghidra.app.util.bin.format.pdb2.pdbreader.*; +import ghidra.app.util.bin.format.pdb2.pdbreader.PdbByteReader; +import ghidra.app.util.bin.format.pdb2.pdbreader.PdbException; import ghidra.util.exception.CancelledException; import ghidra.util.task.TaskMonitor; /** - * This class is an extension of {@link Pdb700}, based on {@link AbstractPdb}, whose sole purpose - * is to allow for testing of internal components of {@link AbstractPdb} classes. It is not - * part of the production PDB Reader. + * This class is an extension of {@link Msf}, and has the sole purpose of stubbing the Msf for + * testing of internal components of PDB classes. */ public class StubMsf implements Msf {