From c6e33b89b48993cd81798219d6bce6626e63477a Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Tue, 9 Jun 2026 13:45:19 +0000 Subject: [PATCH] GP-6721: Improve the Dynamic GoTo dialog --- .../app/services/DebuggerListingService.java | 18 + .../DebuggerListingPlugin.html | 36 +- .../images/DebuggerGoToDialog.png | Bin 5978 -> 10778 bytes .../debug/gui/action/DebuggerGoToDialog.java | 85 +- .../debug/gui/action/DebuggerGoToTrait.java | 92 +- .../gui/action/WatchLocationTrackingSpec.java | 2 +- .../AbstractDebuggerSleighInputDialog.java | 11 +- .../gui/listing/DebuggerListingPlugin.java | 24 + .../gui/listing/DebuggerListingProvider.java | 10 +- .../memory/DebuggerMemoryBytesProvider.java | 13 +- .../gui/time/DebuggerTimeSelectionDialog.java | 7 + .../core/debug/gui/watch/DefaultWatchRow.java | 2 +- .../ghidra/pcode/exec/DebuggerPcodeUtils.java | 181 ++- .../DebuggerListingPluginScreenShots.java | 5 +- .../java/ghidra/pcode/struct/DefaultVar.java | 11 +- .../pcode/exec/SleighProgramCompiler.java | 14 +- .../java/ghidra/pcode/exec/SleighUtils.java | 117 +- .../ghidra/pcode/exec/SleighUtilsTest.java | 19 +- .../Framework/SoftwareModeling/build.gradle | 16 +- .../SoftwareModeling/certification.manifest | 2 + .../antlr/ghidra/sleigh/grammar/BaseLexer.g | 11 +- .../ghidra/sleigh/grammar/DisplayParser.g | 2 +- .../ghidra/sleigh/grammar/SemanticLexerHex.g | 30 + .../sleigh/grammar/SemanticLexerIdHex.g | 30 + .../ghidra/sleigh/grammar/SemanticParser.g | 13 +- .../ghidra/sleigh/grammar/SleighCompiler.g | 1196 ++++++++++------- .../antlr/ghidra/sleigh/grammar/SleighEcho.g | 2 +- .../ghidra/sleigh/grammar/SleighParser.g | 2 +- .../pcodeCPort/sleighbase/SleighBase.java | 11 +- .../pcodeCPort/slgh_compile/PcodeCompile.java | 50 +- .../slgh_compile/SleighCompile.java | 27 +- .../program/model/lang/PcodeParser.java | 25 +- .../grammar/AbstractSleighCompiler.java | 178 +++ .../sleigh/grammar/RadixBigInteger.java | 12 + .../ghidra/sleigh/grammar/SleighLexer.java | 8 +- .../listing/DebuggerListingProviderTest.java | 1 + .../pcode/exec/TraceRmiPcodeExecTest.java | 177 +++ 37 files changed, 1760 insertions(+), 680 deletions(-) create mode 100644 Ghidra/Framework/SoftwareModeling/src/main/antlr/ghidra/sleigh/grammar/SemanticLexerHex.g create mode 100644 Ghidra/Framework/SoftwareModeling/src/main/antlr/ghidra/sleigh/grammar/SemanticLexerIdHex.g create mode 100644 Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/sleigh/grammar/AbstractSleighCompiler.java diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerListingService.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerListingService.java index d4e90cbecb..9d5fd6ed16 100644 --- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerListingService.java +++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerListingService.java @@ -20,6 +20,7 @@ import ghidra.debug.api.action.AutoReadMemorySpec; import ghidra.debug.api.action.LocationTrackingSpec; import ghidra.debug.api.listing.MultiBlendedListingBackgroundColorModel; import ghidra.framework.plugintool.ServiceInfo; +import ghidra.pcode.exec.SleighUtils.LitIdMode; import ghidra.program.model.address.Address; import ghidra.program.util.ProgramSelection; @@ -94,6 +95,23 @@ public interface DebuggerListingService extends CodeViewerService { */ boolean goTo(Address address, boolean centerOnScreen); + /** + * Set the mode of the Go-to dialog's Sleigh expressions + *
+ * This applies to all Go-to dialogs among the dynamic providers, including listings and memory + * (hex byte) views. + * + * @param mode the new mode + */ + void setGoToSleighMode(LitIdMode mode); + + /** + * Get the mode of the Go-to dialog's Sleigh expressions + * + * @return the current mode + */ + LitIdMode getGoToSleighMode(); + /** * Obtain a coloring background model suitable for the given listing * diff --git a/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerListingPlugin/DebuggerListingPlugin.html b/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerListingPlugin/DebuggerListingPlugin.html index be738abb7d..842597dcd8 100644 --- a/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerListingPlugin/DebuggerListingPlugin.html +++ b/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerListingPlugin/DebuggerListingPlugin.html @@ -154,25 +154,53 @@ point in time. If the current trace is live and at the present, the target may be queried to retrieve any machine state required to evaluate the expression. The expression may be in terms of labels, registers, and constants. Labels may come from the current trace or a program mapped - into the trace. Ambiguities are resolved arbitrarily.
+ into the trace. Ambiguities are resolved arbitrarily. Relative expressions are permitted by + starting with a plus (+) or minus (-). Additionally, a dot
+ (.) refers to the current address.
The radio buttons at the bottom indicate the default radix of integer literals:
+ +.slaspec file. Literals are assumed in decimal unless an
+ 0x or 0b prefix is included. There is no ambiguity with ids, since
+ they cannot start with a digit 0-9.0n
+ (decimal) prefix is included. The tokenizer treats any contiguous sequence of digits
+ 0-9,A-F,a-f as a literal, which introduces ambiguity with certain ids, e.g., a1,
+ which in some languages could refer to a register. In this mode, the ambiguous token is
+ treated as an integer literal, i.e., having the decimal value 161. Note that the prefix
+ 0b (for binary literals) is no longer permitted. The token, e.g.,
+ 0b01 is treated as a hex literal, i.e., having the decimal value 2817.a1 is first checked to
+ match a register. If there is no a1 register, then it treats it as an integer
+ literal. Unfortunately, this may lead to unexpected behavior. A user typing A1
+ would get the literal value, even if register a1 exists, since ids are case
+ sensitive.Note that a Go-To action can fail for many reasons, e.g., syntax errors, computation failures. One possible reason is that the address is not part of a memory region known to the debugger. This failure can be overcome by enabling Force Full View.
-Some examples:
+Some examples (in Hex mode):
00401234 — A constant address in simple notation00401234 — A constant address0x00401234:8 — A constant address in Sleigh notationmain + 10 — 10 bytes past the address of "main"+4c — 76 (4c hex) bytes past the current addressmain + 10 — 16 (10 hex) bytes past the address of "main"RAX — The address in RAXnSKqa3jFDdL=G
z^&zIC+=@OuOGV#2`gMGLeOsgXlG6zdTRF&Rqva~;G$;DqOnKQWR}f8$E91@0#so{h
zm@2Q
- Enter an address or Sleigh expression. Press F1 for help and examples.
+ Enter an address or Sleigh expression. Use + (plus) or - (minus) for movement relative
+ to your current address. Press F1 for help and examples.
&o)`ZpC&J%UZ8;C_yP6fym#xZFS+rdSl=ks;
zgWU5WB_dU!uH#J>O;1Y9Ys(%JlUAD