mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/GP-3547_ghidra1_DefaultSettingsFix'
This commit is contained in:
commit
48b8bc0fcc
9 changed files with 88 additions and 55 deletions
|
@ -139,8 +139,7 @@ public enum VariableValueUtils {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Boolean evaluateLoad(Program program, PcodeOp op,
|
||||
Map<Varnode, Boolean> already) {
|
||||
protected Boolean evaluateLoad(Program program, PcodeOp op, Map<Varnode, Boolean> already) {
|
||||
return evaluateVarnode(program, op.getInput(1), already);
|
||||
}
|
||||
|
||||
|
@ -180,9 +179,14 @@ public enum VariableValueUtils {
|
|||
this.space = space;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImmutableSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
|
||||
return delegate.isChangeAllowed(settingsDefinition);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -473,9 +477,8 @@ public enum VariableValueUtils {
|
|||
*/
|
||||
public static boolean hasFreshUnwind(PluginTool tool, DebuggerCoordinates coordinates) {
|
||||
ListingUnwoundFrame innermost = locateInnermost(tool, coordinates);
|
||||
if (innermost == null || !Objects.equals(innermost.getProgramCounter(),
|
||||
getProgramCounter(coordinates.getPlatform(), coordinates.getThread(),
|
||||
coordinates.getViewSnap()))) {
|
||||
if (innermost == null || !Objects.equals(innermost.getProgramCounter(), getProgramCounter(
|
||||
coordinates.getPlatform(), coordinates.getThread(), coordinates.getViewSnap()))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -866,8 +869,7 @@ public enum VariableValueUtils {
|
|||
address.isRegisterAddress()) {
|
||||
settings = new DefaultSpaceSettings(settings, language.getDefaultSpace());
|
||||
}
|
||||
ByteMemBufferImpl buf =
|
||||
new ByteMemBufferImpl(address, bytes, language.isBigEndian()) {
|
||||
ByteMemBufferImpl buf = new ByteMemBufferImpl(address, bytes, language.isBigEndian()) {
|
||||
@Override
|
||||
public Memory getMemory() {
|
||||
return coordinates.getView().getMemory();
|
||||
|
|
|
@ -786,12 +786,14 @@
|
|||
<P>To change the default settings for a given data type:</P>
|
||||
|
||||
<OL>
|
||||
<LI>Place the cursor on a data item of that type</LI>
|
||||
<LI>Place the cursor on a data item of that type,</LI>
|
||||
|
||||
<LI>Press mouse-right to bring up the popup menu</LI>
|
||||
<LI>Press mouse-right to bring up the popup menu,</LI>
|
||||
|
||||
<LI>Select <B>Data<IMG src="help/shared/arrow.gif"> Default Settings...</B> to bring up
|
||||
the default settings dialog</LI>
|
||||
the default settings dialog. This action may not be available in cases which do not allow
|
||||
the default settings to be modified such as components of Dynamic Data Types which are
|
||||
established on-the-fly. </LI>
|
||||
</OL>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
|
|
|
@ -158,8 +158,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||
.buildAndInstall(tool);
|
||||
|
||||
// Data instance settings action based upon data selection in listing
|
||||
new ActionBuilder("Data Settings", getName())
|
||||
.sharedKeyBinding()
|
||||
new ActionBuilder("Data Settings", getName()).sharedKeyBinding()
|
||||
.popupMenuPath(DATA_SETTINGS_POPUP_PATH)
|
||||
.popupMenuGroup("Settings")
|
||||
.withContext(ListingActionContext.class)
|
||||
|
@ -168,8 +167,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||
.buildAndInstall(tool);
|
||||
|
||||
// Default settings action based upon data selection in listing
|
||||
new ActionBuilder("Default Settings", getName())
|
||||
.sharedKeyBinding()
|
||||
new ActionBuilder("Default Settings", getName()).sharedKeyBinding()
|
||||
.popupMenuPath(DEFAULT_SETTINGS_POPUP_PATH)
|
||||
.popupMenuGroup("Settings")
|
||||
.withContext(ListingActionContext.class)
|
||||
|
@ -178,8 +176,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||
.buildAndInstall(tool);
|
||||
|
||||
// Default settings action for selected datatypes from datatype manager
|
||||
new ActionBuilder("Default Settings", getName())
|
||||
.sharedKeyBinding()
|
||||
new ActionBuilder("Default Settings", getName()).sharedKeyBinding()
|
||||
.popupMenuPath(DATATYPE_SETTINGS_POPUP_PATH)
|
||||
.popupMenuGroup("Settings")
|
||||
.withContext(DataTypesActionContext.class)
|
||||
|
@ -197,8 +194,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||
.buildAndInstall(tool);
|
||||
|
||||
// Default settings action for composite editor components (stand-alone archive)
|
||||
new ActionBuilder("Default Settings", getName())
|
||||
.sharedKeyBinding()
|
||||
new ActionBuilder("Default Settings", getName()).sharedKeyBinding()
|
||||
.popupMenuPath(DATATYPE_SETTINGS_POPUP_PATH)
|
||||
.popupMenuGroup("Settings")
|
||||
.withContext(ComponentStandAloneActionContext.class)
|
||||
|
@ -207,8 +203,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||
.buildAndInstall(tool);
|
||||
|
||||
editDataTypeAction =
|
||||
new ActionBuilder("Edit Data Type", getName())
|
||||
.popupMenuPath(EDIT_DATA_TYPE_POPUP_PATH)
|
||||
new ActionBuilder("Edit Data Type", getName()).popupMenuPath(EDIT_DATA_TYPE_POPUP_PATH)
|
||||
.popupMenuGroup("BasicData")
|
||||
.withContext(ListingActionContext.class)
|
||||
.enabledWhen(c -> {
|
||||
|
@ -717,7 +712,14 @@ public class DataPlugin extends Plugin implements DataService {
|
|||
if (data == null) {
|
||||
return false;
|
||||
}
|
||||
return data.getDataType().getSettingsDefinitions().length != 0;
|
||||
DataType dt = data.getDataType();
|
||||
if (dt.getSettingsDefinitions().length == 0) {
|
||||
return false;
|
||||
}
|
||||
if (editDefaults) {
|
||||
return !dt.getDefaultSettings().isImmutableSettings();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void editDefaultDataSettings(ListingActionContext context) {
|
||||
|
|
|
@ -24,6 +24,11 @@ public interface Settings {
|
|||
|
||||
static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
|
||||
/**
|
||||
* {@return true if settings may not be modified}
|
||||
*/
|
||||
boolean isImmutableSettings();
|
||||
|
||||
/**
|
||||
* Determine if a settings change corresponding to the specified
|
||||
* settingsDefinition is permitted.
|
||||
|
|
|
@ -72,8 +72,8 @@ public class SettingsImpl implements Settings, Serializable {
|
|||
this();
|
||||
if (settings != null) {
|
||||
String[] names = settings.getNames();
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
map.put(names[i], settings.getValue(names[i]));
|
||||
for (String name : names) {
|
||||
map.put(name, settings.getValue(name));
|
||||
}
|
||||
defaultSettings = settings.getDefaultSettings();
|
||||
}
|
||||
|
@ -100,6 +100,11 @@ public class SettingsImpl implements Settings, Serializable {
|
|||
this.changeSourceObj = changeSourceObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImmutableSettings() {
|
||||
return immutable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
|
||||
if (immutable) {
|
||||
|
@ -147,9 +152,8 @@ public class SettingsImpl implements Settings, Serializable {
|
|||
if (name == null) {
|
||||
nameStr = "s";
|
||||
}
|
||||
Msg.warn(SettingsImpl.class,
|
||||
"Ignored invalid attempt to modify immutable " + typeStr + "component setting" +
|
||||
nameStr);
|
||||
Msg.warn(SettingsImpl.class, "Ignored invalid attempt to modify immutable " + typeStr +
|
||||
"component setting" + nameStr);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -212,10 +216,9 @@ public class SettingsImpl implements Settings, Serializable {
|
|||
@Override
|
||||
public String[] getNames() {
|
||||
String[] names = new String[map.size()];
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
int i = 0;
|
||||
while (it.hasNext()) {
|
||||
names[i++] = it.next();
|
||||
for (String element : map.keySet()) {
|
||||
names[i++] = element;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
|
|
@ -460,6 +460,11 @@ class DataTypeComponentDB implements InternalDataTypeComponent {
|
|||
dataMgr.dataTypeChanged(getParent(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImmutableSettings() {
|
||||
return false; // NOTE: We could check to see if any editable Settings are defined
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
|
||||
if (settingsDefinition instanceof TypeDefSettingsDefinition) {
|
||||
|
|
|
@ -77,6 +77,11 @@ class DataTypeSettingsDB implements Settings {
|
|||
return wasLocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImmutableSettings() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
|
||||
if (locked) {
|
||||
|
@ -137,9 +142,8 @@ class DataTypeSettingsDB implements Settings {
|
|||
if (name == null) {
|
||||
nameStr = "s";
|
||||
}
|
||||
Msg.warn(SettingsImpl.class,
|
||||
"Ignored invalid attempt to modify immutable " + typeStr + "component setting" +
|
||||
nameStr);
|
||||
Msg.warn(SettingsImpl.class, "Ignored invalid attempt to modify immutable " + typeStr +
|
||||
"component setting" + nameStr);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -46,6 +46,11 @@ public interface Data extends CodeUnit, Settings {
|
|||
*/
|
||||
public Class<?> getValueClass();
|
||||
|
||||
@Override
|
||||
default boolean isImmutableSettings() {
|
||||
return true; // NOTE: We could check to see if any editable Settings are defined
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this data corresponds to string data. This is determined
|
||||
* by the corresponding data type producing a String value.
|
||||
|
|
|
@ -35,6 +35,11 @@ public class SettingsBuilder implements Settings {
|
|||
// nada
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImmutableSettings() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
|
||||
return settings.isChangeAllowed(settingsDefinition);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue