mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/GP-5157-dragonmacher-unify-unresolved-ref-color--SQUASHED'
This commit is contained in:
commit
e5a8b9a79e
18 changed files with 224 additions and 214 deletions
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -15,17 +15,23 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.functionwindow;
|
package ghidra.app.plugin.core.functionwindow;
|
||||||
|
|
||||||
import docking.widgets.table.DiscoverableTableUtils;
|
import java.awt.Color;
|
||||||
import docking.widgets.table.TableColumnDescriptor;
|
import java.awt.Component;
|
||||||
|
|
||||||
|
import docking.widgets.table.*;
|
||||||
|
import ghidra.app.util.SymbolInspector;
|
||||||
import ghidra.docking.settings.Settings;
|
import ghidra.docking.settings.Settings;
|
||||||
import ghidra.framework.plugintool.PluginTool;
|
import ghidra.framework.plugintool.PluginTool;
|
||||||
import ghidra.framework.plugintool.ServiceProvider;
|
import ghidra.framework.plugintool.ServiceProvider;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.listing.*;
|
import ghidra.program.model.listing.*;
|
||||||
|
import ghidra.program.model.symbol.Symbol;
|
||||||
import ghidra.util.LongIterator;
|
import ghidra.util.LongIterator;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -180,6 +186,9 @@ public class FunctionTableModel extends AddressBasedTableModel<FunctionRowObject
|
||||||
private class NameTableColumn
|
private class NameTableColumn
|
||||||
extends AbstractProgramBasedDynamicTableColumn<FunctionRowObject, String> {
|
extends AbstractProgramBasedDynamicTableColumn<FunctionRowObject, String> {
|
||||||
|
|
||||||
|
private GColumnRenderer<String> renderer = new FunctionNameRenderer();
|
||||||
|
private SymbolInspector inspector = new SymbolInspector(serviceProvider, null);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnName() {
|
public String getColumnName() {
|
||||||
return "Name";
|
return "Name";
|
||||||
|
@ -196,5 +205,35 @@ public class FunctionTableModel extends AddressBasedTableModel<FunctionRowObject
|
||||||
return function.getName();
|
return function.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GColumnRenderer<String> getColumnRenderer() {
|
||||||
|
return renderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A renderer to paint function name colors using the SymbolInspector
|
||||||
|
private class FunctionNameRenderer extends AbstractGhidraColumnRenderer<String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(GTableCellRenderingData data) {
|
||||||
|
Component cellRenderer = super.getTableCellRendererComponent(data);
|
||||||
|
setBold();
|
||||||
|
if (data.isSelected()) {
|
||||||
|
return cellRenderer; // just let the default foreground color through
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionRowObject rowObject = (FunctionRowObject) data.getRowObject();
|
||||||
|
Function function = rowObject.getFunction();
|
||||||
|
Symbol symbol = function.getSymbol();
|
||||||
|
Color color = inspector.getColor(symbol);
|
||||||
|
cellRenderer.setForeground(color);
|
||||||
|
return cellRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFilterString(String t, Settings settings) {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -353,7 +353,6 @@ class InstructionPanel extends JPanel implements ChangeListener {
|
||||||
SymbolTable st = program.getSymbolTable();
|
SymbolTable st = program.getSymbolTable();
|
||||||
Symbol sym = st.getSymbol(ref);
|
Symbol sym = st.getSymbol(ref);
|
||||||
if (sym != null) {
|
if (sym != null) {
|
||||||
symbolInspector.setProgram(program);
|
|
||||||
return symbolInspector.getColor(sym);
|
return symbolInspector.getColor(sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -27,7 +27,6 @@ import generic.theme.GIcon;
|
||||||
import ghidra.app.plugin.core.symboltree.nodes.SymbolCategoryNode;
|
import ghidra.app.plugin.core.symboltree.nodes.SymbolCategoryNode;
|
||||||
import ghidra.app.plugin.core.symboltree.nodes.SymbolNode;
|
import ghidra.app.plugin.core.symboltree.nodes.SymbolNode;
|
||||||
import ghidra.app.util.SymbolInspector;
|
import ghidra.app.util.SymbolInspector;
|
||||||
import ghidra.program.model.listing.Program;
|
|
||||||
import ghidra.program.model.symbol.Symbol;
|
import ghidra.program.model.symbol.Symbol;
|
||||||
import resources.ResourceManager;
|
import resources.ResourceManager;
|
||||||
|
|
||||||
|
@ -120,10 +119,6 @@ public class SymbolGTree extends GTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgram(Program program) {
|
|
||||||
symbolInspector.setProgram(program);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|
|
@ -151,7 +151,6 @@ public class SymbolTreeProvider extends ComponentProviderAdapter {
|
||||||
private SymbolGTree createTree(SymbolTreeRootNode rootNode) {
|
private SymbolGTree createTree(SymbolTreeRootNode rootNode) {
|
||||||
if (tree != null) {
|
if (tree != null) {
|
||||||
GTreeNode oldRootNode = tree.getModelRoot();
|
GTreeNode oldRootNode = tree.getModelRoot();
|
||||||
tree.setProgram(rootNode.getProgram());
|
|
||||||
tree.setRootNode(rootNode);
|
tree.setRootNode(rootNode);
|
||||||
|
|
||||||
oldRootNode.removeAll();// assist in cleanup a bit
|
oldRootNode.removeAll();// assist in cleanup a bit
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -127,7 +127,6 @@ public class CreateSymbolTableAction extends ProgramSymbolContextAction {
|
||||||
new TransientSymbolTableDnDAdapter(table, model);
|
new TransientSymbolTableDnDAdapter(table, model);
|
||||||
|
|
||||||
SymbolInspector symbolInspector = new SymbolInspector(tool, table);
|
SymbolInspector symbolInspector = new SymbolInspector(tool, table);
|
||||||
symbolInspector.setProgram(program);
|
|
||||||
SymbolRenderer renderer = model.getSymbolRenderer();
|
SymbolRenderer renderer = model.getSymbolRenderer();
|
||||||
renderer.setSymbolInspector(symbolInspector);
|
renderer.setSymbolInspector(symbolInspector);
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -19,15 +19,8 @@ import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
|
||||||
import docking.widgets.table.GTableCellRenderingData;
|
import docking.widgets.table.GTableCellRenderingData;
|
||||||
import generic.theme.GThemeDefaults.Colors;
|
|
||||||
import ghidra.app.util.SymbolInspector;
|
import ghidra.app.util.SymbolInspector;
|
||||||
import ghidra.program.model.address.Address;
|
|
||||||
import ghidra.program.model.lang.Register;
|
|
||||||
import ghidra.program.model.listing.Program;
|
|
||||||
import ghidra.program.model.listing.Variable;
|
|
||||||
import ghidra.program.model.symbol.Symbol;
|
import ghidra.program.model.symbol.Symbol;
|
||||||
import ghidra.program.util.ProgramLocation;
|
|
||||||
import ghidra.program.util.VariableNameFieldLocation;
|
|
||||||
import ghidra.util.table.GhidraTableCellRenderer;
|
import ghidra.util.table.GhidraTableCellRenderer;
|
||||||
|
|
||||||
public class SymbolRenderer extends GhidraTableCellRenderer {
|
public class SymbolRenderer extends GhidraTableCellRenderer {
|
||||||
|
@ -44,74 +37,18 @@ public class SymbolRenderer extends GhidraTableCellRenderer {
|
||||||
|
|
||||||
Object value = data.getValue();
|
Object value = data.getValue();
|
||||||
int column = data.getColumnModelIndex();
|
int column = data.getColumnModelIndex();
|
||||||
boolean isSelected = data.isSelected();
|
|
||||||
|
|
||||||
if (value == null && column == AbstractSymbolTableModel.LABEL_COL) {
|
if (value == null && column == AbstractSymbolTableModel.LABEL_COL) {
|
||||||
setText("<< REMOVED >>");
|
setText("<< REMOVED >>");
|
||||||
}
|
}
|
||||||
else if (value instanceof Symbol) {
|
else if (value instanceof Symbol s) {
|
||||||
handleSymbol(value, isSelected);
|
setBold();
|
||||||
}
|
Color color = inspector.getColor(s);
|
||||||
else if (value instanceof Address) {
|
|
||||||
setText(getAddressString((Address) value));
|
if (!data.isSelected()) {
|
||||||
}
|
setForeground(color);
|
||||||
else if (value instanceof ProgramLocation) {
|
}
|
||||||
setText(getLocationString((ProgramLocation) value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getLocationString(ProgramLocation location) {
|
|
||||||
if (location instanceof VariableNameFieldLocation) {
|
|
||||||
VariableNameFieldLocation varLoc = (VariableNameFieldLocation) location;
|
|
||||||
Variable variable = varLoc.getVariable();
|
|
||||||
return variable.getVariableStorage().toString();
|
|
||||||
}
|
|
||||||
return getAddressString(location.getAddress());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleSymbol(Object value, boolean isSelected) {
|
|
||||||
setBold();
|
|
||||||
Color color =
|
|
||||||
(inspector != null) && (value instanceof Symbol) ? inspector.getColor((Symbol) value)
|
|
||||||
: Colors.FOREGROUND;
|
|
||||||
|
|
||||||
if (!isSelected) {
|
|
||||||
setForeground(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getAddressString(Address address) {
|
|
||||||
if (address.isStackAddress()) {
|
|
||||||
return getStackAddressString(address);
|
|
||||||
}
|
|
||||||
else if (address.isRegisterAddress()) {
|
|
||||||
return getRegisterAddressString(address);
|
|
||||||
}
|
|
||||||
else if (address.isExternalAddress() || address == Address.NO_ADDRESS) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return address.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getRegisterAddressString(Address address) {
|
|
||||||
Program program = inspector.getProgram();
|
|
||||||
if (program != null) {
|
|
||||||
Register register = program.getRegister(address);
|
|
||||||
if (register != null) {
|
|
||||||
return register.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getStackAddressString(Address address) {
|
|
||||||
long offset = address.getOffset();
|
|
||||||
if (offset < 0) {
|
|
||||||
return "Stack[-0x" + Long.toHexString(-offset) + "]";
|
|
||||||
}
|
|
||||||
return "Stack[0x" + Long.toHexString(offset) + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -179,7 +179,6 @@ public class SymbolTablePlugin extends Plugin {
|
||||||
Program newProg = progEvent.getActiveProgram();
|
Program newProg = progEvent.getActiveProgram();
|
||||||
|
|
||||||
if (oldProg != null) {
|
if (oldProg != null) {
|
||||||
inspector.setProgram(null);
|
|
||||||
oldProg.removeListener(domainObjectListener);
|
oldProg.removeListener(domainObjectListener);
|
||||||
domainObjectWorker.clearAllJobs();
|
domainObjectWorker.clearAllJobs();
|
||||||
symProvider.setProgram(null, inspector);
|
symProvider.setProgram(null, inspector);
|
||||||
|
@ -189,7 +188,6 @@ public class SymbolTablePlugin extends Plugin {
|
||||||
currentProgram = newProg;
|
currentProgram = newProg;
|
||||||
if (newProg != null) {
|
if (newProg != null) {
|
||||||
currentProgram.addListener(domainObjectListener);
|
currentProgram.addListener(domainObjectListener);
|
||||||
inspector.setProgram(currentProgram);
|
|
||||||
symProvider.setProgram(currentProgram, inspector);
|
symProvider.setProgram(currentProgram, inspector);
|
||||||
refProvider.setProgram(currentProgram, inspector);
|
refProvider.setProgram(currentProgram, inspector);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -40,10 +40,7 @@ import ghidra.program.model.symbol.*;
|
||||||
public class SymbolInspector implements OptionsChangeListener {
|
public class SymbolInspector implements OptionsChangeListener {
|
||||||
|
|
||||||
private Component repaintComp;
|
private Component repaintComp;
|
||||||
private Program program;
|
|
||||||
private ToolOptions optionsObject;
|
private ToolOptions optionsObject;
|
||||||
private Listing listing;
|
|
||||||
private Memory memory;
|
|
||||||
private Map<String, Object> cache = new HashMap<>();
|
private Map<String, Object> cache = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,35 +78,6 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Associates a program with this symbol inspector
|
|
||||||
* @param p the program for inspecting symbols
|
|
||||||
*/
|
|
||||||
public void setProgram(Program p) {
|
|
||||||
if (program == p) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (program != null) {
|
|
||||||
this.program = null;
|
|
||||||
this.listing = null;
|
|
||||||
this.memory = null;
|
|
||||||
}
|
|
||||||
if (p != null) {
|
|
||||||
this.program = p;
|
|
||||||
this.listing = p.getListing();
|
|
||||||
this.memory = p.getMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the program in use by this inspector; may be null;
|
|
||||||
* @return the program in use by this inspector; may be null;
|
|
||||||
*/
|
|
||||||
public Program getProgram() {
|
|
||||||
return program;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this when you are done with this inspector and will not use it again.
|
* Call this when you are done with this inspector and will not use it again.
|
||||||
* Cleans up listeners, etc.
|
* Cleans up listeners, etc.
|
||||||
|
@ -120,7 +88,25 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
optionsObject = null;
|
optionsObject = null;
|
||||||
}
|
}
|
||||||
repaintComp = null;
|
repaintComp = null;
|
||||||
setProgram(null);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does nothing
|
||||||
|
* @param p the program
|
||||||
|
* @deprecated this method does nothing
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "11.3", forRemoval = true)
|
||||||
|
public void setProgram(Program p) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return null}
|
||||||
|
* @deprecated returns null
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "11.3", forRemoval = true)
|
||||||
|
public Program getProgram() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,6 +115,7 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
* @return boolean true if symbol is bad
|
* @return boolean true if symbol is bad
|
||||||
*/
|
*/
|
||||||
public boolean isBadReferenceSymbol(Symbol s) {
|
public boolean isBadReferenceSymbol(Symbol s) {
|
||||||
|
Memory memory = getMemory(s);
|
||||||
if (memory == null) {
|
if (memory == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -149,6 +136,7 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Address addr = s.getAddress();
|
Address addr = s.getAddress();
|
||||||
|
Listing listing = getListing(s);
|
||||||
Data data = listing.getDataContaining(addr);
|
Data data = listing.getDataContaining(addr);
|
||||||
return (data != null);
|
return (data != null);
|
||||||
}
|
}
|
||||||
|
@ -162,6 +150,7 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
if (isBadReferenceSymbol(s)) {
|
if (isBadReferenceSymbol(s)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Program program = s.getProgram();
|
||||||
ReferenceManager refMgr = program.getReferenceManager();
|
ReferenceManager refMgr = program.getReferenceManager();
|
||||||
return !refMgr.hasReferencesTo(s.getAddress());
|
return !refMgr.hasReferencesTo(s.getAddress());
|
||||||
}
|
}
|
||||||
|
@ -225,6 +214,7 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Address addr = s.getAddress();
|
Address addr = s.getAddress();
|
||||||
|
Listing listing = getListing(s);
|
||||||
Instruction instr = listing.getInstructionContaining(addr);
|
Instruction instr = listing.getInstructionContaining(addr);
|
||||||
return (instr != null);
|
return (instr != null);
|
||||||
}
|
}
|
||||||
|
@ -265,6 +255,7 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Address addr = s.getAddress();
|
Address addr = s.getAddress();
|
||||||
|
Listing listing = getListing(s);
|
||||||
CodeUnit cu = listing.getCodeUnitContaining(addr);
|
CodeUnit cu = listing.getCodeUnitContaining(addr);
|
||||||
if (cu != null && cu.getLength() > 1) {
|
if (cu != null && cu.getLength() > 1) {
|
||||||
return cu.getMinAddress().compareTo(addr) < 0;
|
return cu.getMinAddress().compareTo(addr) < 0;
|
||||||
|
@ -321,6 +312,25 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
return new ColorAndStyle(color, style);
|
return new ColorAndStyle(color, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the color and style used to render the given reference. Calling this method is
|
||||||
|
* faster than calling {@link #getColor(Symbol)} and {@link #getStyle(Symbol)}
|
||||||
|
* separately.
|
||||||
|
*
|
||||||
|
* @param p the program
|
||||||
|
* @param r the reference
|
||||||
|
* @return the color and style
|
||||||
|
*/
|
||||||
|
public ColorAndStyle getColorAndStyle(Program p, Reference r) {
|
||||||
|
ScreenElement se = getScreenElement(p, r);
|
||||||
|
if (se == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Color color = getColor(se);
|
||||||
|
int style = getStyle(se);
|
||||||
|
return new ColorAndStyle(color, style);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the color used to render the given symbol.
|
* Get the color used to render the given symbol.
|
||||||
* @param s symbol to inspect
|
* @param s symbol to inspect
|
||||||
|
@ -341,7 +351,7 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ScreenElement corresponding to the type of the symbol
|
* Get the ScreenElement corresponding to the type of the symbol
|
||||||
* @param s symbol to inspect
|
* @param s the symbol to inspect
|
||||||
* @return the screen element
|
* @return the screen element
|
||||||
*/
|
*/
|
||||||
public ScreenElement getScreenElement(Symbol s) {
|
public ScreenElement getScreenElement(Symbol s) {
|
||||||
|
@ -366,7 +376,8 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
return OptionsGui.LABELS_UNREFD;
|
return OptionsGui.LABELS_UNREFD;
|
||||||
}
|
}
|
||||||
else if (isFunctionSymbol(s)) {
|
else if (isFunctionSymbol(s)) {
|
||||||
return OptionsGui.FUN_NAME;
|
Function f = (Function) s.getObject();
|
||||||
|
return getFunctionScreenElement(f);
|
||||||
}
|
}
|
||||||
else if (isVariableSymbol(s)) {
|
else if (isVariableSymbol(s)) {
|
||||||
if (s.getSymbolType() == SymbolType.PARAMETER) {
|
if (s.getSymbolType() == SymbolType.PARAMETER) {
|
||||||
|
@ -388,6 +399,21 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ScreenElement corresponding to the type of the reference.
|
||||||
|
* @param p the program
|
||||||
|
* @param r the reference to inspect
|
||||||
|
* @return the screen element
|
||||||
|
*/
|
||||||
|
public ScreenElement getScreenElement(Program p, Reference r) {
|
||||||
|
if (r.isExternalReference()) {
|
||||||
|
ExternalLocation extLoc = ((ExternalReference) r).getExternalLocation();
|
||||||
|
String libName = extLoc.getLibraryName();
|
||||||
|
return getExternalPathScreenElement(p, libName);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Color getOffcutSymbolColor() {
|
public Color getOffcutSymbolColor() {
|
||||||
return getColor(OptionsGui.XREF_OFFCUT);
|
return getColor(OptionsGui.XREF_OFFCUT);
|
||||||
}
|
}
|
||||||
|
@ -400,12 +426,60 @@ public class SymbolInspector implements OptionsChangeListener {
|
||||||
// Private Methods
|
// Private Methods
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|
||||||
private ScreenElement getExternalScreenElement(Symbol s) {
|
private Listing getListing(Symbol s) {
|
||||||
String path = program.getExternalManager().getExternalLibraryPath(getExternalName(s));
|
Program p = s.getProgram();
|
||||||
if (path != null && path.length() > 0) {
|
if (p != null) {
|
||||||
return OptionsGui.EXT_REF_RESOLVED;
|
return p.getListing();
|
||||||
}
|
}
|
||||||
return OptionsGui.BAD_REF_ADDR;
|
return null; // not sure if this can happen
|
||||||
|
}
|
||||||
|
|
||||||
|
private Memory getMemory(Symbol s) {
|
||||||
|
Program p = s.getProgram();
|
||||||
|
if (p != null) {
|
||||||
|
return p.getMemory();
|
||||||
|
}
|
||||||
|
return null; // not sure if this can happen
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScreenElement getExternalScreenElement(Symbol s) {
|
||||||
|
|
||||||
|
Program p = s.getProgram();
|
||||||
|
String libName = getExternalName(s);
|
||||||
|
return getExternalPathScreenElement(p, libName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScreenElement getExternalPathScreenElement(Program p, String libName) {
|
||||||
|
|
||||||
|
ExternalManager externalManager = p.getExternalManager();
|
||||||
|
if (Library.UNKNOWN.equals(libName)) {
|
||||||
|
return OptionsGui.EXT_REF_UNRESOLVED;
|
||||||
|
}
|
||||||
|
|
||||||
|
String path = externalManager.getExternalLibraryPath(libName);
|
||||||
|
if (path == null || path.length() == 0) {
|
||||||
|
return OptionsGui.EXT_REF_UNRESOLVED;
|
||||||
|
}
|
||||||
|
return OptionsGui.EXT_REF_RESOLVED;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScreenElement getFunctionScreenElement(Function function) {
|
||||||
|
if (!function.isThunk()) {
|
||||||
|
return OptionsGui.FUN_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
// override function name color for external thunks which are not linked
|
||||||
|
Function thunkedFunction = function.getThunkedFunction(true);
|
||||||
|
if (thunkedFunction == null) {
|
||||||
|
return OptionsGui.EXT_REF_UNRESOLVED;
|
||||||
|
}
|
||||||
|
else if (thunkedFunction.isExternal()) {
|
||||||
|
ExternalLocation location = thunkedFunction.getExternalLocation();
|
||||||
|
String libName = location.getLibraryName();
|
||||||
|
return getExternalPathScreenElement(function.getProgram(), libName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OptionsGui.FUN_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getExternalName(Symbol s) {
|
private String getExternalName(Symbol s) {
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -25,6 +25,7 @@ import docking.widgets.fieldpanel.support.FieldLocation;
|
||||||
import docking.widgets.fieldpanel.support.RowColLocation;
|
import docking.widgets.fieldpanel.support.RowColLocation;
|
||||||
import ghidra.GhidraOptions;
|
import ghidra.GhidraOptions;
|
||||||
import ghidra.app.util.ListingHighlightProvider;
|
import ghidra.app.util.ListingHighlightProvider;
|
||||||
|
import ghidra.app.util.SymbolInspector;
|
||||||
import ghidra.app.util.viewer.field.ListingColors.FunctionColors;
|
import ghidra.app.util.viewer.field.ListingColors.FunctionColors;
|
||||||
import ghidra.app.util.viewer.format.FieldFormatModel;
|
import ghidra.app.util.viewer.format.FieldFormatModel;
|
||||||
import ghidra.app.util.viewer.proxy.FunctionProxy;
|
import ghidra.app.util.viewer.proxy.FunctionProxy;
|
||||||
|
@ -32,7 +33,8 @@ import ghidra.app.util.viewer.proxy.ProxyObj;
|
||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.Options;
|
||||||
import ghidra.framework.options.ToolOptions;
|
import ghidra.framework.options.ToolOptions;
|
||||||
import ghidra.program.model.listing.*;
|
import ghidra.program.model.listing.*;
|
||||||
import ghidra.program.model.symbol.*;
|
import ghidra.program.model.symbol.SourceType;
|
||||||
|
import ghidra.program.model.symbol.Symbol;
|
||||||
import ghidra.program.util.*;
|
import ghidra.program.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +47,8 @@ public class FunctionSignatureFieldFactory extends FieldFactory {
|
||||||
public final static String DISPLAY_NAMESPACE =
|
public final static String DISPLAY_NAMESPACE =
|
||||||
GROUP_TITLE + Options.DELIMITER + GhidraOptions.DISPLAY_NAMESPACE;
|
GROUP_TITLE + Options.DELIMITER + GhidraOptions.DISPLAY_NAMESPACE;
|
||||||
|
|
||||||
|
private SymbolInspector inspector;
|
||||||
|
|
||||||
private boolean displayFunctionScope;
|
private boolean displayFunctionScope;
|
||||||
|
|
||||||
public FunctionSignatureFieldFactory() {
|
public FunctionSignatureFieldFactory() {
|
||||||
|
@ -58,13 +62,16 @@ public class FunctionSignatureFieldFactory extends FieldFactory {
|
||||||
* @param displayOptions the Options for display properties.
|
* @param displayOptions the Options for display properties.
|
||||||
* @param fieldOptions the Options for field specific properties.
|
* @param fieldOptions the Options for field specific properties.
|
||||||
*/
|
*/
|
||||||
public FunctionSignatureFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
|
public FunctionSignatureFieldFactory(FieldFormatModel model,
|
||||||
|
ListingHighlightProvider hlProvider,
|
||||||
ToolOptions displayOptions, ToolOptions fieldOptions) {
|
ToolOptions displayOptions, ToolOptions fieldOptions) {
|
||||||
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
|
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
|
||||||
|
|
||||||
fieldOptions.registerOption(DISPLAY_NAMESPACE, false, null,
|
fieldOptions.registerOption(DISPLAY_NAMESPACE, false, null,
|
||||||
"Prepends namespaces to labels that are not in the global namespace.");
|
"Prepends namespaces to labels that are not in the global namespace.");
|
||||||
|
|
||||||
|
inspector = new SymbolInspector(displayOptions, null);
|
||||||
|
|
||||||
displayFunctionScope = fieldOptions.getBoolean(DISPLAY_NAMESPACE, false);
|
displayFunctionScope = fieldOptions.getBoolean(DISPLAY_NAMESPACE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,27 +225,8 @@ public class FunctionSignatureFieldFactory extends FieldFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color getFunctionNameColor(Function function) {
|
private Color getFunctionNameColor(Function function) {
|
||||||
// override function name color for external thunks which are not linked
|
Symbol s = function.getSymbol();
|
||||||
if (function.isThunk()) {
|
return inspector.getColor(s);
|
||||||
Function thunkedFunction = function.getThunkedFunction(true);
|
|
||||||
if (thunkedFunction == null) {
|
|
||||||
return ListingColors.EXT_REF_UNRESOLVED;
|
|
||||||
}
|
|
||||||
else if (thunkedFunction.isExternal()) {
|
|
||||||
ExternalLocation externalLocation = thunkedFunction.getExternalLocation();
|
|
||||||
String libName = externalLocation.getLibraryName();
|
|
||||||
if (Library.UNKNOWN.equals(libName)) {
|
|
||||||
return ListingColors.EXT_REF_UNRESOLVED;
|
|
||||||
}
|
|
||||||
ExternalManager externalManager = function.getProgram().getExternalManager();
|
|
||||||
String path = externalManager.getExternalLibraryPath(libName);
|
|
||||||
if (path == null || path.length() == 0) {
|
|
||||||
return ListingColors.EXT_REF_UNRESOLVED;
|
|
||||||
}
|
|
||||||
return ListingColors.EXT_REF_RESOLVED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FunctionColors.NAME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -148,7 +148,6 @@ public class LabelFieldFactory extends FieldFactory {
|
||||||
Address currAddr = cu.getMinAddress();
|
Address currAddr = cu.getMinAddress();
|
||||||
|
|
||||||
Program prog = cu.getProgram();
|
Program prog = cu.getProgram();
|
||||||
inspector.setProgram(prog);
|
|
||||||
|
|
||||||
Listing list = prog.getListing();
|
Listing list = prog.getListing();
|
||||||
Function func = list.getFunctionAt(currAddr);
|
Function func = list.getFunctionAt(currAddr);
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -67,7 +67,6 @@ abstract class OperandFieldHelper extends FieldFactory {
|
||||||
private SymbolInspector inspector;
|
private SymbolInspector inspector;
|
||||||
|
|
||||||
private ColorStyleAttributes addressAttributes = new ColorStyleAttributes();
|
private ColorStyleAttributes addressAttributes = new ColorStyleAttributes();
|
||||||
private ColorStyleAttributes externalRefAttributes = new ColorStyleAttributes();
|
|
||||||
private ColorStyleAttributes badRefAttributes = new ColorStyleAttributes();
|
private ColorStyleAttributes badRefAttributes = new ColorStyleAttributes();
|
||||||
private ColorStyleAttributes separatorAttributes = new ColorStyleAttributes();
|
private ColorStyleAttributes separatorAttributes = new ColorStyleAttributes();
|
||||||
private ColorStyleAttributes scalarAttributes = new ColorStyleAttributes();
|
private ColorStyleAttributes scalarAttributes = new ColorStyleAttributes();
|
||||||
|
@ -646,21 +645,16 @@ abstract class OperandFieldHelper extends FieldFactory {
|
||||||
|
|
||||||
ReferenceManager refMgr = p.getReferenceManager();
|
ReferenceManager refMgr = p.getReferenceManager();
|
||||||
Reference[] refs = refMgr.getReferencesFrom(cu.getMinAddress(), opIndex);
|
Reference[] refs = refMgr.getReferencesFrom(cu.getMinAddress(), opIndex);
|
||||||
for (Reference element : refs) {
|
for (Reference ref : refs) {
|
||||||
if (element.isExternalReference()) {
|
|
||||||
ExternalManager extMgr = p.getExternalManager();
|
|
||||||
ExternalLocation extLoc = ((ExternalReference) element).getExternalLocation();
|
|
||||||
|
|
||||||
// has external reference been resolved?
|
// handle external references
|
||||||
String path = extMgr.getExternalLibraryPath(extLoc.getLibraryName());
|
ColorAndStyle c = inspector.getColorAndStyle(p, ref);
|
||||||
if (path != null && path.length() > 0) {
|
if (c != null) {
|
||||||
return externalRefAttributes;
|
ColorStyleAttributes newAttributes = new ColorStyleAttributes();
|
||||||
}
|
newAttributes.colorAttribute = c.getColor();
|
||||||
return badRefAttributes;
|
newAttributes.styleAttribute = c.getStyle();
|
||||||
|
return newAttributes;
|
||||||
}
|
}
|
||||||
// if (refs[i].isVariableReference()) {
|
|
||||||
// return globalFrameRefAttributes;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference mr = refMgr.getPrimaryReferenceFrom(cu.getMinAddress(), opIndex);
|
Reference mr = refMgr.getPrimaryReferenceFrom(cu.getMinAddress(), opIndex);
|
||||||
|
@ -687,27 +681,25 @@ abstract class OperandFieldHelper extends FieldFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the font and color to use to render an operand when that operand
|
* Determine the font and color to use to render an operand when that operand is a reference.
|
||||||
* is a reference.
|
|
||||||
*/
|
*/
|
||||||
private ColorStyleAttributes getAddressAttributes(CodeUnit cu, Address destAddr, int opIndex,
|
private ColorStyleAttributes getAddressAttributes(CodeUnit cu, Address destAddr, int opIndex,
|
||||||
Program program) {
|
Program p) {
|
||||||
|
|
||||||
if (destAddr == null) {
|
if (destAddr == null) {
|
||||||
return separatorAttributes;
|
return separatorAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destAddr.isMemoryAddress() && !program.getMemory().contains(destAddr)) {
|
if (destAddr.isMemoryAddress() && !p.getMemory().contains(destAddr)) {
|
||||||
return badRefAttributes;
|
return badRefAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolTable st = program.getSymbolTable();
|
SymbolTable st = p.getSymbolTable();
|
||||||
ReferenceManager refMgr = program.getReferenceManager();
|
ReferenceManager refMgr = p.getReferenceManager();
|
||||||
|
|
||||||
Reference ref = refMgr.getReference(cu.getMinAddress(), destAddr, opIndex);
|
Reference ref = refMgr.getReference(cu.getMinAddress(), destAddr, opIndex);
|
||||||
Symbol sym = st.getSymbol(ref);
|
Symbol sym = st.getSymbol(ref);
|
||||||
if (sym != null) {
|
if (sym != null) {
|
||||||
inspector.setProgram(program);
|
|
||||||
ColorStyleAttributes newAttributes = new ColorStyleAttributes();
|
ColorStyleAttributes newAttributes = new ColorStyleAttributes();
|
||||||
ColorAndStyle c = inspector.getColorAndStyle(sym);
|
ColorAndStyle c = inspector.getColorAndStyle(sym);
|
||||||
newAttributes.colorAttribute = c.getColor();
|
newAttributes.colorAttribute = c.getColor();
|
||||||
|
@ -727,7 +719,6 @@ abstract class OperandFieldHelper extends FieldFactory {
|
||||||
scalarAttributes.colorAttribute = ListingColors.CONSTANT;
|
scalarAttributes.colorAttribute = ListingColors.CONSTANT;
|
||||||
variableRefAttributes.colorAttribute = FunctionColors.VARIABLE;
|
variableRefAttributes.colorAttribute = FunctionColors.VARIABLE;
|
||||||
addressAttributes.colorAttribute = ListingColors.ADDRESS;
|
addressAttributes.colorAttribute = ListingColors.ADDRESS;
|
||||||
externalRefAttributes.colorAttribute = ListingColors.EXT_REF_RESOLVED;
|
|
||||||
badRefAttributes.colorAttribute = ListingColors.REF_BAD;
|
badRefAttributes.colorAttribute = ListingColors.REF_BAD;
|
||||||
registerAttributes.colorAttribute = ListingColors.REGISTER;
|
registerAttributes.colorAttribute = ListingColors.REGISTER;
|
||||||
|
|
||||||
|
@ -739,8 +730,6 @@ abstract class OperandFieldHelper extends FieldFactory {
|
||||||
options.getInt(OptionsGui.VARIABLE.getStyleOptionName(), -1);
|
options.getInt(OptionsGui.VARIABLE.getStyleOptionName(), -1);
|
||||||
addressAttributes.styleAttribute =
|
addressAttributes.styleAttribute =
|
||||||
options.getInt(OptionsGui.ADDRESS.getStyleOptionName(), -1);
|
options.getInt(OptionsGui.ADDRESS.getStyleOptionName(), -1);
|
||||||
externalRefAttributes.styleAttribute =
|
|
||||||
options.getInt(OptionsGui.EXT_REF_RESOLVED.getStyleOptionName(), -1);
|
|
||||||
badRefAttributes.styleAttribute =
|
badRefAttributes.styleAttribute =
|
||||||
options.getInt(OptionsGui.BAD_REF_ADDR.getStyleOptionName(), -1);
|
options.getInt(OptionsGui.BAD_REF_ADDR.getStyleOptionName(), -1);
|
||||||
registerAttributes.styleAttribute =
|
registerAttributes.styleAttribute =
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -60,6 +60,7 @@ public class OptionsGui extends JPanel {
|
||||||
public static final ScreenElement ENTRY_POINT = new ScreenElement("Entry Point", ListingColors.EXT_ENTRY_POINT);
|
public static final ScreenElement ENTRY_POINT = new ScreenElement("Entry Point", ListingColors.EXT_ENTRY_POINT);
|
||||||
public static final ScreenElement COMMENT_EOL = new ScreenElement("Comment, EOL", "EOL Comment", CommentColors.EOL);
|
public static final ScreenElement COMMENT_EOL = new ScreenElement("Comment, EOL", "EOL Comment", CommentColors.EOL);
|
||||||
public static final ScreenElement EXT_REF_RESOLVED = new ScreenElement("External Reference, Resolved", ListingColors.EXT_REF_RESOLVED);
|
public static final ScreenElement EXT_REF_RESOLVED = new ScreenElement("External Reference, Resolved", ListingColors.EXT_REF_RESOLVED);
|
||||||
|
public static final ScreenElement EXT_REF_UNRESOLVED = new ScreenElement("External Reference, Unresolved", ListingColors.EXT_REF_UNRESOLVED);
|
||||||
public static final ScreenElement FIELD_NAME = new ScreenElement("Field Name", ListingColors.FIELD_NAME);
|
public static final ScreenElement FIELD_NAME = new ScreenElement("Field Name", ListingColors.FIELD_NAME);
|
||||||
public static final ScreenElement FUN_CALL_FIXUP = new ScreenElement("Function Call-Fixup", FunctionColors.CALL_FIXUP);
|
public static final ScreenElement FUN_CALL_FIXUP = new ScreenElement("Function Call-Fixup", FunctionColors.CALL_FIXUP);
|
||||||
public static final ScreenElement FUN_NAME = new ScreenElement("Function Name", FunctionColors.NAME);
|
public static final ScreenElement FUN_NAME = new ScreenElement("Function Name", FunctionColors.NAME);
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -346,7 +346,6 @@ public class VTMarkupItemsTableModel extends AddressBasedTableModel<VTMarkupItem
|
||||||
}
|
}
|
||||||
Color c = FG_ERROR;
|
Color c = FG_ERROR;
|
||||||
if (symbolInspector != null) {
|
if (symbolInspector != null) {
|
||||||
symbolInspector.setProgram(program);
|
|
||||||
c = symbolInspector.getColor(s);
|
c = symbolInspector.getColor(s);
|
||||||
}
|
}
|
||||||
setForeground(c);
|
setForeground(c);
|
||||||
|
@ -481,7 +480,6 @@ public class VTMarkupItemsTableModel extends AddressBasedTableModel<VTMarkupItem
|
||||||
}
|
}
|
||||||
Color c = FG_ERROR;
|
Color c = FG_ERROR;
|
||||||
if (symbolInspector != null) {
|
if (symbolInspector != null) {
|
||||||
symbolInspector.setProgram(program);
|
|
||||||
c = symbolInspector.getColor(s);
|
c = symbolInspector.getColor(s);
|
||||||
}
|
}
|
||||||
setForeground(c);
|
setForeground(c);
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -587,7 +587,6 @@ public abstract class AbstractVTMatchTableModel extends AddressBasedTableModel<V
|
||||||
renderer.setToolTipText(symbol.getName(true));
|
renderer.setToolTipText(symbol.getName(true));
|
||||||
}
|
}
|
||||||
if (symbolInspector != null) {
|
if (symbolInspector != null) {
|
||||||
symbolInspector.setProgram(symbol.getProgram());
|
|
||||||
renderer.setForeground(symbolInspector.getColor(symbol));
|
renderer.setForeground(symbolInspector.getColor(symbol));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -716,7 +715,6 @@ public abstract class AbstractVTMatchTableModel extends AddressBasedTableModel<V
|
||||||
Address address = displayableAddress.getAddress();
|
Address address = displayableAddress.getAddress();
|
||||||
if (!address.isMemoryAddress() && symbolInspector != null) {
|
if (!address.isMemoryAddress() && symbolInspector != null) {
|
||||||
Symbol s = program.getSymbolTable().getPrimarySymbol(address);
|
Symbol s = program.getSymbolTable().getPrimarySymbol(address);
|
||||||
symbolInspector.setProgram(program);
|
|
||||||
Color c = (s != null) ? symbolInspector.getColor(s) : FG_ERROR;
|
Color c = (s != null) ? symbolInspector.getColor(s) : FG_ERROR;
|
||||||
setForeground(c);
|
setForeground(c);
|
||||||
}
|
}
|
||||||
|
@ -826,7 +824,6 @@ public abstract class AbstractVTMatchTableModel extends AddressBasedTableModel<V
|
||||||
renderer.setToolTipText(symbol.getName(true));
|
renderer.setToolTipText(symbol.getName(true));
|
||||||
}
|
}
|
||||||
if (symbolInspector != null) {
|
if (symbolInspector != null) {
|
||||||
symbolInspector.setProgram(symbol.getProgram());
|
|
||||||
renderer.setForeground(symbolInspector.getColor(symbol));
|
renderer.setForeground(symbolInspector.getColor(symbol));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -955,7 +952,6 @@ public abstract class AbstractVTMatchTableModel extends AddressBasedTableModel<V
|
||||||
Address address = displayableAddress.getAddress();
|
Address address = displayableAddress.getAddress();
|
||||||
if (!address.isMemoryAddress() && symbolInspector != null) {
|
if (!address.isMemoryAddress() && symbolInspector != null) {
|
||||||
Symbol s = program.getSymbolTable().getPrimarySymbol(address);
|
Symbol s = program.getSymbolTable().getPrimarySymbol(address);
|
||||||
symbolInspector.setProgram(program);
|
|
||||||
Color c = (s != null) ? symbolInspector.getColor(s) : FG_ERROR;
|
Color c = (s != null) ? symbolInspector.getColor(s) : FG_ERROR;
|
||||||
setForeground(c);
|
setForeground(c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -53,7 +53,6 @@ public class VTSymbolRenderer extends GhidraTableCellRenderer {
|
||||||
Color color = Colors.FOREGROUND;
|
Color color = Colors.FOREGROUND;
|
||||||
if (value instanceof Symbol) {
|
if (value instanceof Symbol) {
|
||||||
Symbol s = (Symbol) value;
|
Symbol s = (Symbol) value;
|
||||||
inspector.setProgram(s.getProgram());
|
|
||||||
color = inspector.getColor(s);
|
color = inspector.getColor(s);
|
||||||
}
|
}
|
||||||
setForeground(color);
|
setForeground(color);
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -35,7 +35,7 @@ public interface ExternalManager {
|
||||||
* @return array of external names
|
* @return array of external names
|
||||||
*/
|
*/
|
||||||
public String[] getExternalLibraryNames();
|
public String[] getExternalLibraryNames();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Library which corresponds to the specified name
|
* Get the Library which corresponds to the specified name
|
||||||
* @param libraryName name of library
|
* @param libraryName name of library
|
||||||
|
@ -64,7 +64,7 @@ public interface ExternalManager {
|
||||||
* @param libraryName the name of the library to associate with a file.
|
* @param libraryName the name of the library to associate with a file.
|
||||||
* @param pathname the path to the program to be associated with the library name.
|
* @param pathname the path to the program to be associated with the library name.
|
||||||
* @param userDefined true if the external path is being specified by the user
|
* @param userDefined true if the external path is being specified by the user
|
||||||
* @throws InvalidInputException
|
* @throws InvalidInputException on invalid input
|
||||||
*/
|
*/
|
||||||
public void setExternalPath(String libraryName, String pathname, boolean userDefined)
|
public void setExternalPath(String libraryName, String pathname, boolean userDefined)
|
||||||
throws InvalidInputException;
|
throws InvalidInputException;
|
||||||
|
@ -75,7 +75,7 @@ public interface ExternalManager {
|
||||||
* @param newName the new name of the external library name.
|
* @param newName the new name of the external library name.
|
||||||
* @param source the source of this external library
|
* @param source the source of this external library
|
||||||
* @throws DuplicateNameException if another namespace has the same name
|
* @throws DuplicateNameException if another namespace has the same name
|
||||||
* @throws InvalidInputException
|
* @throws InvalidInputException on invalid input
|
||||||
*/
|
*/
|
||||||
public void updateExternalLibraryName(String oldName, String newName, SourceType source)
|
public void updateExternalLibraryName(String oldName, String newName, SourceType source)
|
||||||
throws DuplicateNameException, InvalidInputException;
|
throws DuplicateNameException, InvalidInputException;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue