mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
updates from review
This commit is contained in:
parent
755dc694e1
commit
1d31b87eba
5 changed files with 21 additions and 145 deletions
|
@ -1241,14 +1241,9 @@ public class CodeBrowserPlugin extends Plugin
|
|||
tool.setConfigChanged(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Layout getLayout(Address addr) {
|
||||
return connectedProvider.getListingPanel().getLayout(addr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListingModel getListingModel() {
|
||||
return connectedProvider.getListingPanel().getListingModel();
|
||||
return connectedProvider.getListingPanel().getListingModel().copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@ import javax.swing.JComponent;
|
|||
|
||||
import docking.action.DockingAction;
|
||||
import docking.widgets.fieldpanel.FieldPanel;
|
||||
import docking.widgets.fieldpanel.Layout;
|
||||
import docking.widgets.fieldpanel.field.Field;
|
||||
import ghidra.app.nav.Navigatable;
|
||||
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
|
||||
|
@ -29,7 +28,6 @@ import ghidra.app.util.viewer.format.FormatManager;
|
|||
import ghidra.app.util.viewer.listingpanel.*;
|
||||
import ghidra.app.util.viewer.util.AddressIndexMap;
|
||||
import ghidra.framework.plugintool.ServiceInfo;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
|
@ -165,12 +163,6 @@ public interface CodeViewerService {
|
|||
*/
|
||||
public void setNorthComponent(JComponent comp);
|
||||
|
||||
/**
|
||||
* Returns the Layout of Fields for the given Address.
|
||||
* @param addr the address at which to get a Layout
|
||||
*/
|
||||
public Layout getLayout(Address addr);
|
||||
|
||||
/**
|
||||
* tells the browser to rebuild the display.
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,6 @@ import docking.widgets.fieldpanel.listener.IndexMapper;
|
|||
import docking.widgets.fieldpanel.listener.LayoutModelListener;
|
||||
import docking.widgets.fieldpanel.support.*;
|
||||
import ghidra.app.util.viewer.field.*;
|
||||
import ghidra.app.util.viewer.format.FormatManager;
|
||||
import ghidra.app.util.viewer.util.AddressBasedIndexMapper;
|
||||
import ghidra.app.util.viewer.util.AddressIndexMap;
|
||||
import ghidra.program.model.address.*;
|
||||
|
@ -36,7 +35,6 @@ import ghidra.program.util.*;
|
|||
import ghidra.util.datastruct.WeakDataStructureFactory;
|
||||
import ghidra.util.datastruct.WeakSet;
|
||||
import ghidra.util.task.SwingUpdateManager;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class ListingModelAdapter implements LayoutModel, ListingModelListener {
|
||||
private static Class<?> defaultFieldFactoryClass = AddressFieldFactory.class;
|
||||
|
@ -50,7 +48,7 @@ public class ListingModelAdapter implements LayoutModel, ListingModelListener {
|
|||
private Dimension preferredViewSize;
|
||||
|
||||
public ListingModelAdapter(ListingModel bigListingModel) {
|
||||
this.model = bigListingModel != null ? bigListingModel : new EmptyBigListingModel();
|
||||
this.model = bigListingModel != null ? bigListingModel : new EmptyListingModel();
|
||||
addressToIndexMap = new AddressIndexMap(model.getAddressSet());
|
||||
removeUnviewableAddressRanges();
|
||||
model.addListener(this);
|
||||
|
@ -504,113 +502,6 @@ public class ListingModelAdapter implements LayoutModel, ListingModelListener {
|
|||
}
|
||||
}
|
||||
|
||||
static class EmptyBigListingModel implements ListingModel {
|
||||
@Override
|
||||
public void addListener(ListingModelListener listener) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Address getAddressAfter(Address address) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Address getAddressBefore(Address address) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressSetView getAddressSet() {
|
||||
return new AddressSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Layout getLayout(Address address, boolean isGapAddress) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Program getProgram() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen(Data object) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(ListingModelListener listener) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleOpen(Data object) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openAllData(Data data, TaskMonitor monitor) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeAllData(Data data, TaskMonitor monitor) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openAllData(AddressSetView addresses, TaskMonitor monitor) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeAllData(AddressSetView addresses, TaskMonitor monitor) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeData(Data data) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openData(Data data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFormatManager(FormatManager formatManager) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressSet adjustAddressSetToCodeUnitBoundaries(AddressSet addressSet) {
|
||||
return new AddressSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListingModel copy() {
|
||||
return new EmptyBigListingModel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Layout getLayout(Address addr) {
|
||||
BigInteger index = addressToIndexMap.getIndex(addr);
|
||||
|
|
|
@ -211,7 +211,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
|
|||
* Returns the current ListingModel used by this panel.
|
||||
*/
|
||||
public ListingModel getListingModel() {
|
||||
return listingModel.copy();
|
||||
return listingModel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,6 +51,8 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
private Program program;
|
||||
private AddressFactory addrFactory;
|
||||
private AddressSpace space;
|
||||
private CodeViewerService cvs;
|
||||
private ListingModel listingModel;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
@ -61,7 +63,12 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
cb = env.getPlugin(CodeBrowserPlugin.class);
|
||||
loadProgram("notepad");
|
||||
resetFormatOptions();
|
||||
cvs = tool.getService(CodeViewerService.class);
|
||||
listingModel = cvs.getListingModel();
|
||||
}
|
||||
|
||||
private Layout getLayout(Address addr) {
|
||||
return listingModel.getLayout(addr, false);
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -103,20 +110,18 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
@Test
|
||||
public void testGetLayout() {
|
||||
// env.showTool();
|
||||
CodeViewerService cvs = tool.getService(CodeViewerService.class);
|
||||
assertNull(cvs.getLayout(addr(0)));
|
||||
Layout l = cvs.getLayout(addr(0x1001000));
|
||||
assertNull(getLayout(addr(0)));
|
||||
Layout l = getLayout(addr(0x1001000));
|
||||
assertNotNull(l);
|
||||
assertEquals(6, l.getNumFields());
|
||||
|
||||
assertNull(cvs.getLayout(addr(0x1001001)));
|
||||
assertNull(getLayout(addr(0x1001001)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStringsFromLayout() {
|
||||
env.showTool();
|
||||
CodeViewerService cvs = tool.getService(CodeViewerService.class);
|
||||
Layout l = cvs.getLayout(addr(0x1001008));
|
||||
Layout l = getLayout(addr(0x1001008));
|
||||
|
||||
int n = l.getNumFields();
|
||||
assertEquals(7, n);
|
||||
|
@ -133,8 +138,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
@Test
|
||||
public void testGetStringsFromLayout1() {
|
||||
env.showTool();
|
||||
CodeViewerService cvs = tool.getService(CodeViewerService.class);
|
||||
Layout l = cvs.getLayout(addr(0x1004772));
|
||||
Layout l = getLayout(addr(0x1004772));
|
||||
|
||||
int n = l.getNumFields();
|
||||
assertEquals(4, n);
|
||||
|
@ -147,8 +151,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void testProgramLocation1() {
|
||||
CodeViewerService cvs = tool.getService(CodeViewerService.class);
|
||||
Layout l = cvs.getLayout(addr(0x1004772));
|
||||
Layout l = getLayout(addr(0x1004772));
|
||||
|
||||
ListingField f = (ListingField) l.getField(1);
|
||||
assertEquals("bf 00 01 00 00", f.getText());
|
||||
|
@ -177,8 +180,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
inst.setComment(CodeUnit.EOL_COMMENT, comment);
|
||||
program.endTransaction(id, true);
|
||||
cb.updateNow();
|
||||
CodeViewerService cvs = tool.getService(CodeViewerService.class);
|
||||
Layout l = cvs.getLayout(addr(0x1004772));
|
||||
Layout l = getLayout(addr(0x1004772));
|
||||
env.showTool();
|
||||
|
||||
ListingField f = (ListingField) l.getField(4);
|
||||
|
@ -213,8 +215,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
opt.setBoolean("EOL Comments Field.Enable Word Wrapping", true);
|
||||
|
||||
cb.updateNow();
|
||||
CodeViewerService cvs = tool.getService(CodeViewerService.class);
|
||||
Layout l = cvs.getLayout(addr(0x1004772));
|
||||
Layout l = getLayout(addr(0x1004772));
|
||||
env.showTool();
|
||||
|
||||
ListingField f = (ListingField) l.getField(4);
|
||||
|
@ -252,8 +253,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
opt.setBoolean("EOL Comments Field.Enable Word Wrapping", true);
|
||||
|
||||
cb.updateNow();
|
||||
CodeViewerService cvs = tool.getService(CodeViewerService.class);
|
||||
Layout l = cvs.getLayout(addr(0x1004772));
|
||||
Layout l = getLayout(addr(0x1004772));
|
||||
env.showTool();
|
||||
|
||||
ListingField f = (ListingField) l.getField(4);
|
||||
|
@ -290,8 +290,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
// opt.putBoolean("test", "EOL Comments Field.Enable Word Wrapping", true);
|
||||
|
||||
cb.updateNow();
|
||||
CodeViewerService cvs = tool.getService(CodeViewerService.class);
|
||||
Layout l = cvs.getLayout(addr(0x1004772));
|
||||
Layout l = getLayout(addr(0x1004772));
|
||||
env.showTool();
|
||||
|
||||
ListingField f = (ListingField) l.getField(4);
|
||||
|
@ -332,8 +331,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
Options fieldOptions = cb.getFormatManager().getFieldOptions();
|
||||
List<String> names = fieldOptions.getOptionNames();
|
||||
|
||||
for (int i = 0; i < names.size(); i++) {
|
||||
String name = names.get(i);
|
||||
for (String name : names) {
|
||||
if (!name.startsWith("Format Code")) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue