GP-5795: Add a "Comment" column in the "Watches" table.

This commit is contained in:
Dan 2025-07-28 15:27:22 +00:00
parent 598efa66d9
commit 851264808b
4 changed files with 33 additions and 2 deletions

View file

@ -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);
}

View file

@ -150,6 +150,7 @@ public class DebuggerWatchesProvider extends ComponentProviderAdapter
protected enum WatchTableColumns
implements EnumeratedTableColumn<WatchTableColumns, DefaultWatchRow> {
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, //

View file

@ -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) {

View file

@ -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()));
}