Ghidra is a software reverse engineering (SRE) framework
Merge remote-tracking branch 'origin/GP-4131_Dan_fixModelTreeCorruption--SQUASHED'
Ryan Kurtz1c414dfac5c0
diff --cc Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/DebuggerModelProviderTest.javaindex 7d10b8dbd3,5a4ae3a346..1832d3a588--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/DebuggerModelProviderTest.java+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/DebuggerModelProviderTest.java@@@ -1030,30 -1029,102 +1029,129 @@@ public class DebuggerModelProviderTest}@Test+ public void testSetValueAffectsTree() throws Throwable {+ createTraceAndPopulateObjects();++ TraceObjectKeyPath threadsPath = TraceObjectKeyPath.parse("Processes[0].Threads");+ TraceObject threads = tb.trace.getObjectManager().getObjectByCanonicalPath(threadsPath);+ TraceObject thread0 =+ tb.trace.getObjectManager().getObjectByCanonicalPath(threadsPath.index(0));++ traceManager.activateTrace(tb.trace);+ traceManager.activateSnap(1);+ waitForSwing();++ modelProvider.setPath(threadsPath);+ waitForTasks();++ AbstractNode node =+ waitForValue(() -> modelProvider.objectsTreePanel.treeModel.getNode(threadsPath));+ assertEquals(10, node.getChildren().size());++ try (Transaction tx = tb.startTransaction()) {+ threads.setAttribute(Lifespan.nowOn(0), "Current", thread0);+ }+ waitForTasks();++ assertEquals(11, node.getChildren().size());+ }+++ public void testDuplicateNameInSameParentDoesntCorruptTree() throws Throwable {+ createTraceAndPopulateObjects();+ TraceObjectKeyPath threadsPath = TraceObjectKeyPath.parse("Processes[0].Threads");+ TraceObject threads = tb.trace.getObjectManager().getObjectByCanonicalPath(threadsPath);+ TraceObject thread0 =+ tb.trace.getObjectManager().getObjectByCanonicalPath(threadsPath.index(0));++ traceManager.activateTrace(tb.trace);+ traceManager.activateSnap(1);+ waitForSwing();++ modelProvider.setPath(threadsPath);+ modelProvider.setLimitToCurrentSnap(false);+ waitForTasks();++ AbstractNode node =+ waitForValue(() -> modelProvider.objectsTreePanel.treeModel.getNode(threadsPath));++ try (Transaction tx = tb.startTransaction()) {+ threads.setAttribute(Lifespan.at(0), "CurrentA", thread0);+ threads.setAttribute(Lifespan.at(2), "CurrentA", thread0);+ threads.setAttribute(Lifespan.at(0), "CurrentB", thread0);+ threads.setAttribute(Lifespan.at(2), "CurrentB", thread0);+ }+ waitForTasks();++ node.unloadChildren();+ node.expand();+ waitForTasks();++ assertEquals(14, node.getChildCount());+ Map<String, List<GTreeNode>> byName =+ node.getChildren().stream().collect(Collectors.groupingBy(n -> n.getName()));+ assertTrue(byName.values().stream().allMatch(c -> c.size() == 1));+ }++ // @Test+ public void testDuplicateNameInDifferentParentsDoesntCorruptTree() throws Throwable {+ // Unfinished.TODO();+ // This is already covered. Processes has a [0] and Threads also has a [0].+ }++ @Test+ public void testDuplicateNameDifferentLifespanAppearInAttributesTable() throws Throwable {+ createTraceAndPopulateObjects();+ TraceObjectKeyPath threadsPath = TraceObjectKeyPath.parse("Processes[0].Threads");+ TraceObject threads = tb.trace.getObjectManager().getObjectByCanonicalPath(threadsPath);+ TraceObject thread0 =+ tb.trace.getObjectManager().getObjectByCanonicalPath(threadsPath.index(0));++ traceManager.activateTrace(tb.trace);+ traceManager.activateSnap(1);+ waitForSwing();++ modelProvider.setPath(threadsPath);+ modelProvider.setLimitToCurrentSnap(false);+ waitForTasks();++ try (Transaction tx = tb.startTransaction()) {+ threads.setAttribute(Lifespan.at(0), "CurrentA", thread0);+ threads.setAttribute(Lifespan.at(2), "CurrentA", thread0);+ threads.setAttribute(Lifespan.at(0), "CurrentB", thread0);+ threads.setAttribute(Lifespan.at(2), "CurrentB", thread0);+ }+ waitForTasks();++ assertEquals(4, modelProvider.attributesTablePanel.tableModel.getModelData().size());+ }++ @Test+ public void testDuplicateNameDifferentLifespanAppearInElementsTable() throws Throwable {+ createTraceAndPopulateObjects();+ TraceObjectKeyPath threadsPath = TraceObjectKeyPath.parse("Processes[0].Threads");+ TraceObject threads = tb.trace.getObjectManager().getObjectByCanonicalPath(threadsPath);+ TraceObject thread0 =+ tb.trace.getObjectManager().getObjectByCanonicalPath(threadsPath.index(0));++ traceManager.activateTrace(tb.trace);+ traceManager.activateSnap(1);+ waitForSwing();++ modelProvider.setPath(threadsPath);+ modelProvider.setLimitToCurrentSnap(false);+ waitForTasks();++ try (Transaction tx = tb.startTransaction()) {+ threads.setElement(Lifespan.at(0), "CurrentA", thread0);+ threads.setElement(Lifespan.at(2), "CurrentA", thread0);+ threads.setElement(Lifespan.at(0), "CurrentB", thread0);+ threads.setElement(Lifespan.at(2), "CurrentB", thread0);+ }+ waitForTasks();++ // TODO: Should I collapse entries that are links to the same object?+ // Would use the "Life" column to display span for each included entry.+ // Neat, but not sure it's worth it+ assertEquals(14, modelProvider.elementsTablePanel.tableModel.getModelData().size());+ }}