mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-3446 - Review fixes
This commit is contained in:
parent
142ed19e84
commit
8ebfd61348
5 changed files with 13 additions and 43 deletions
|
@ -21,7 +21,6 @@ import java.awt.event.MouseEvent;
|
|||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComponent;
|
||||
|
@ -970,7 +969,7 @@ public class CodeBrowserPlugin extends Plugin
|
|||
return; // not sure if this can happen
|
||||
}
|
||||
|
||||
Supplier<Set<Reference>> refs = () -> XReferenceUtil.getAllXrefs(location);
|
||||
Set<Reference> refs = XReferenceUtil.getAllXrefs(location);
|
||||
XReferenceUtil.showAllXrefs(connectedProvider, tool, service, location, refs);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package ghidra.app.util;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
|
@ -25,6 +24,7 @@ import ghidra.app.plugin.core.table.TableComponentProvider;
|
|||
import ghidra.app.util.query.TableService;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.DataUtilities;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
|
@ -307,15 +307,13 @@ public class XReferenceUtil {
|
|||
* @param serviceProvider the service provider needed to wire navigation
|
||||
* @param service the service needed to show the table
|
||||
* @param location the location for which to find references
|
||||
* @param xrefs the supplier of xrefs to show
|
||||
* @param xrefs the xrefs to show
|
||||
*/
|
||||
public static void showAllXrefs(Navigatable navigatable, ServiceProvider serviceProvider,
|
||||
TableService service, ProgramLocation location, Supplier<Set<Reference>> xrefs) {
|
||||
|
||||
Set<Reference> refs = xrefs.get();
|
||||
TableService service, ProgramLocation location, Set<Reference> xrefs) {
|
||||
|
||||
ReferencesFromTableModel model =
|
||||
new ReferencesFromTableModel(new ArrayList<>(refs), serviceProvider,
|
||||
new ReferencesFromTableModel(new ArrayList<>(xrefs), serviceProvider,
|
||||
location.getProgram());
|
||||
TableComponentProvider<ReferenceEndpoint> provider = service.showTable(
|
||||
"XRefs to " + location.getAddress().toString(), "XRefs", model, "XRefs", navigatable);
|
||||
|
@ -332,7 +330,7 @@ public class XReferenceUtil {
|
|||
*/
|
||||
public static Set<Reference> getAllXrefs(ProgramLocation location) {
|
||||
|
||||
CodeUnit cu = getImmediateDataContaining(location);
|
||||
CodeUnit cu = DataUtilities.getDataAtLocation(location);
|
||||
if (cu == null) {
|
||||
Address toAddress = location.getAddress();
|
||||
Listing listing = location.getProgram().getListing();
|
||||
|
@ -348,22 +346,4 @@ public class XReferenceUtil {
|
|||
CollectionUtils.addAll(set, offcuts);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the nearest {@link Data} object containing a given address.
|
||||
*
|
||||
* @param location the program location within the data object
|
||||
* @return the Data object
|
||||
*/
|
||||
private static Data getImmediateDataContaining(ProgramLocation location) {
|
||||
Address addr = location.getAddress();
|
||||
Listing listing = location.getProgram().getListing();
|
||||
Data dataContaining = listing.getDataContaining(addr);
|
||||
if (dataContaining == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Data dataAtAddr = dataContaining.getComponent(location.getComponentPath());
|
||||
return dataAtAddr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package ghidra.app.util.viewer.field;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import ghidra.app.nav.Navigatable;
|
||||
import ghidra.app.util.XReferenceUtil;
|
||||
|
@ -80,7 +79,7 @@ public class VariableXRefFieldMouseHandler extends XRefFieldMouseHandler {
|
|||
VariableLocation variableLocation = (VariableLocation) location;
|
||||
Variable variable = variableLocation.getVariable();
|
||||
|
||||
Supplier<Set<Reference>> refs = () -> XReferenceUtil.getVariableRefs(variable);
|
||||
Set<Reference> refs = XReferenceUtil.getVariableRefs(variable);
|
||||
XReferenceUtil.showAllXrefs(navigatable, serviceProvider, service, location, refs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package ghidra.app.util.viewer.field;
|
|||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import docking.widgets.fieldpanel.field.FieldElement;
|
||||
import docking.widgets.fieldpanel.field.TextField;
|
||||
|
@ -106,7 +105,7 @@ public class XRefFieldMouseHandler implements FieldMouseHandlerExtension {
|
|||
return;
|
||||
}
|
||||
|
||||
Supplier<Set<Reference>> refs = () -> XReferenceUtil.getAllXrefs(location);
|
||||
Set<Reference> refs = XReferenceUtil.getAllXrefs(location);
|
||||
XReferenceUtil.showAllXrefs(navigatable, serviceProvider, service, location, refs);
|
||||
}
|
||||
|
||||
|
|
|
@ -326,20 +326,13 @@ public final class DataUtilities {
|
|||
|
||||
Address addr = loc.getAddress();
|
||||
Listing listing = loc.getProgram().getListing();
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr);
|
||||
if (cu == null) {
|
||||
cu = listing.getCodeUnitContaining(addr);
|
||||
Data dataContaining = listing.getDataContaining(addr);
|
||||
if (dataContaining == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cu instanceof Data) {
|
||||
Data d = (Data) cu;
|
||||
int[] compPath = loc.getComponentPath();
|
||||
if (compPath != null) {
|
||||
d = d.getComponent(compPath);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
return null;
|
||||
Data dataAtAddr = dataContaining.getComponent(loc.getComponentPath());
|
||||
return dataAtAddr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue