GP-601: Generic configuration + change of base for IDs

This commit is contained in:
d-millar 2021-04-01 18:39:33 -04:00 committed by Dan
parent 314c58e941
commit 92017b9f7d
27 changed files with 602 additions and 111 deletions

View file

@ -0,0 +1,58 @@
/* ###
* IP: GHIDRA
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.dbg.target;
import java.util.concurrent.CompletableFuture;
import ghidra.dbg.DebuggerTargetObjectIface;
/**
* A target with writable configuration options
*
* <p>
* In general, the options are stored as attributes, so that the current values are retrievable by
* the client, and so that the names and types of options are known. Note that not every attribute
* denotes a writable option. Enumeration of available options is not yet specified, but for the
* moment, we assume a subset of the attributes.
*
* <p>
* Options should be close to their scope of applicability. For example, if an object affects the
* whole model, it should be an option of the root, or perhaps an option of a top-level "Options"
* object. If an option affects an object's elements, that option should be on the containing
* object. If an option affects a singular object, that option should probably be on that object
* itself.
*
* <p>
* Furthermore, writing an option should not be the means of triggering an action. Though certainly,
* the model may react to their modification. Actions, in general, should instead be exposed as
* {@link TargetMethod}s.
*/
@DebuggerTargetObjectIface("Configurable")
public interface TargetConfigurable extends TargetObject {
String BASE_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "base";
/**
* Write a single option to this object
*
* @param key the name of the option, typically corresponding to the same-named attribute
* @param value the value to assign the option, typically conforming to the attribute schema
* @return a future which completes when the change is processed.
* @throws {@link DebuggerIllegalArgumentException} if the key is not writable, or if the value
* is not valid.
*/
public CompletableFuture<Void> writeConfigurationOption(String key, Object value);
}

View file

@ -29,6 +29,7 @@ import ghidra.dbg.util.CollectionUtils.AbstractNMap;
/**
* An object which can be invoked as a method
*
* <p>
* TODO: Should parameters and return type be something incorporated into Schemas?
*/
@DebuggerTargetObjectIface("Method")
@ -295,7 +296,11 @@ public interface TargetMethod extends TargetObject {
*
* @return the name-description map of parameters
*/
@TargetAttributeType(name = PARAMETERS_ATTRIBUTE_NAME, required = true, fixed = true, hidden = true)
@TargetAttributeType(
name = PARAMETERS_ATTRIBUTE_NAME,
required = true,
fixed = true,
hidden = true)
default public TargetParameterMap getParameters() {
return getParameters(this);
}
@ -310,7 +315,11 @@ public interface TargetMethod extends TargetObject {
*
* @return the return type
*/
@TargetAttributeType(name = RETURN_TYPE_ATTRIBUTE_NAME, required = true, fixed = true, hidden = true)
@TargetAttributeType(
name = RETURN_TYPE_ATTRIBUTE_NAME,
required = true,
fixed = true,
hidden = true)
default public Class<?> getReturnType() {
return getTypedAttributeNowByName(RETURN_TYPE_ATTRIBUTE_NAME, Class.class, Object.class);
}

View file

@ -159,13 +159,13 @@ import ghidra.lifecycle.Internal;
public interface TargetObject extends Comparable<TargetObject> {
Set<Class<? extends TargetObject>> ALL_INTERFACES =
Set.of(TargetAccessConditioned.class, TargetAggregate.class, TargetAttachable.class,
TargetAttacher.class, TargetBreakpointLocation.class,
Set.of(TargetAccessConditioned.class, TargetActiveScope.class, TargetAggregate.class,
TargetAttachable.class, TargetAttacher.class, TargetBreakpointLocation.class,
TargetBreakpointLocationContainer.class, TargetBreakpointSpec.class,
TargetBreakpointSpecContainer.class, TargetConsole.class, TargetDataTypeMember.class,
TargetDataTypeNamespace.class, TargetDeletable.class, TargetDetachable.class,
TargetEnvironment.class, TargetEventScope.class, TargetExecutionStateful.class,
TargetActiveScope.class, TargetFocusScope.class, TargetInterpreter.class,
TargetBreakpointSpecContainer.class, TargetConfigurable.class, TargetConsole.class,
TargetDataTypeMember.class, TargetDataTypeNamespace.class, TargetDeletable.class,
TargetDetachable.class, TargetEnvironment.class, TargetEventScope.class,
TargetExecutionStateful.class, TargetFocusScope.class, TargetInterpreter.class,
TargetInterruptible.class, TargetKillable.class, TargetLauncher.class,
TargetMemory.class, TargetMemoryRegion.class, TargetMethod.class, TargetModule.class,
TargetModuleContainer.class, TargetNamedDataType.class, TargetProcess.class,

View file

@ -50,6 +50,7 @@
<attribute name="_value" schema="ANY" hidden="yes" />
<attribute name="_type" schema="STRING" hidden="yes" />
<attribute name="_order" schema="INT" hidden="yes" />
<attribute name="base" schema="INT" hidden="yes" />
<attribute schema="ANY" />
</schema>
<schema name="Interpreter" elementResync="NEVER" attributeResync="NEVER">