From c0d344faba2f0dc8d03a9059ca16643d163761d1 Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Mon, 6 Jul 2026 18:59:25 -0400 Subject: [PATCH] GP-7044 - Find Uses - Updated finding code for FunctionDefinitions to find all references --- .../FunctionDefinitionLocationDescriptor.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/FunctionDefinitionLocationDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/FunctionDefinitionLocationDescriptor.java index 9da5e83915..0f217cc1fa 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/FunctionDefinitionLocationDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/FunctionDefinitionLocationDescriptor.java @@ -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 accumulator, TaskMonitor monitor) throws CancelledException { + findAppliedFunctionDefinition(accumulator); + + ReferenceUtils.findDataTypeReferences(accumulator, functionDefinition, program, true, + monitor); + } + + private void findAppliedFunctionDefinition(Accumulator 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)); + } } }