diff --git a/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBreakpointsPlugin/DebuggerBreakpointsPlugin.html b/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBreakpointsPlugin/DebuggerBreakpointsPlugin.html index daa63d1045..813e16dbd2 100644 --- a/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBreakpointsPlugin/DebuggerBreakpointsPlugin.html +++ b/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBreakpointsPlugin/DebuggerBreakpointsPlugin.html @@ -149,8 +149,11 @@
  • Threads - (hidden by default) if the breakpoint applies to a limited set of threads, gives the list of threads.
  • -
  • Comment - gives a user comment — the specification's expression by default. This - field is user modifiable.
  • +
  • Comment - gives a user comment. This field is user modifiable.
  • + +
  • Expression - the expression given by the user when placing the breakpoint. This ought to + echo back what was typed into the CLI, if applicable. When placed via a Listing, this often + refers to the dynamic address.
  • Sleigh - indicates whether or not the location has a customized Sleigh configuration. This is only relevant for emulation.
  • @@ -319,7 +322,7 @@ emu_exec_decoded(); Alternatively, suppose the example instruction is JZ 0x00401234. Then, the injection can jump straight to the target:
    -goto [0x00401234];
    +goto 0x00401234;
     
    diff --git a/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBreakpointsPlugin/images/DebuggerBreakpointsPlugin.png b/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBreakpointsPlugin/images/DebuggerBreakpointsPlugin.png index 77722233b8..5615abc9f6 100644 Binary files a/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBreakpointsPlugin/images/DebuggerBreakpointsPlugin.png and b/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBreakpointsPlugin/images/DebuggerBreakpointsPlugin.png differ diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/BreakpointLocationRow.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/BreakpointLocationRow.java index c835c5c32a..543972d6ea 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/BreakpointLocationRow.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/BreakpointLocationRow.java @@ -25,6 +25,7 @@ import ghidra.pcode.exec.SleighUtils; import ghidra.program.model.address.Address; import ghidra.program.util.ProgramLocation; import ghidra.trace.model.breakpoint.TraceBreakpointLocation; +import ghidra.trace.model.breakpoint.TraceBreakpointSpec; public class BreakpointLocationRow { private final DebuggerBreakpointsProvider provider; @@ -113,6 +114,15 @@ public class BreakpointLocationRow { } } + public String getExpression() { + TraceBreakpointSpec spec = loc.getSpecification(); + if (spec == null) { + // Shouldn't happen, but may in the interim + return ""; + } + return spec.getExpression(getSnap()); + } + public boolean hasSleigh() { return !SleighUtils.UNCONDITIONAL_BREAK.equals(loc.getEmuSleigh(getSnap())); } diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProvider.java index c7a90e983b..88d460684b 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProvider.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProvider.java @@ -70,8 +70,9 @@ public class DebuggerBreakpointsProvider extends ComponentProviderAdapter protected enum LogicalBreakpointTableColumns implements EnumeratedTableColumn { - STATE("State", State.class, LogicalBreakpointRow::getState, LogicalBreakpointRow::setState, true), - NAME("Name", String.class, LogicalBreakpointRow::getName, LogicalBreakpointRow::setName, // + STATE("State", State.class, LogicalBreakpointRow::getState, LogicalBreakpointRow::setState, + true), + NAME("Name", String.class, LogicalBreakpointRow::getName, LogicalBreakpointRow::setName, LogicalBreakpointRow::isNamable, true), ADDRESS("Address", Address.class, LogicalBreakpointRow::getAddress, true), IMAGE("Image", String.class, LogicalBreakpointRow::getImageName, true), @@ -142,8 +143,8 @@ public class DebuggerBreakpointsProvider extends ComponentProviderAdapter } } - protected static class LogicalBreakpointTableModel extends RowWrappedEnumeratedColumnTableModel< // - LogicalBreakpointTableColumns, LogicalBreakpoint, LogicalBreakpointRow, LogicalBreakpoint> { + protected static class LogicalBreakpointTableModel extends RowWrappedEnumeratedColumnTableModel< + LogicalBreakpointTableColumns, LogicalBreakpoint, LogicalBreakpointRow, LogicalBreakpoint> { public LogicalBreakpointTableModel(DebuggerBreakpointsProvider provider) { super(provider.getTool(), "Breakpoints", LogicalBreakpointTableColumns.class, lb -> lb, @@ -160,12 +161,16 @@ public class DebuggerBreakpointsProvider extends ComponentProviderAdapter protected enum BreakpointLocationTableColumns implements EnumeratedTableColumn { - STATE("State", State.class, BreakpointLocationRow::getState, BreakpointLocationRow::setState, true, true), - NAME("Name", String.class, BreakpointLocationRow::getName, BreakpointLocationRow::setName, true, true), + STATE("State", State.class, BreakpointLocationRow::getState, + BreakpointLocationRow::setState, true, true), + NAME("Name", String.class, BreakpointLocationRow::getName, BreakpointLocationRow::setName, + true, true), ADDRESS("Address", Address.class, BreakpointLocationRow::getAddress, true, true), TRACE("Trace", String.class, BreakpointLocationRow::getTraceName, true, true), THREADS("Threads", String.class, BreakpointLocationRow::getThreads, true, false), - COMMENT("Comment", String.class, BreakpointLocationRow::getComment, BreakpointLocationRow::setComment, true, true), + COMMENT("Comment", String.class, BreakpointLocationRow::getComment, + BreakpointLocationRow::setComment, true, true), + EXPRESSION("Expression", String.class, BreakpointLocationRow::getExpression, true, true), SLEIGH("Sleigh", Boolean.class, BreakpointLocationRow::hasSleigh, true, true); private final String header; @@ -229,9 +234,8 @@ public class DebuggerBreakpointsProvider extends ComponentProviderAdapter } protected static class BreakpointLocationTableModel - extends RowWrappedEnumeratedColumnTableModel< // - BreakpointLocationTableColumns, ObjectKey, BreakpointLocationRow, // - TraceBreakpointLocation> { + extends RowWrappedEnumeratedColumnTableModel { public BreakpointLocationTableModel(DebuggerBreakpointsProvider provider) { super(provider.getTool(), "Locations", BreakpointLocationTableColumns.class, diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsPluginScreenShots.java b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsPluginScreenShots.java index fee2453f98..3618e91f62 100644 --- a/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsPluginScreenShots.java +++ b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsPluginScreenShots.java @@ -44,7 +44,7 @@ import ghidra.test.ToyProgramBuilder; import ghidra.trace.database.ToyDBTraceBuilder; import ghidra.trace.database.breakpoint.DBTraceBreakpointManager; import ghidra.trace.model.*; -import ghidra.trace.model.breakpoint.TraceBreakpointKind; +import ghidra.trace.model.breakpoint.*; import ghidra.util.Msg; import ghidra.util.task.TaskMonitor; import help.screenshot.GhidraScreenShotGenerator; @@ -151,11 +151,20 @@ public class DebuggerBreakpointsPluginScreenShots extends GhidraScreenShotGenera long snap = tb1.trace.getTimeManager().createSnapshot("First").getKey(); DBTraceBreakpointManager bm = tb1.trace.getBreakpointManager(); - bm.placeBreakpoint("Breakpoints[1]", snap, tb1.addr(0x00401234), List.of(), - Set.of(TraceBreakpointKind.SW_EXECUTE), true, "ram:00401234"); - bm.placeBreakpoint("Breakpoints[2]", snap, tb1.range(0x00604321, 0x00604324), - List.of(), - Set.of(TraceBreakpointKind.WRITE), true, "ram:00604321"); + TraceBreakpointLocation locCx = + bm.placeBreakpoint("Breakpoints[1]", snap, tb1.addr(0x00401234), List.of(), + Set.of(TraceBreakpointKind.SW_EXECUTE), true, ""); + locCx.getSpecification() + .getObject() + .setAttribute(Lifespan.nowOn(snap), TraceBreakpointSpec.KEY_EXPRESSION, + "*0x00401234"); + TraceBreakpointLocation locWr = + bm.placeBreakpoint("Breakpoints[2]", snap, tb1.range(0x00604321, 0x00604324), + List.of(), Set.of(TraceBreakpointKind.WRITE), true, ""); + locWr.getSpecification() + .getObject() + .setAttribute(Lifespan.nowOn(snap), TraceBreakpointSpec.KEY_EXPRESSION, + "version"); } try (Transaction tx = tb2.startTransaction()) { @@ -164,8 +173,13 @@ public class DebuggerBreakpointsPluginScreenShots extends GhidraScreenShotGenera long snap = tb2.trace.getTimeManager().createSnapshot("First").getKey(); DBTraceBreakpointManager bm = tb2.trace.getBreakpointManager(); - bm.placeBreakpoint("Breakpoints[1]", snap, tb2.addr(0x7fac1234), List.of(), - Set.of(TraceBreakpointKind.SW_EXECUTE), false, "ram:7fac1234"); + TraceBreakpointLocation locCx = + bm.placeBreakpoint("Breakpoints[1]", snap, tb2.addr(0x7fac1234), List.of(), + Set.of(TraceBreakpointKind.SW_EXECUTE), false, ""); + locCx.getSpecification() + .getObject() + .setAttribute(Lifespan.nowOn(snap), TraceBreakpointSpec.KEY_EXPRESSION, + "*0x7fac1234"); } programManager.openProgram(program); diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerScreenShots.java b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerScreenShots.java index 18e61664c6..44453241a1 100644 --- a/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerScreenShots.java +++ b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerScreenShots.java @@ -260,6 +260,7 @@ public class TutorialDebuggerScreenShots extends GhidraScreenShotGenerator @Test public void testGettingStarted_ToolWSpecimen() { + tool.getActiveWindow().requestFocus(); captureToolWindow(1920, 1080); } @@ -309,7 +310,7 @@ public class TutorialDebuggerScreenShots extends GhidraScreenShotGenerator public void testGettingStarted_DisassemblyAfterLaunch() throws Throwable { launchProgramInGdb(); - Thread.sleep(7000); + tool.getActiveWindow().requestFocus(); captureToolWindow(1920, 1080); } @@ -382,9 +383,9 @@ public class TutorialDebuggerScreenShots extends GhidraScreenShotGenerator Program prog = null; long snap = flatDbg.getCurrentSnap(); try (LoadResults result = ProgramLoader.builder() - .source(new File(module.getName(snap))) - .project(env.getProject()) - .monitor(monitor) + .source(new File(module.getName(snap))) + .project(env.getProject()) + .monitor(monitor) .load()) { result.save(monitor); @@ -442,6 +443,7 @@ public class TutorialDebuggerScreenShots extends GhidraScreenShotGenerator // Just to be sure. goTo(tool, progLibC, flatDbg.translateDynamicToStatic(dynAddr)); + tool.getActiveWindow().requestFocus(); captureToolWindow(1920, 1080); } diff --git a/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.html b/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.html index 8d514d35c7..1732b21481 100644 --- a/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.html +++ b/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.html @@ -261,9 +261,9 @@ back-end.
  • The Trace column indicates which target contains the location. The text here should match one of the tabs from the Dynamic Listing panel.
  • -
  • The Comment column is a user-defined comment. Its -default value is the specification that generated it, e.g., -srand.
  • +
  • The Comment column is a user-defined comment.
  • +
  • The Expression column is the expression given when +specifying the breakpoint, e.g., srand.
  • @@ -422,7 +422,7 @@ course.

    Exercise: Diagram the Mines

    -

    You goal is to capture the location of all the mines. You will +

    Your goal is to capture the location of all the mines. You will probably want to disable the breakpoints on rand and srand for now. Devise a strategy using breakpoints and the control buttons (Step, Resume, etc.) so that you can observe the diff --git a/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.md b/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.md index a42cc52a02..3e4149b703 100644 --- a/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.md +++ b/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.md @@ -88,7 +88,7 @@ The State, Address, and Sleigh columns are the same as the top, but for the indi * The **Trace** column indicates which target contains the location. The text here should match one of the tabs from the Dynamic Listing panel. * The **Comment** column is a user-defined comment. - Its default value is the specification that generated it, e.g., `srand`. +* The **Expression** column is the expression given when specifying the breakpoint, e.g., `srand`. ### Toggling the Breakpoints @@ -195,7 +195,7 @@ The advantages of a dynamic session along side static analysis should become mor ### Exercise: Diagram the Mines -You goal is to capture the location of all the mines. +Your goal is to capture the location of all the mines. You will probably want to disable the breakpoints on `rand` and `srand` for now. Devise a strategy using breakpoints and the control buttons (Step, Resume, etc.) so that you can observe the location of each mine. Use pen and paper to draw a diagram of the board, and mark the location of each mine as you observe the algorithm placing it. diff --git a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_EmptyAfterLaunch.png b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_EmptyAfterLaunch.png index 3955c95344..f6a0e1bac2 100644 Binary files a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_EmptyAfterLaunch.png and b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_EmptyAfterLaunch.png differ diff --git a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_PopAfterSRandRand.png b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_PopAfterSRandRand.png index 26f01c8170..7efe94e1d6 100644 Binary files a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_PopAfterSRandRand.png and b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_PopAfterSRandRand.png differ diff --git a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_SyncedAfterImportLibC.png b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_SyncedAfterImportLibC.png index 856c2a4e5e..45a4123f2b 100644 Binary files a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_SyncedAfterImportLibC.png and b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_SyncedAfterImportLibC.png differ diff --git a/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_DisassemblyAfterLaunch.png b/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_DisassemblyAfterLaunch.png index 252c733b3e..6c75492991 100644 Binary files a/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_DisassemblyAfterLaunch.png and b/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_DisassemblyAfterLaunch.png differ diff --git a/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_ToolWSpecimen.png b/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_ToolWSpecimen.png index a5482ea5f6..8f59dccc5f 100644 Binary files a/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_ToolWSpecimen.png and b/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_ToolWSpecimen.png differ