diff --git a/Ghidra/Features/Decompiler/src/main/doc/pcoderef.xml b/Ghidra/Features/Decompiler/src/main/doc/pcoderef.xml index e609b2d803..64965a5443 100644 --- a/Ghidra/Features/Decompiler/src/main/doc/pcoderef.xml +++ b/Ghidra/Features/Decompiler/src/main/doc/pcoderef.xml @@ -3501,7 +3501,7 @@ still have normal data-flow and can be manipulated symbolically.
output = cpool(input0,intput1);output = cpool(input0,input1);while (true) {
monitor.checkCancelled();
- TargetExecutionState execState = getExecutionState(trace);
+ TraceExecutionState execState = getExecutionState(trace);
switch (execState) {
- case STOPPED:
- resume();
- break;
- case TERMINATED:
- case INACTIVE:
- throw new AssertionError("Target terminated");
- case ALIVE:
- println(
- "I don't know whether or not the target is running. Please make it RUNNING.");
- break;
- case RUNNING:
- /**
- * Probably timed out waiting for break. That's fine. Give the player time to
- * win.
- */
- break;
- default:
- throw new AssertionError("Unrecognized state: " + execState);
- }
- try {
- monitor.setMessage("Waiting for player to win");
- waitForBreak(1, TimeUnit.SECONDS);
- }
- catch (TimeoutException e) {
- // Give the player time to win.
- continue;
- }
- flushAsyncPipelines(trace);
- Address pc = getProgramCounter();
- println("STOPPED at pc = " + pc);
- if (resetDyn.equals(pc)) {
- break;
- }
-}
+ case STOPPED -> resume();
+ case TERMINATED, INACTIVE -> throw new AssertionError("Target terminated");
+ case ALIVE -> println(
+ "I don't know whether or not the target is running. Please make it RUNNING.");
+ case RUNNING -> {
+ /**
+ * Probably timed out waiting for break. That's fine. Give the player time to
+ * win.
+ */
+ }
+ default -> throw new AssertionError("Unrecognized state: " + execState);
+ }
+ try {
+ monitor.setMessage("Waiting for player to win");
+ waitForBreak(1, TimeUnit.SECONDS);
+ }
+ catch (TimeoutException e) {
+ // Give the player time to win.
+ continue;
+ }
+ flushAsyncPipelines(trace);
+ Address pc = getProgramCounter();
+ println("STOPPED at pc = " + pc);
+ if (resetDyn.equals(pc)) {
+ break;
+ }
+}
The “center” of this loop is a call to waitForBreak() on
line 27. This is the simplest primitive for waiting on the target to
meet any condition. Because we expect the user to take more than a
@@ -511,9 +504,7 @@ keep waiting. Using a timeout of 1 second ensures we can terminate
promptly should the user cancel the script.
Before waiting, we need to make sure the target is running. Because
we could repeat the loop while the target is already running, we should
-only call resume() if the target is stopped. There are
-utility methods on TargetExecutionState like
-isRunning(), which you might prefer to use. Here, we
+only call resume() if the target is stopped. Here, we
exhaustively handle every kind of state using a switch statement, which
does make the code a bit verbose.
When the target does break, we first allow the UI to finish
diff --git a/GhidraDocs/GhidraClass/Debugger/B3-Scripting.md b/GhidraDocs/GhidraClass/Debugger/B3-Scripting.md
index 5edd3b3bcd..5bfa41d803 100644
--- a/GhidraDocs/GhidraClass/Debugger/B3-Scripting.md
+++ b/GhidraDocs/GhidraClass/Debugger/B3-Scripting.md
@@ -293,26 +293,19 @@ We do not need to be precise in this check; it suffices to check the program cou
while (true) {
monitor.checkCancelled();
- TargetExecutionState execState = getExecutionState(trace);
+ TraceExecutionState execState = getExecutionState(trace);
switch (execState) {
- case STOPPED:
- resume();
- break;
- case TERMINATED:
- case INACTIVE:
- throw new AssertionError("Target terminated");
- case ALIVE:
- println(
- "I don't know whether or not the target is running. Please make it RUNNING.");
- break;
- case RUNNING:
+ case STOPPED -> resume();
+ case TERMINATED, INACTIVE -> throw new AssertionError("Target terminated");
+ case ALIVE -> println(
+ "I don't know whether or not the target is running. Please make it RUNNING.");
+ case RUNNING -> {
/**
* Probably timed out waiting for break. That's fine. Give the player time to
* win.
*/
- break;
- default:
- throw new AssertionError("Unrecognized state: " + execState);
+ }
+ default -> throw new AssertionError("Unrecognized state: " + execState);
}
try {
monitor.setMessage("Waiting for player to win");
@@ -338,7 +331,6 @@ Using a timeout of 1 second ensures we can terminate promptly should the user ca
Before waiting, we need to make sure the target is running.
Because we could repeat the loop while the target is already running, we should only call `resume()` if the target is stopped.
-There are utility methods on `TargetExecutionState` like `isRunning()`, which you might prefer to use.
Here, we exhaustively handle every kind of state using a switch statement, which does make the code a bit verbose.
When the target does break, we first allow the UI to finish interrogating the target.
diff --git a/GhidraDocs/GhidraClass/Debugger/B4-Modeling.html b/GhidraDocs/GhidraClass/Debugger/B4-Modeling.html
index 240cb37007..d2cd7ae433 100644
--- a/GhidraDocs/GhidraClass/Debugger/B4-Modeling.html
+++ b/GhidraDocs/GhidraClass/Debugger/B4-Modeling.html
@@ -585,7 +585,7 @@ class="sourceCode numberSource java numberLines"><
to complete the model. There is some odd nuance in the naming of p-code
operations, so do read the documentation carefully. If you are not
entirely certain what an operation does, take a look at OpBehaviorFactory.
+href="../../../Ghidra/Framework/Emulation/src/main/java/ghidra/pcode/opbehavior/OpBehaviorFactory.java">OpBehaviorFactory.
You can also examine the concrete implementation on byte arrays BytesPcodeArithmetic.
output = cpool(input0,intput1);output = cpool(input0,input1);
macro resultflags(op) {
zeroflag = (op == 0);
- signflag = (op1 s< 0);
+ signflag = (op s< 0);
}
:add r1,r2 is opcode=0xba & r1 & r2 { r1 = r1 + r2; resultflags(r1); }