mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Merge remote-tracking branch 'origin/GP-2668-dragonmacher-show-symbol-references-action'
This commit is contained in:
commit
1b034882d2
4 changed files with 50 additions and 94 deletions
|
@ -15,12 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.symtable;
|
package ghidra.app.plugin.core.symtable;
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
import docking.widgets.table.DiscoverableTableUtils;
|
||||||
|
import docking.widgets.table.TableColumnDescriptor;
|
||||||
import docking.widgets.table.*;
|
|
||||||
import ghidra.app.services.BlockModelService;
|
import ghidra.app.services.BlockModelService;
|
||||||
import ghidra.docking.settings.Settings;
|
import ghidra.docking.settings.Settings;
|
||||||
import ghidra.framework.plugintool.PluginTool;
|
import ghidra.framework.plugintool.PluginTool;
|
||||||
|
@ -34,8 +32,6 @@ import ghidra.program.util.ProgramLocation;
|
||||||
import ghidra.util.datastruct.Accumulator;
|
import ghidra.util.datastruct.Accumulator;
|
||||||
import ghidra.util.exception.CancelledException;
|
import ghidra.util.exception.CancelledException;
|
||||||
import ghidra.util.table.AddressBasedTableModel;
|
import ghidra.util.table.AddressBasedTableModel;
|
||||||
import ghidra.util.table.column.AbstractGhidraColumnRenderer;
|
|
||||||
import ghidra.util.table.column.GColumnRenderer;
|
|
||||||
import ghidra.util.table.field.*;
|
import ghidra.util.table.field.*;
|
||||||
import ghidra.util.task.TaskMonitor;
|
import ghidra.util.task.TaskMonitor;
|
||||||
|
|
||||||
|
@ -79,7 +75,7 @@ public class SymbolReferenceModel extends AddressBasedTableModel<Reference> {
|
||||||
descriptor.addVisibleColumn(
|
descriptor.addVisibleColumn(
|
||||||
DiscoverableTableUtils.adaptColumForModel(this, new ReferenceFromLabelTableColumn()));
|
DiscoverableTableUtils.adaptColumForModel(this, new ReferenceFromLabelTableColumn()));
|
||||||
descriptor.addVisibleColumn(new SubroutineTableColumn());
|
descriptor.addVisibleColumn(new SubroutineTableColumn());
|
||||||
descriptor.addVisibleColumn(new AccessTableColumn());
|
descriptor.addVisibleColumn(new ReferenceTypeTableColumn());
|
||||||
descriptor.addVisibleColumn(
|
descriptor.addVisibleColumn(
|
||||||
DiscoverableTableUtils.adaptColumForModel(this, new ReferenceFromPreviewTableColumn()));
|
DiscoverableTableUtils.adaptColumForModel(this, new ReferenceFromPreviewTableColumn()));
|
||||||
|
|
||||||
|
@ -240,32 +236,6 @@ public class SymbolReferenceModel extends AddressBasedTableModel<Reference> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getReferenceType(RefType type) {
|
|
||||||
if (type == RefType.THUNK) {
|
|
||||||
return "Thunk";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type.isRead() && type.isWrite()) {
|
|
||||||
return "RW";
|
|
||||||
}
|
|
||||||
if (type.isRead()) {
|
|
||||||
return "Read";
|
|
||||||
}
|
|
||||||
if (type.isWrite()) {
|
|
||||||
return "Write";
|
|
||||||
}
|
|
||||||
if (type.isData()) {
|
|
||||||
return "Data";
|
|
||||||
}
|
|
||||||
if (type.isCall()) {
|
|
||||||
return "Call";
|
|
||||||
}
|
|
||||||
if (type.isJump()) {
|
|
||||||
return (type.isConditional() ? "Branch" : "Jump");
|
|
||||||
}
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Symbol getSymbol(Address fromAddress, String symbolName,
|
private static Symbol getSymbol(Address fromAddress, String symbolName,
|
||||||
BlockModelService blockModelService, Program program) {
|
BlockModelService blockModelService, Program program) {
|
||||||
|
|
||||||
|
@ -374,55 +344,4 @@ public class SymbolReferenceModel extends AddressBasedTableModel<Reference> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AccessTableColumn
|
|
||||||
extends AbstractProgramBasedDynamicTableColumn<Reference, RefType> {
|
|
||||||
|
|
||||||
private AccessCellRenderer accessRenderer = new AccessCellRenderer();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getColumnName() {
|
|
||||||
return "Access";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RefType getValue(Reference rowObject, Settings settings, Program program,
|
|
||||||
ServiceProvider serviceProvider) throws IllegalArgumentException {
|
|
||||||
|
|
||||||
Listing listing = program.getListing();
|
|
||||||
RefType referenceType = rowObject.getReferenceType();
|
|
||||||
if (referenceType == RefType.INDIRECTION) {
|
|
||||||
Instruction instruction = listing.getInstructionAt(rowObject.getFromAddress());
|
|
||||||
if (instruction != null) {
|
|
||||||
FlowType flowType = instruction.getFlowType();
|
|
||||||
return flowType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return referenceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GColumnRenderer<RefType> getColumnRenderer() {
|
|
||||||
return accessRenderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class AccessCellRenderer extends AbstractGhidraColumnRenderer<RefType> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getTableCellRendererComponent(GTableCellRenderingData data) {
|
|
||||||
|
|
||||||
JLabel label = (JLabel) super.getTableCellRendererComponent(data);
|
|
||||||
|
|
||||||
RefType refType = (RefType) data.getValue();
|
|
||||||
label.setText(getReferenceType(refType));
|
|
||||||
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFilterString(RefType t, Settings settings) {
|
|
||||||
return getReferenceType(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,13 +114,14 @@ public class ReferencesFromTableModel extends AddressBasedTableModel<ReferenceEn
|
||||||
ReferenceEndpoint rowObject = (ReferenceEndpoint) data.getValue();
|
ReferenceEndpoint rowObject = (ReferenceEndpoint) data.getValue();
|
||||||
String text = asString(rowObject);
|
String text = asString(rowObject);
|
||||||
label.setText(text);
|
label.setText(text);
|
||||||
|
label.setToolTipText(rowObject.getReferenceType().getName());
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String asString(ReferenceEndpoint t) {
|
private String asString(ReferenceEndpoint t) {
|
||||||
RefType refType = t.getReferenceType();
|
RefType refType = t.getReferenceType();
|
||||||
String text = refType.getName();
|
String text = refType.getDisplayString();
|
||||||
if (t.isOffcut()) {
|
if (t.isOffcut()) {
|
||||||
text = "<html>" + HTMLUtilities.colorString(OFFCUT_COLOR, text + HTML_OFFCUT_TEXT);
|
text = "<html>" + HTMLUtilities.colorString(OFFCUT_COLOR, text + HTML_OFFCUT_TEXT);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +131,7 @@ public class ReferencesFromTableModel extends AddressBasedTableModel<ReferenceEn
|
||||||
@Override
|
@Override
|
||||||
public String getFilterString(ReferenceEndpoint t, Settings settings) {
|
public String getFilterString(ReferenceEndpoint t, Settings settings) {
|
||||||
RefType refType = t.getReferenceType();
|
RefType refType = t.getReferenceType();
|
||||||
String text = refType.getName();
|
String text = refType.getDisplayString();
|
||||||
if (t.isOffcut()) {
|
if (t.isOffcut()) {
|
||||||
return text + PLAIN_OFFCUT_TEXT;
|
return text + PLAIN_OFFCUT_TEXT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,8 @@ import javax.swing.JLabel;
|
||||||
import docking.widgets.table.GTableCellRenderingData;
|
import docking.widgets.table.GTableCellRenderingData;
|
||||||
import ghidra.docking.settings.Settings;
|
import ghidra.docking.settings.Settings;
|
||||||
import ghidra.framework.plugintool.ServiceProvider;
|
import ghidra.framework.plugintool.ServiceProvider;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.*;
|
||||||
import ghidra.program.model.symbol.RefType;
|
import ghidra.program.model.symbol.*;
|
||||||
import ghidra.program.model.symbol.Reference;
|
|
||||||
import ghidra.program.util.ProgramLocation;
|
import ghidra.program.util.ProgramLocation;
|
||||||
import ghidra.util.table.column.AbstractGhidraColumnRenderer;
|
import ghidra.util.table.column.AbstractGhidraColumnRenderer;
|
||||||
import ghidra.util.table.column.GColumnRenderer;
|
import ghidra.util.table.column.GColumnRenderer;
|
||||||
|
@ -51,7 +50,16 @@ public class ReferenceTypeTableColumn
|
||||||
@Override
|
@Override
|
||||||
public RefType getValue(Reference rowObject, Settings settings, Program program,
|
public RefType getValue(Reference rowObject, Settings settings, Program program,
|
||||||
ServiceProvider serviceProvider) throws IllegalArgumentException {
|
ServiceProvider serviceProvider) throws IllegalArgumentException {
|
||||||
return rowObject.getReferenceType();
|
Listing listing = program.getListing();
|
||||||
|
RefType referenceType = rowObject.getReferenceType();
|
||||||
|
if (referenceType == RefType.INDIRECTION) {
|
||||||
|
Instruction instruction = listing.getInstructionAt(rowObject.getFromAddress());
|
||||||
|
if (instruction != null) {
|
||||||
|
FlowType flowType = instruction.getFlowType();
|
||||||
|
return flowType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return referenceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,15 +81,13 @@ public class ReferenceTypeTableColumn
|
||||||
JLabel label = (JLabel) super.getTableCellRendererComponent(data);
|
JLabel label = (JLabel) super.getTableCellRendererComponent(data);
|
||||||
|
|
||||||
RefType value = (RefType) data.getValue();
|
RefType value = (RefType) data.getValue();
|
||||||
|
label.setText(value.getDisplayString());
|
||||||
label.setText(value.getName());
|
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFilterString(RefType t, Settings settings) {
|
public String getFilterString(RefType t, Settings settings) {
|
||||||
return t.getName();
|
return t.getDisplayString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,6 +258,36 @@ public abstract class RefType {
|
||||||
private byte type;
|
private byte type;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an easy to read display string for this ref type.
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public String getDisplayString() {
|
||||||
|
if (this == RefType.THUNK) {
|
||||||
|
return "Thunk";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRead() && isWrite()) {
|
||||||
|
return "RW";
|
||||||
|
}
|
||||||
|
if (isRead()) {
|
||||||
|
return "Read";
|
||||||
|
}
|
||||||
|
if (isWrite()) {
|
||||||
|
return "Write";
|
||||||
|
}
|
||||||
|
if (isData()) {
|
||||||
|
return "Data";
|
||||||
|
}
|
||||||
|
if (isCall()) {
|
||||||
|
return "Call";
|
||||||
|
}
|
||||||
|
if (isJump()) {
|
||||||
|
return (isConditional() ? "Branch" : "Jump");
|
||||||
|
}
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
protected RefType(byte type, String name) {
|
protected RefType(byte type, String name) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue