mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 12:00:04 +02:00
Merge remote-tracking branch 'origin/GP-1469_Dan_watchesGoToRepr' into patch
This commit is contained in:
commit
a30d0b9bb2
3 changed files with 62 additions and 23 deletions
|
@ -57,7 +57,7 @@
|
|||
|
||||
<LI>Address - when evaluation succeeds, the address of the watch's value. This field is
|
||||
really 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, if
|
||||
possible.</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 error
|
||||
is rendered here. Double-clicking the row will display the stack trace. Note that errors
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -64,6 +64,7 @@ public class WatchRow {
|
|||
private byte[] value;
|
||||
private byte[] prevValue; // Value at previous coordinates
|
||||
private 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 ReadDepsTraceBytesPcodeExecutorState
|
||||
extends 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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue