mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-0: Fixes for tests post GP-2676/3028
This commit is contained in:
parent
b0d6534d39
commit
f053f147ac
6 changed files with 37 additions and 66 deletions
|
@ -230,7 +230,7 @@ public class DebuggerLogicalBreakpointServicePlugin extends Plugin
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.trackTraceBreakpoint(c.a, tb, false);
|
info.trackTraceBreakpoint(c.a, tb, getMode(info.trace), false);
|
||||||
}
|
}
|
||||||
catch (TrackedTooSoonException e) {
|
catch (TrackedTooSoonException e) {
|
||||||
Msg.info(this,
|
Msg.info(this,
|
||||||
|
@ -243,7 +243,7 @@ public class DebuggerLogicalBreakpointServicePlugin extends Plugin
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.trackTraceBreakpoint(c.a, tb, true);
|
info.trackTraceBreakpoint(c.a, tb, getMode(info.trace), true);
|
||||||
}
|
}
|
||||||
catch (TrackedTooSoonException e) {
|
catch (TrackedTooSoonException e) {
|
||||||
Msg.info(this,
|
Msg.info(this,
|
||||||
|
@ -269,7 +269,7 @@ public class DebuggerLogicalBreakpointServicePlugin extends Plugin
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
info.trackTraceBreakpoint(c.a, tb, false);
|
info.trackTraceBreakpoint(c.a, tb, getMode(info.trace), false);
|
||||||
}
|
}
|
||||||
catch (TrackedTooSoonException e) {
|
catch (TrackedTooSoonException e) {
|
||||||
Msg.info(this, "Ignoring " + tb +
|
Msg.info(this, "Ignoring " + tb +
|
||||||
|
@ -553,28 +553,17 @@ public class DebuggerLogicalBreakpointServicePlugin extends Plugin
|
||||||
}
|
}
|
||||||
Collection<TraceBreakpoint> visible = new ArrayList<>();
|
Collection<TraceBreakpoint> visible = new ArrayList<>();
|
||||||
for (AddressRange range : trace.getBaseAddressFactory().getAddressSet()) {
|
for (AddressRange range : trace.getBaseAddressFactory().getAddressSet()) {
|
||||||
Collection<? extends TraceBreakpoint> breaks = trace
|
visible.addAll(trace.getBreakpointManager()
|
||||||
.getBreakpointManager()
|
.getBreakpointsIntersecting(Lifespan.at(snap), range));
|
||||||
.getBreakpointsIntersecting(Lifespan.at(snap), range);
|
|
||||||
if (mode.useEmulatedBreakpoints()) {
|
|
||||||
visible.addAll(breaks);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (TraceBreakpoint tb : breaks) {
|
|
||||||
if (recorder.getTargetBreakpoint(tb) != null) {
|
|
||||||
visible.add(tb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
trackTraceBreakpoints(a, visible);
|
trackTraceBreakpoints(a, visible, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void trackTraceBreakpoints(AddCollector a,
|
protected void trackTraceBreakpoints(AddCollector a,
|
||||||
Collection<TraceBreakpoint> breakpoints) {
|
Collection<TraceBreakpoint> breakpoints, StateEditingMode mode) {
|
||||||
for (TraceBreakpoint tb : breakpoints) {
|
for (TraceBreakpoint tb : breakpoints) {
|
||||||
try {
|
try {
|
||||||
trackTraceBreakpoint(a, tb, false);
|
trackTraceBreakpoint(a, tb, mode, false);
|
||||||
}
|
}
|
||||||
catch (TrackedTooSoonException e) {
|
catch (TrackedTooSoonException e) {
|
||||||
// This can still happen during reload (on OBJECT_RESTORED)
|
// This can still happen during reload (on OBJECT_RESTORED)
|
||||||
|
@ -597,8 +586,13 @@ public class DebuggerLogicalBreakpointServicePlugin extends Plugin
|
||||||
new DefaultTraceLocation(trace, null, Lifespan.at(snap), tb.getMinAddress()));
|
new DefaultTraceLocation(trace, null, Lifespan.at(snap), tb.getMinAddress()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void trackTraceBreakpoint(AddCollector a, TraceBreakpoint tb, boolean forceUpdate)
|
protected void trackTraceBreakpoint(AddCollector a, TraceBreakpoint tb,
|
||||||
|
StateEditingMode mode, boolean forceUpdate)
|
||||||
throws TrackedTooSoonException {
|
throws TrackedTooSoonException {
|
||||||
|
if (!mode.useEmulatedBreakpoints() &&
|
||||||
|
(recorder == null || recorder.getTargetBreakpoint(tb) == null)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Address traceAddr = tb.getMinAddress();
|
Address traceAddr = tb.getMinAddress();
|
||||||
ProgramLocation progLoc = computeStaticLocation(tb);
|
ProgramLocation progLoc = computeStaticLocation(tb);
|
||||||
LogicalBreakpointInternal lb;
|
LogicalBreakpointInternal lb;
|
||||||
|
|
|
@ -807,7 +807,9 @@ public class DebuggerTraceManagerServicePlugin extends Plugin
|
||||||
}
|
}
|
||||||
varView.setSnap(snap);
|
varView.setSnap(snap);
|
||||||
fireLocationEvent(coordinates, cause);
|
fireLocationEvent(coordinates, cause);
|
||||||
}, SwingExecutorService.LATER); // Not MAYBE_NOW lest snap events get out of order
|
}, cause == ActivationCause.EMU_STATE_EDIT
|
||||||
|
? SwingExecutorService.MAYBE_NOW // ProgramView may call .get on Swing thread
|
||||||
|
: SwingExecutorService.LATER); // Respect event order
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireLocationEvent(DebuggerCoordinates coordinates, ActivationCause cause) {
|
protected void fireLocationEvent(DebuggerCoordinates coordinates, ActivationCause cause) {
|
||||||
|
|
|
@ -61,6 +61,10 @@ public interface DebuggerTraceManagerService {
|
||||||
* The change was driven by the recorder advancing a snapshot
|
* The change was driven by the recorder advancing a snapshot
|
||||||
*/
|
*/
|
||||||
FOLLOW_PRESENT,
|
FOLLOW_PRESENT,
|
||||||
|
/**
|
||||||
|
* The tool is activating scratch coordinates to display an emulator state change
|
||||||
|
*/
|
||||||
|
EMU_STATE_EDIT,
|
||||||
/**
|
/**
|
||||||
* The change was caused by a change to the mapper selection, probably indirectly by the
|
* The change was caused by a change to the mapper selection, probably indirectly by the
|
||||||
* user
|
* user
|
||||||
|
|
|
@ -319,7 +319,7 @@ public enum StateEditingMode {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return traceManager.activateAndNotify(withTime, ActivationCause.USER, false);
|
return traceManager.activateAndNotify(withTime, ActivationCause.EMU_STATE_EDIT, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.debug.service.breakpoint;
|
package ghidra.app.plugin.core.debug.service.breakpoint;
|
||||||
|
|
||||||
import static ghidra.lifecycle.Unfinished.TODO;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -26,6 +25,7 @@ import org.junit.*;
|
||||||
|
|
||||||
import generic.Unique;
|
import generic.Unique;
|
||||||
import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
|
import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
|
||||||
|
import ghidra.app.plugin.core.debug.service.editing.DebuggerStateEditingServicePlugin;
|
||||||
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingUtils;
|
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingUtils;
|
||||||
import ghidra.app.services.*;
|
import ghidra.app.services.*;
|
||||||
import ghidra.app.services.LogicalBreakpoint.State;
|
import ghidra.app.services.LogicalBreakpoint.State;
|
||||||
|
@ -547,16 +547,6 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
|
||||||
assertTrue(breakpointService.getAllBreakpoints().isEmpty());
|
assertTrue(breakpointService.getAllBreakpoints().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: When "resume recording" is implemented, consider that a "new" trace may already have
|
|
||||||
* breakpoints
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void testRecordTraceWithBreakpoints() {
|
|
||||||
TODO();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRecordTraceThenOpenTraceThenAddBreakpoint() throws Throwable {
|
public void testRecordTraceThenOpenTraceThenAddBreakpoint() throws Throwable {
|
||||||
startRecorder1();
|
startRecorder1();
|
||||||
|
@ -720,16 +710,6 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
|
||||||
assertLogicalBreakpointForMappedSoftwareBreakpoint(trace);
|
assertLogicalBreakpointForMappedSoftwareBreakpoint(trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: When "resume recording" is implemented, consider that a "new" trace may already have
|
|
||||||
* mappings
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void testOpenProgramWithBookmarkThenRecordTraceWithMapping() {
|
|
||||||
TODO();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOpenProgramThenAddBookmarksThenRecordTraceThenAddMapping() throws Throwable {
|
public void testOpenProgramThenAddBookmarksThenRecordTraceThenAddMapping() throws Throwable {
|
||||||
startRecorder1();
|
startRecorder1();
|
||||||
|
@ -1639,11 +1619,15 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
|
||||||
@Test
|
@Test
|
||||||
public void testAddTraceBreakpointSetSleighThenMapThenSaveToProgramCopiesSleigh()
|
public void testAddTraceBreakpointSetSleighThenMapThenSaveToProgramCopiesSleigh()
|
||||||
throws Throwable {
|
throws Throwable {
|
||||||
|
DebuggerStateEditingService editingService =
|
||||||
|
addPlugin(tool, DebuggerStateEditingServicePlugin.class);
|
||||||
|
|
||||||
// TODO: What if already mapped?
|
// TODO: What if already mapped?
|
||||||
// Not sure I care about tb.setEmuSleigh() out of band
|
// Not sure I care about tb.setEmuSleigh() out of band
|
||||||
|
|
||||||
createTrace();
|
createTrace();
|
||||||
traceManager.openTrace(tb.trace);
|
traceManager.openTrace(tb.trace);
|
||||||
|
editingService.setCurrentMode(tb.trace, StateEditingMode.RW_EMULATOR);
|
||||||
createProgramFromTrace();
|
createProgramFromTrace();
|
||||||
intoProject(program);
|
intoProject(program);
|
||||||
programManager.openProgram(program);
|
programManager.openProgram(program);
|
||||||
|
|
|
@ -454,39 +454,24 @@ public class DebuggerStateEditingServiceTest extends AbstractGhidraHeadedDebugge
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWriteTargetMemoryNotPresentErr() throws Throwable {
|
public void testWriteTargetRequiresPresent() throws Throwable {
|
||||||
TraceRecorder recorder = recordAndWaitSync();
|
TraceRecorder recorder = recordAndWaitSync();
|
||||||
traceManager.openTrace(tb.trace);
|
traceManager.openTrace(tb.trace);
|
||||||
activateTrace();
|
activateTrace();
|
||||||
traceManager.activateThread(recorder.getTraceThread(mb.testThread1));
|
traceManager.activateThread(recorder.getTraceThread(mb.testThread1));
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
editingService.setCurrentMode(recorder.getTrace(), StateEditingMode.RW_TARGET);
|
|
||||||
|
|
||||||
traceManager.activateSnap(traceManager.getCurrentSnap() - 1);
|
editingService.setCurrentMode(tb.trace, StateEditingMode.RW_TARGET);
|
||||||
|
|
||||||
StateEditor editor = createStateEditor();
|
|
||||||
assertFalse(editor.isVariableEditable(tb.addr(0x00400000), 4));
|
|
||||||
expecting(MemoryAccessException.class, () -> {
|
|
||||||
waitOn(editor.setVariable(tb.addr(0x00400000), tb.arr(1, 2, 3, 4)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testWriteTargetRegisterNotPresentErr() throws Throwable {
|
|
||||||
TraceRecorder recorder = recordAndWaitSync();
|
|
||||||
traceManager.openTrace(tb.trace);
|
|
||||||
activateTrace();
|
|
||||||
traceManager.activateThread(recorder.getTraceThread(mb.testThread1));
|
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
editingService.setCurrentMode(recorder.getTrace(), StateEditingMode.RW_TARGET);
|
assertEquals(recorder.getSnap(), traceManager.getCurrentSnap());
|
||||||
|
|
||||||
traceManager.activateSnap(traceManager.getCurrentSnap() - 1);
|
traceManager.activateSnap(traceManager.getCurrentSnap() - 1);
|
||||||
|
waitForSwing();
|
||||||
|
assertEquals(StateEditingMode.RW_EMULATOR, editingService.getCurrentMode(tb.trace));
|
||||||
|
|
||||||
StateEditor editor = createStateEditor();
|
editingService.setCurrentMode(tb.trace, StateEditingMode.RW_TARGET);
|
||||||
assertFalse(editor.isRegisterEditable(r0));
|
waitForSwing();
|
||||||
expecting(MemoryAccessException.class, () -> {
|
assertEquals(recorder.getSnap(), traceManager.getCurrentSnap());
|
||||||
waitOn(editor.setRegister(rv1234));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -494,6 +479,7 @@ public class DebuggerStateEditingServiceTest extends AbstractGhidraHeadedDebugge
|
||||||
createAndOpenTrace();
|
createAndOpenTrace();
|
||||||
activateTrace();
|
activateTrace();
|
||||||
editingService.setCurrentMode(tb.trace, StateEditingMode.RW_TARGET);
|
editingService.setCurrentMode(tb.trace, StateEditingMode.RW_TARGET);
|
||||||
|
waitForSwing();
|
||||||
|
|
||||||
StateEditor editor = createStateEditor();
|
StateEditor editor = createStateEditor();
|
||||||
assertFalse(editor.isVariableEditable(tb.addr(0x00400000), 4));
|
assertFalse(editor.isVariableEditable(tb.addr(0x00400000), 4));
|
||||||
|
@ -507,6 +493,7 @@ public class DebuggerStateEditingServiceTest extends AbstractGhidraHeadedDebugge
|
||||||
createAndOpenTrace();
|
createAndOpenTrace();
|
||||||
activateTrace();
|
activateTrace();
|
||||||
editingService.setCurrentMode(tb.trace, StateEditingMode.RW_TARGET);
|
editingService.setCurrentMode(tb.trace, StateEditingMode.RW_TARGET);
|
||||||
|
waitForSwing();
|
||||||
|
|
||||||
StateEditor editor = createStateEditor();
|
StateEditor editor = createStateEditor();
|
||||||
assertFalse(editor.isRegisterEditable(r0));
|
assertFalse(editor.isRegisterEditable(r0));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue