mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch 'origin/GT-2846-2847-dragonmacher-decompiler-navigation'
This commit is contained in:
commit
44e8f64d7e
17 changed files with 705 additions and 316 deletions
|
@ -36,6 +36,7 @@ import ghidra.program.model.address.*;
|
|||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.symbol.Reference;
|
||||
import ghidra.util.datastruct.LRUMap;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class ProgramBigListingModel implements ListingModel, FormatModelListener,
|
||||
|
@ -51,6 +52,9 @@ public class ProgramBigListingModel implements ListingModel, FormatModelListener
|
|||
private DummyFieldFactory dummyFactory;
|
||||
private List<ListingModelListener> listeners = new ArrayList<>();
|
||||
|
||||
// Use a cache so that simple arrowing to-and-fro with the keyboard will respond quickly
|
||||
private LRUMap<Address, Layout> layoutCache = new LRUMap<>(10);
|
||||
|
||||
public ProgramBigListingModel(Program program, FormatManager formatMgr) {
|
||||
this.program = program;
|
||||
this.listing = program.getListing();
|
||||
|
@ -87,6 +91,10 @@ public class ProgramBigListingModel implements ListingModel, FormatModelListener
|
|||
showNonExternalFunctionPointerFormat = (Boolean) newValue;
|
||||
formatModelChanged(null);
|
||||
}
|
||||
|
||||
// There are quite a few options that affect the display of the the layouts. Flush
|
||||
// the cache on any change, as it is simpler than tracking individual options.
|
||||
layoutCache.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,6 +123,16 @@ public class ProgramBigListingModel implements ListingModel, FormatModelListener
|
|||
|
||||
@Override
|
||||
public Layout getLayout(Address addr, boolean isGapAddress) {
|
||||
|
||||
Layout layout = layoutCache.get(addr);
|
||||
if (layout == null) {
|
||||
layout = doGetLayout(addr, isGapAddress);
|
||||
layoutCache.put(addr, layout);
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
|
||||
public Layout doGetLayout(Address addr, boolean isGapAddress) {
|
||||
List<RowLayout> list = new ArrayList<>();
|
||||
FieldFormatModel format;
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr);
|
||||
|
@ -477,12 +495,16 @@ public class ProgramBigListingModel implements ListingModel, FormatModelListener
|
|||
}
|
||||
|
||||
protected void notifyDataChanged(boolean updateImmediately) {
|
||||
layoutCache.clear();
|
||||
|
||||
for (ListingModelListener listener : listeners) {
|
||||
listener.dataChanged(updateImmediately);
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyModelSizeChanged() {
|
||||
layoutCache.clear();
|
||||
|
||||
for (ListingModelListener listener : listeners) {
|
||||
listener.modelSizeChanged();
|
||||
}
|
||||
|
@ -523,15 +545,14 @@ public class ProgramBigListingModel implements ListingModel, FormatModelListener
|
|||
return program.isClosed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.framework.model.DomainObjectListener#domainObjectChanged(ghidra.framework.model.DomainObjectChangedEvent)
|
||||
*/
|
||||
@Override
|
||||
public void domainObjectChanged(DomainObjectChangedEvent ev) {
|
||||
if (!program.isClosed()) {
|
||||
boolean updateImmediately = ev.numRecords() <= 5;
|
||||
notifyDataChanged(updateImmediately);
|
||||
if (program.isClosed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean updateImmediately = ev.numRecords() <= 5;
|
||||
notifyDataChanged(updateImmediately);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -70,7 +70,7 @@ public abstract class AbstractProgramBasedTest extends AbstractGhidraHeadedInteg
|
|||
* Override this method if you need to build your own program.
|
||||
*
|
||||
* @return the program to use for this test.
|
||||
* @throws Exception if an exceptioun is thrown opening the program
|
||||
* @throws Exception if an exception is thrown opening the program
|
||||
*/
|
||||
protected Program getProgram() throws Exception {
|
||||
return env.getProgram(getProgramName());
|
||||
|
|
|
@ -56,10 +56,6 @@ public class OperandFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest
|
|||
private Options fieldOptions;
|
||||
private Program program;
|
||||
|
||||
public OperandFieldFactoryTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
|
|
|
@ -41,10 +41,6 @@ public class PostCommentFieldFactoryTest extends AbstractGhidraHeadedIntegration
|
|||
private Options fieldOptions;
|
||||
private Program program;
|
||||
|
||||
public PostCommentFieldFactoryTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue