mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/GP-5216_ghidra1_BSimApplySignature'
(Closes #7310)
This commit is contained in:
commit
87666d830b
5 changed files with 40 additions and 41 deletions
|
@ -22,11 +22,9 @@ import ghidra.app.cmd.function.ApplyFunctionSignatureCmd;
|
|||
import ghidra.app.cmd.function.FunctionRenameOption;
|
||||
import ghidra.framework.cmd.Command;
|
||||
import ghidra.framework.cmd.CompoundCmd;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.program.model.listing.FunctionSignature;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.symbol.SourceType;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -148,7 +146,7 @@ public class EditFunctionSignatureDialog extends AbstractEditFunctionSignatureDi
|
|||
@Override
|
||||
protected boolean applyChanges() throws CancelledException {
|
||||
// create the command
|
||||
Command command = createCommand();
|
||||
Command<Program> command = createCommand();
|
||||
|
||||
if (command == null) {
|
||||
return false;
|
||||
|
@ -164,9 +162,9 @@ public class EditFunctionSignatureDialog extends AbstractEditFunctionSignatureDi
|
|||
return true;
|
||||
}
|
||||
|
||||
private Command createCommand() throws CancelledException {
|
||||
private Command<Program> createCommand() throws CancelledException {
|
||||
|
||||
Command cmd = null;
|
||||
Command<Program> cmd = null;
|
||||
if (isSignatureChanged() || isCallingConventionChanged() ||
|
||||
(function.getSignatureSource() == SourceType.DEFAULT)) {
|
||||
|
||||
|
@ -179,20 +177,20 @@ public class EditFunctionSignatureDialog extends AbstractEditFunctionSignatureDi
|
|||
FunctionRenameOption.RENAME);
|
||||
}
|
||||
|
||||
CompoundCmd compoundCommand = new CompoundCmd("Update Function Signature");
|
||||
CompoundCmd<Program> compoundCommand = new CompoundCmd<>("Update Function Signature");
|
||||
|
||||
compoundCommand.add(new Command() {
|
||||
compoundCommand.add(new Command<Program>() {
|
||||
String errMsg = null;
|
||||
|
||||
@Override
|
||||
public boolean applyTo(DomainObject obj) {
|
||||
public boolean applyTo(Program p) {
|
||||
try {
|
||||
String conventionName = getCallingConvention();
|
||||
function.setCallingConvention(conventionName);
|
||||
return true;
|
||||
}
|
||||
catch (InvalidInputException e) {
|
||||
errMsg = "Invalid calling convention. " + e.getMessage();
|
||||
errMsg = e.getMessage();
|
||||
Msg.error(this, "Unexpected Exception: " + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
|
@ -209,9 +207,9 @@ public class EditFunctionSignatureDialog extends AbstractEditFunctionSignatureDi
|
|||
}
|
||||
});
|
||||
if (allowInLine) {
|
||||
compoundCommand.add(new Command() {
|
||||
compoundCommand.add(new Command<Program>() {
|
||||
@Override
|
||||
public boolean applyTo(DomainObject obj) {
|
||||
public boolean applyTo(Program p) {
|
||||
function.setInline(isInlineSelected());
|
||||
return true;
|
||||
}
|
||||
|
@ -228,9 +226,9 @@ public class EditFunctionSignatureDialog extends AbstractEditFunctionSignatureDi
|
|||
});
|
||||
}
|
||||
if (allowNoReturn) {
|
||||
compoundCommand.add(new Command() {
|
||||
compoundCommand.add(new Command<Program>() {
|
||||
@Override
|
||||
public boolean applyTo(DomainObject obj) {
|
||||
public boolean applyTo(Program p) {
|
||||
function.setNoReturn(hasNoReturnSelected());
|
||||
return true;
|
||||
}
|
||||
|
@ -247,9 +245,9 @@ public class EditFunctionSignatureDialog extends AbstractEditFunctionSignatureDi
|
|||
});
|
||||
}
|
||||
if (allowCallFixup) {
|
||||
compoundCommand.add(new Command() {
|
||||
compoundCommand.add(new Command<Program>() {
|
||||
@Override
|
||||
public boolean applyTo(DomainObject obj) {
|
||||
public boolean applyTo(Program p) {
|
||||
function.setCallFixup(getCallFixupSelection());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -380,7 +380,17 @@ public class FunctionUtility {
|
|||
if (CompilerSpec.CALLING_CONVENTION_thiscall.equals(sourceConv)) {
|
||||
return sourceConv;
|
||||
}
|
||||
return sameLanguageAndCompilerSpec ? sourceFunction.getCallingConventionName()
|
||||
boolean applyConventionName = sameLanguageAndCompilerSpec;
|
||||
if (applyConventionName) {
|
||||
DataTypeManager dtMgr = destinationFunction.getProgram().getDataTypeManager();
|
||||
String name = destinationFunction.getCallingConventionName();
|
||||
if (GenericCallingConvention
|
||||
.getGenericCallingConvention(name) == GenericCallingConvention.unknown &&
|
||||
!dtMgr.getKnownCallingConventionNames().contains(name)) {
|
||||
applyConventionName = false;
|
||||
}
|
||||
}
|
||||
return applyConventionName ? sourceFunction.getCallingConventionName()
|
||||
: destinationFunction.getCallingConventionName();
|
||||
}
|
||||
|
||||
|
|
|
@ -314,8 +314,8 @@ public class DecompilerParameterIdCmd extends BackgroundCommand<Program> {
|
|||
func.setCallingConvention(CompilerSpec.CALLING_CONVENTION_cdecl);
|
||||
}
|
||||
catch (InvalidInputException e) {
|
||||
setStatusMsg("Invalid Calling Convention " + CompilerSpec.CALLING_CONVENTION_cdecl +
|
||||
" : " + e);
|
||||
setStatusMsg(
|
||||
"Unknown calling convention: " + CompilerSpec.CALLING_CONVENTION_cdecl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4144,10 +4144,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
if (restrictive &&
|
||||
GenericCallingConvention
|
||||
.getGenericCallingConvention(name) == GenericCallingConvention.unknown &&
|
||||
!getKnownCallingConventionNames().contains(name) &&
|
||||
getCallingConvention(name) == null) {
|
||||
!getKnownCallingConventionNames().contains(name)) {
|
||||
|
||||
throw new InvalidInputException("Invalid calling convention name: " + name);
|
||||
throw new InvalidInputException("Unknown calling convention name: " + name);
|
||||
}
|
||||
|
||||
return callingConventionAdapter.getCallingConventionId(name,
|
||||
|
|
|
@ -188,17 +188,9 @@ public class FunctionDefinitionDataType extends GenericDataType implements Funct
|
|||
}
|
||||
|
||||
if (GenericCallingConvention
|
||||
.getGenericCallingConvention(conventionName) != GenericCallingConvention.unknown) {
|
||||
ProgramArchitecture arch = dataMgr != null ? dataMgr.getProgramArchitecture() : null;
|
||||
if (arch != null) {
|
||||
CompilerSpec compilerSpec = arch.getCompilerSpec();
|
||||
PrototypeModel callingConvention =
|
||||
compilerSpec.getCallingConvention(conventionName);
|
||||
if (callingConvention == null) {
|
||||
throw new InvalidInputException(
|
||||
"Invalid calling convention name: " + conventionName);
|
||||
}
|
||||
}
|
||||
.getGenericCallingConvention(conventionName) == GenericCallingConvention.unknown &&
|
||||
!dataMgr.getKnownCallingConventionNames().contains(name)) {
|
||||
throw new InvalidInputException("Unknown calling convention name: " + conventionName);
|
||||
}
|
||||
|
||||
this.callingConventionName = conventionName;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue