Ghidra is a software reverse engineering (SRE) framework
GP-3026: Add Expression column to Breakpoints. Update/fix docs.
Dan5670520c9a03
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.htmlindex 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 @@<LI>Threads - (hidden by default) if the breakpoint applies to a limited set of threads,gives the list of threads.</LI>- <LI>Comment - gives a user comment — the specification's expression by default. This- field is user modifiable.</LI>+ <LI>Comment - gives a user comment. This field is user modifiable.</LI>++ <LI>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.</LI><LI>Sleigh - indicates whether or not the location has a customized Sleigh configuration.This is only relevant for emulation.</LI>@@ -319,7 +322,7 @@ emu_exec_decoded();Alternatively, suppose the example instruction is <CODE>JZ 0x00401234</CODE>. Then, theinjection can jump straight to the target:<PRE>-goto [0x00401234];+goto 0x00401234;</PRE></LI>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.pngindex 77722233b8..5615abc9f6 100644Binary 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 differdiff --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.javaindex 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.javaindex 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 ComponentProviderAdapterprotected enum LogicalBreakpointTableColumnsimplements EnumeratedTableColumn<LogicalBreakpointTableColumns, LogicalBreakpointRow> {- 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 ComponentProviderAdapterprotected enum BreakpointLocationTableColumnsimplements EnumeratedTableColumn<BreakpointLocationTableColumns, BreakpointLocationRow> {- 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<BreakpointLocationTableColumns, ObjectKey,+ BreakpointLocationRow, TraceBreakpointLocation> {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.javaindex 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 GhidraScreenShotGeneralong 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 GhidraScreenShotGeneralong 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.javaindex 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@Testpublic void testGettingStarted_ToolWSpecimen() {+ tool.getActiveWindow().requestFocus();captureToolWindow(1920, 1080);}@@ -309,7 +310,7 @@ public class TutorialDebuggerScreenShots extends GhidraScreenShotGeneratorpublic void testGettingStarted_DisassemblyAfterLaunch() throws Throwable {launchProgramInGdb();- Thread.sleep(7000);+ tool.getActiveWindow().requestFocus();captureToolWindow(1920, 1080);}@@ -382,9 +383,9 @@ public class TutorialDebuggerScreenShots extends GhidraScreenShotGeneratorProgram prog = null;long snap = flatDbg.getCurrentSnap();try (LoadResults<Program> 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.htmlindex 8d514d35c7..1732b21481 100644--- a/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.html+++ b/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.html@@ -261,9 +261,9 @@ back-end.</li><li>The <strong>Trace</strong> column indicates which target containsthe location. The text here should match one of the tabs from theDynamic Listing panel.</li>-<li>The <strong>Comment</strong> column is a user-defined comment. Its-default value is the specification that generated it, e.g.,-<code>srand</code>.</li>+<li>The <strong>Comment</strong> column is a user-defined comment.</li>+<li>The <strong>Expression</strong> column is the expression given when+specifying the breakpoint, e.g., <code>srand</code>.</li></ul></section><section id="toggling-the-breakpoints" class="level3">@@ -422,7 +422,7 @@ course.</p></section><section id="exercise-diagram-the-mines" class="level3"><h3>Exercise: Diagram the Mines</h3>-<p>You goal is to capture the location of all the mines. You will+<p>Your goal is to capture the location of all the mines. You willprobably want to disable the breakpoints on <code>rand</code> and<code>srand</code> for now. Devise a strategy using breakpoints and thecontrol buttons (Step, Resume, etc.) so that you can observe thediff --git a/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.md b/GhidraDocs/GhidraClass/Debugger/A3-Breakpoints.mdindex 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.pngindex 3955c95344..f6a0e1bac2 100644Binary files a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_EmptyAfterLaunch.png and b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_EmptyAfterLaunch.png differdiff --git a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_PopAfterSRandRand.png b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_PopAfterSRandRand.pngindex 26f01c8170..7efe94e1d6 100644Binary files a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_PopAfterSRandRand.png and b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_PopAfterSRandRand.png differdiff --git a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_SyncedAfterImportLibC.png b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_SyncedAfterImportLibC.pngindex 856c2a4e5e..45a4123f2b 100644Binary files a/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_SyncedAfterImportLibC.png and b/GhidraDocs/GhidraClass/Debugger/images/Breakpoints_SyncedAfterImportLibC.png differdiff --git a/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_DisassemblyAfterLaunch.png b/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_DisassemblyAfterLaunch.pngindex 252c733b3e..6c75492991 100644Binary files a/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_DisassemblyAfterLaunch.png and b/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_DisassemblyAfterLaunch.png differdiff --git a/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_ToolWSpecimen.png b/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_ToolWSpecimen.pngindex a5482ea5f6..8f59dccc5f 100644Binary files a/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_ToolWSpecimen.png and b/GhidraDocs/GhidraClass/Debugger/images/GettingStarted_ToolWSpecimen.png differ