mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-7044 - Find Uses - Updated finding code for FunctionDefinitions to
find all references
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
* 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package ghidra.app.plugin.core.navigation.locationreferences;
|
||||
|
||||
import ghidra.program.database.symbol.FunctionSymbol;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.symbol.*;
|
||||
@@ -39,6 +40,13 @@ public class FunctionDefinitionLocationDescriptor extends GenericDataTypeLocatio
|
||||
protected void doGetReferences(Accumulator<LocationReference> accumulator, TaskMonitor monitor)
|
||||
throws CancelledException {
|
||||
|
||||
findAppliedFunctionDefinition(accumulator);
|
||||
|
||||
ReferenceUtils.findDataTypeReferences(accumulator, functionDefinition, program, true,
|
||||
monitor);
|
||||
}
|
||||
|
||||
private void findAppliedFunctionDefinition(Accumulator<LocationReference> accumulator) {
|
||||
DataType myReturnType = functionDefinition.getReturnType();
|
||||
ParameterDefinition[] myParameters = functionDefinition.getArguments();
|
||||
|
||||
@@ -48,15 +56,14 @@ public class FunctionDefinitionLocationDescriptor extends GenericDataTypeLocatio
|
||||
|
||||
// the definition could be applied in more than one namespace, so handle each application
|
||||
while (symbols.hasNext()) {
|
||||
Symbol symbol = symbols.next();
|
||||
|
||||
if (!(symbol instanceof FunctionSymbol)) {
|
||||
Symbol symbol = symbols.next();
|
||||
if (!(symbol instanceof FunctionSymbol functionSymbol)) {
|
||||
continue;
|
||||
}
|
||||
FunctionSymbol functionSymbol = (FunctionSymbol) symbol;
|
||||
|
||||
long symbolID = functionSymbol.getID();
|
||||
Function function = functionManager.getFunction(symbolID);
|
||||
|
||||
FunctionSignature signature = function.getSignature(true);
|
||||
ParameterDefinition[] theirParameters = signature.getArguments();
|
||||
if (!isSameParamters(myParameters, theirParameters)) {
|
||||
@@ -67,7 +74,14 @@ public class FunctionDefinitionLocationDescriptor extends GenericDataTypeLocatio
|
||||
continue;
|
||||
}
|
||||
|
||||
accumulator.add(new LocationReference(symbol.getAddress()));
|
||||
ProgramLocation location = symbol.getProgramLocation();
|
||||
Address address = symbol.getAddress();
|
||||
if (location != null) {
|
||||
accumulator.add(new LocationReference(address, null, location));
|
||||
}
|
||||
else {
|
||||
accumulator.add(new LocationReference(address));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user