Ghidra is a software reverse engineering (SRE) framework
GP-1469: Double-clicking Watch Repr cell may go to value.
Danb1c17db4e119
diff --git a/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerWatchesPlugin/DebuggerWatchesPlugin.html b/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerWatchesPlugin/DebuggerWatchesPlugin.htmlindex f863cf99e1..4b958a373e 100644--- a/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerWatchesPlugin/DebuggerWatchesPlugin.html+++ b/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerWatchesPlugin/DebuggerWatchesPlugin.html@@ -57,7 +57,7 @@<LI>Address - when evaluation succeeds, the address of the watch's value. This field isreally only meaningful when the outermost operator of the expression is a memory dereference.- Double-clicking a row will navigate the primary dynamic listing to this address, if+ Double-clicking this cell will navigate the primary dynamic listing to this address, ifpossible.</LI><LI>Value - the raw bytes of the watched buffer. If the expression is a register, then this@@ -71,7 +71,9 @@possible.</LI><LI>Representation - the value of the watch as interpreted by the selected data type. This- field is not yet user modifiable, even if the <B>Enable Edits</B> toggle is on.</LI>+ field is not yet user modifiable, even if the <B>Enable Edits</B> toggle is on. If the value+ is an address, i.e., Type is a pointer, then double-clicking this cell will navigate the+ primary dynamic listing, if possible.</LI><LI>Error - if an error occurs during compilation or evaluation of the expression, that erroris rendered here. Double-clicking the row will display the stack trace. Note that errorsdiff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProvider.javaindex 931b31ea7f..1afed55abc 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProvider.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProvider.java@@ -334,24 +334,7 @@ public class DebuggerWatchesProvider extends ComponentProviderAdapter {if (e.getClickCount() != 2 || e.getButton() != MouseEvent.BUTTON1) {return;}- if (myActionContext == null) {- return;- }- WatchRow row = myActionContext.getWatchRow();- if (row == null) {- return;- }- Throwable error = row.getError();- if (error != null) {- Msg.showError(this, getComponent(), "Evaluation error",- "Could not evaluate watch", error);- return;- }- Address address = myActionContext.getWatchRow().getAddress();- if (listingService == null || address == null || !address.isMemoryAddress()) {- return;- }- listingService.goTo(address, true);+ navigateToSelectedWatch();}});@@ -371,6 +354,44 @@ public class DebuggerWatchesProvider extends ComponentProviderAdapter {super.contextChanged();}+ protected void navigateToSelectedWatch() {+ if (myActionContext == null) {+ return;+ }+ WatchRow row = myActionContext.getWatchRow();+ if (row == null) {+ return;+ }+ int modelCol = watchTable.convertColumnIndexToModel(watchTable.getSelectedColumn());+ Throwable error = row.getError(); // I don't care the selected column for errors+ if (error != null) {+ Msg.showError(this, getComponent(), "Evaluation error",+ "Could not evaluate watch", error);+ }+ else if (modelCol == WatchTableColumns.ADDRESS.ordinal()) {+ Address address = row.getAddress();+ if (address != null) {+ navigateToAddress(address);+ }+ }+ else if (modelCol == WatchTableColumns.REPR.ordinal()) {+ Object val = row.getValueObj();+ if (val instanceof Address) {+ navigateToAddress((Address) val);+ }+ }+ }++ protected void navigateToAddress(Address address) {+ if (listingService == null) {+ return;+ }+ if (address.isMemoryAddress()) {+ listingService.goTo(address, true);+ return;+ }+ }+protected void createActions() {actionEnableEdits = DebuggerResources.EnableEditsAction.builder(plugin).enabledWhen(c -> current.getTrace() != null)diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/WatchRow.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/WatchRow.javaindex 6db7665f7c..ca346ac0d3 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/WatchRow.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/WatchRow.java@@ -64,6 +64,7 @@ public class WatchRow {private byte[] value;private byte[] prevValue; // Value at previous coordinatesprivate String valueString;+ private Object valueObj;private Throwable error = null;public WatchRow(DebuggerWatchesProvider provider, String expression) {@@ -77,6 +78,7 @@ public class WatchRow {reads = null;value = null;valueString = null;+ valueObj = null;}protected void recompile() {@@ -125,20 +127,29 @@ public class WatchRow {address = valueWithAddress.getRight();reads = executorWithAddress.getReads();- valueString = parseAsDataType();+ valueObj = parseAsDataTypeObj();+ valueString = parseAsDataTypeStr();}catch (Exception e) {error = e;}}- protected String parseAsDataType() {+ protected String parseAsDataTypeStr() {if (dataType == null || value == null) {return "";}MemBuffer buffer = new ByteMemBufferImpl(address, value, language.isBigEndian());return dataType.getRepresentation(buffer, SettingsImpl.NO_SETTINGS, value.length);}++ protected Object parseAsDataTypeObj() {+ if (dataType == null || value == null) {+ return null;+ }+ MemBuffer buffer = new ByteMemBufferImpl(address, value, language.isBigEndian());+ return dataType.getValue(buffer, SettingsImpl.NO_SETTINGS, value.length);+ }public static class ReadDepsTraceBytesPcodeExecutorStateextends TraceBytesPcodeExecutorState {@@ -299,7 +310,8 @@ public class WatchRow {public void setDataType(DataType dataType) {this.typePath = dataType == null ? null : dataType.getPathName();this.dataType = dataType;- valueString = parseAsDataType();+ valueString = parseAsDataTypeStr();+ valueObj = parseAsDataTypeObj();provider.contextChanged();}@@ -357,6 +369,10 @@ public class WatchRow {return valueString;}+ public Object getValueObj() {+ return valueObj;+ }+public boolean isValueEditable() {return address != null && provider.isEditsEnabled();}