mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-5795: Add a "Comment" column in the "Watches" table.
This commit is contained in:
parent
598efa66d9
commit
851264808b
4 changed files with 33 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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, //
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue