diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/watch/WatchRow.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/watch/WatchRow.java index 84404b6a29..904d37e958 100644 --- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/watch/WatchRow.java +++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/watch/WatchRow.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -230,4 +230,18 @@ public interface WatchRow { * @return true if the value changed, false otherwise. */ boolean isChanged(); + + /** + * Get the user-defined comment for this row + * + * @return the comment + */ + String getComment(); + + /** + * Set the user-defined comment for this row + * + * @param comment the comment + */ + void setComment(String comment); } diff --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.java index 3433fcf0bd..b4382b6688 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 @@ -150,6 +150,7 @@ public class DebuggerWatchesProvider extends ComponentProviderAdapter protected enum WatchTableColumns implements EnumeratedTableColumn { EXPRESSION("Expression", String.class, WatchRow::getExpression, WatchRow::setExpression), + COMMENT("Comment", String.class, WatchRow::getComment, WatchRow::setComment), ADDRESS("Address", Address.class, WatchRow::getAddress), SYMBOL("Symbol", Symbol.class, WatchRow::getSymbol), VALUE("Value", String.class, WatchRow::getRawValueString, WatchRow::setRawValueString, // diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DefaultWatchRow.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DefaultWatchRow.java index caa870740a..18c07e633b 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DefaultWatchRow.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DefaultWatchRow.java @@ -51,6 +51,7 @@ public class DefaultWatchRow implements WatchRow { public static final int TRUNCATE_BYTES_LENGTH = 64; private static final String KEY_EXPRESSION = "expression"; private static final String KEY_DATA_TYPE = "dataType"; + private static final String KEY_COMMENT = "comment"; private static final String KEY_SETTINGS = "settings"; private final DebuggerWatchesProvider provider; @@ -62,6 +63,7 @@ public class DefaultWatchRow implements WatchRow { private DataType dataType; private SettingsImpl settings = new SettingsImpl(); private SavedSettings savedSettings = new SavedSettings(settings); + private String comment; private volatile PcodeExpression compiled; private volatile TraceMemoryState state; @@ -602,15 +604,27 @@ public class DefaultWatchRow implements WatchRow { } } + @Override + public String getComment() { + return comment; + } + + @Override + public void setComment(String comment) { + this.comment = comment; + } + protected void writeConfigState(SaveState saveState) { saveState.putString(KEY_EXPRESSION, expression); saveState.putString(KEY_DATA_TYPE, typePath); + saveState.putString(KEY_COMMENT, comment); saveState.putSaveState(KEY_SETTINGS, savedSettings.getState()); } protected void readConfigState(SaveState saveState) { setExpression(saveState.getString(KEY_EXPRESSION, "")); setTypePath(saveState.getString(KEY_DATA_TYPE, null)); + setComment(saveState.getString(KEY_COMMENT, "")); savedSettings.setState(saveState.getSaveState(KEY_SETTINGS)); if (dataType != null) { diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProviderTest.java index 829b265990..c73cd91893 100644 --- a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProviderTest.java +++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProviderTest.java @@ -845,6 +845,7 @@ public class DebuggerWatchesProviderTest extends AbstractGhidraHeadedDebuggerInt DefaultWatchRow row1 = watchesProvider.addWatch("*:4 r1"); row0.setDataType(LongLongDataType.dataType); + row0.setComment("My comment"); Settings settings = row0.getSettings(); FormatSettingsDefinition format = FormatSettingsDefinition.DEF; format.setChoice(settings, FormatSettingsDefinition.DECIMAL); @@ -873,6 +874,7 @@ public class DebuggerWatchesProviderTest extends AbstractGhidraHeadedDebuggerInt DefaultWatchRow rRow0 = rows.get("r0"); assertTrue(LongLongDataType.dataType.isEquivalent(rRow0.getDataType())); + assertEquals("My comment", rRow0.getComment()); assertEquals(FormatSettingsDefinition.DECIMAL, format.getChoice(rRow0.getSettings())); }