GP-1288: Addressing some of my own review comments

This commit is contained in:
Dan 2021-09-30 19:54:41 +00:00
parent f242f3fc55
commit 2c3d6704af
19 changed files with 45 additions and 87 deletions

View file

@ -17,16 +17,11 @@ package agent.dbgeng.manager.evt;
import agent.dbgeng.manager.breakpoint.DbgBreakpointInfo;
/**
* The event corresponding with "{@code =breakpoint-created}"
*/
public class DbgBreakpointCreatedEvent extends AbstractDbgEvent<DbgBreakpointInfo> {
private final DbgBreakpointInfo bkptInfo;
/**
* Construct a new event by parsing the tail for information
*
* The breakpoint information must be specified by GDB.
* Construct a new event from the given info
*
* @param info breakpoint info
*
@ -39,7 +34,7 @@ public class DbgBreakpointCreatedEvent extends AbstractDbgEvent<DbgBreakpointInf
/**
* Get the breakpoint information
*
* @return the parsed, but not processed, breakpoint information
* @return the breakpoint information
*/
public DbgBreakpointInfo getBreakpointInfo() {
return bkptInfo;

View file

@ -17,16 +17,11 @@ package agent.dbgeng.manager.evt;
import agent.dbgeng.manager.breakpoint.DbgBreakpointInfo;
/**
* The event corresponding with "{@code =breakpoint-deleted}"
*/
public class DbgBreakpointDeletedEvent extends AbstractDbgEvent<DbgBreakpointInfo> {
private final long number;
/**
* Construct a new event by parsing the tail for information
*
* The breakpoint number must be specified by GDB.
* Construct a new event from the given info
*
* @param info breakpoint info
*/

View file

@ -17,17 +17,12 @@ package agent.dbgeng.manager.evt;
import agent.dbgeng.manager.breakpoint.DbgBreakpointInfo;
/**
* The event corresponding with "{@code =breakpoint-modified}"
*/
public class DbgBreakpointModifiedEvent extends AbstractDbgEvent<DbgBreakpointInfo> {
private long bptId;
/**
* Construct a new event by parsing the tail for information
*
* The breakpoint information must be specified by GDB.
* Construct a new event from the given info
*
* @param info breakpoint info
*/
@ -44,7 +39,7 @@ public class DbgBreakpointModifiedEvent extends AbstractDbgEvent<DbgBreakpointIn
/**
* Get the breakpoint information
*
* @return the parsed, but not processed, breakpoint information
* @return the breakpoint information
*/
public DbgBreakpointInfo getBreakpointInfo() {
return getInfo();

View file

@ -18,16 +18,10 @@ package agent.dbgeng.manager.evt;
import agent.dbgeng.manager.DbgCommand;
import agent.dbgeng.manager.DbgState;
/**
* The event corresponding with "{@code ^done}"
*/
public class DbgCommandDoneEvent extends AbstractDbgCompletedCommandEvent {
private DbgCommand<?> cmd;
/**
* Construct a new event, parsing the tail for information
*/
public DbgCommandDoneEvent() {
super();
}

View file

@ -18,9 +18,6 @@ package agent.dbgeng.manager.evt;
import agent.dbgeng.manager.DbgEvent;
import agent.dbgeng.manager.DbgState;
/**
* The event corresponding with "{@code ^error}"
*/
public class DbgCommandErrorEvent extends AbstractDbgCompletedCommandEvent {
/**

View file

@ -17,14 +17,8 @@ package agent.dbgeng.manager.evt;
import agent.dbgeng.manager.DbgState;
/**
* The event corresponding with "{@code ^running}"
*/
public class DbgCommandRunningEvent extends AbstractDbgCompletedCommandEvent {
/**
* Construct a new event, parsing the tail for information
*/
public DbgCommandRunningEvent() {
super();
}

View file

@ -15,9 +15,6 @@
*/
package agent.dbgeng.manager.evt;
/**
* The event corresponding with "{@code ~""}" output records
*/
public class DbgConsoleOutputEvent extends AbstractDbgEvent<String> {
private int mask;

View file

@ -18,9 +18,6 @@ package agent.dbgeng.manager.evt;
import agent.dbgeng.dbgeng.DebugProcessId;
import agent.dbgeng.manager.impl.DbgProcessImpl;
/**
* The event corresponding with "{@code =thread-selected}"
*/
public class DbgProcessSelectedEvent extends AbstractDbgEvent<DebugProcessId> {
private final DebugProcessId id;
private DbgProcessImpl process;

View file

@ -18,16 +18,11 @@ package agent.dbgeng.manager.evt;
import agent.dbgeng.dbgeng.DebugThreadId;
import agent.dbgeng.manager.DbgState;
/**
* The event corresponding with "{@code *running}"
*/
public class DbgRunningEvent extends AbstractDbgEvent<DebugThreadId> {
private final DebugThreadId id;
/**
* Construct a new event, parsing the tail for information
*
* A thread ID must be specified by dbgeng.
* Construct a new event with the given thread ID
*
* @param id the event info
*/

View file

@ -18,9 +18,6 @@ package agent.dbgeng.manager.evt;
import agent.dbgeng.dbgeng.DebugSessionId;
import agent.dbgeng.manager.impl.DbgSessionImpl;
/**
* The event corresponding with "{@code =thread-selected}"
*/
public class DbgSessionSelectedEvent extends AbstractDbgEvent<DebugSessionId> {
private final DebugSessionId id;
private DbgSessionImpl session;

View file

@ -20,18 +20,13 @@ import agent.dbgeng.manager.DbgState;
import agent.dbgeng.manager.impl.DbgStackFrameImpl;
import agent.dbgeng.manager.impl.DbgThreadImpl;
/**
* The event corresponding with "{@code *stopped}"
*/
public class DbgStoppedEvent extends AbstractDbgEvent<DebugThreadId> {
private final DebugThreadId id;
/**
* Construct a new event, parsing the tail for information
* Construct a new event with the given thread ID
*
* A thread ID must be specified by dbgeng.
*
* @param id the event info
* @param id the thread ID
*/
public DbgStoppedEvent(DebugThreadId id) {
super(id);

View file

@ -15,9 +15,6 @@
*/
package agent.dbgeng.manager.evt;
/**
* The event corresponding with "{@code =thread-selected}"
*/
public class DbgSystemErrorEvent extends AbstractDbgEvent<Integer> {
private final int error;
private final int level;

View file

@ -15,9 +15,6 @@
*/
package agent.dbgeng.manager.evt;
/**
* The event corresponding with "{@code =thread-selected}"
*/
public class DbgSystemsEvent extends AbstractDbgEvent<Long> {
private final long id;

View file

@ -21,9 +21,6 @@ import agent.dbgeng.manager.DbgThread;
import agent.dbgeng.manager.impl.DbgStackFrameImpl;
import agent.dbgeng.manager.impl.DbgThreadImpl;
/**
* The event corresponding with "{@code =thread-selected}"
*/
public class DbgThreadSelectedEvent extends AbstractDbgEvent<DebugThreadId> {
private final DebugThreadId id;
private DbgState state;

View file

@ -149,7 +149,7 @@ public class DbgModelTargetEventImpl extends DbgModelTargetObjectImpl
}
@Override
public Map<String, ParameterDescription<?>> getConfigParameters() {
public Map<String, ParameterDescription<?>> getConfigurableOptions() {
Map<String, ParameterDescription<?>> map = new HashMap<>();
ParameterDescription<String> cmdDesc = ParameterDescription.create(String.class,
COMMAND_ATTRIBUTE_NAME, false, "", COMMAND_ATTRIBUTE_NAME, "filter command");

View file

@ -116,7 +116,7 @@ public class DbgModelTargetExceptionImpl extends DbgModelTargetObjectImpl
}
@Override
public Map<String, ParameterDescription<?>> getConfigParameters() {
public Map<String, ParameterDescription<?>> getConfigurableOptions() {
Map<String, ParameterDescription<?>> map = new HashMap<>();
ParameterDescription<String> cmdDesc = ParameterDescription.create(String.class,
COMMAND_ATTRIBUTE_NAME, false, "", COMMAND_ATTRIBUTE_NAME, "filter command");

View file

@ -16,7 +16,7 @@
package agent.dbgeng.dbgeng;
import static org.junit.Assert.*;
import static org.junit.Assume.*;
import static org.junit.Assume.assumeTrue;
import java.io.*;
import java.nio.ByteBuffer;
@ -29,7 +29,6 @@ import com.sun.jna.Native;
import com.sun.jna.platform.win32.COM.COMException;
import com.sun.jna.win32.StdCallLibrary;
//import agent.dbgeng.DummyProc;
import agent.dbgeng.dbgeng.DebugBreakpoint.BreakType;
import agent.dbgeng.dbgeng.DebugClient.*;
import agent.dbgeng.dbgeng.DebugDataSpaces.*;

View file

@ -46,8 +46,7 @@ import ghidra.app.plugin.core.debug.gui.DebuggerResources.*;
import ghidra.app.plugin.core.debug.gui.objects.actions.*;
import ghidra.app.plugin.core.debug.gui.objects.components.*;
import ghidra.app.services.*;
import ghidra.async.AsyncUtils;
import ghidra.async.TypeSpec;
import ghidra.async.*;
import ghidra.dbg.*;
import ghidra.dbg.error.DebuggerMemoryAccessException;
import ghidra.dbg.target.*;
@ -1528,17 +1527,22 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
public void performConfigure(ActionContext context) {
performAction(context, false, TargetConfigurable.class, configurable -> {
Map<String, ParameterDescription<?>> configParameters =
configurable.getConfigParameters();
if (configParameters.size() > 0) {
Map<String, ?> args = configDialog.promptArguments(configParameters);
if (args != null) {
for (Entry<String, ?> entry : args.entrySet()) {
configurable.writeConfigurationOption(entry.getKey(), entry.getValue());
}
}
}
configurable.getConfigurableOptions();
if (configParameters.isEmpty()) {
return AsyncUtils.NIL;
}, "Couldn't configure");
}
Map<String, ?> args = configDialog.promptArguments(configParameters);
if (args == null) {
// User cancelled
return AsyncUtils.NIL;
}
AsyncFence fence = new AsyncFence();
for (Entry<String, ?> entry : args.entrySet()) {
fence.include(
configurable.writeConfigurationOption(entry.getKey(), entry.getValue()));
}
return fence.ready();
}, "Couldn't configure one or more options");
}
public void initiateConsole(ActionContext context) {

View file

@ -26,10 +26,9 @@ import ghidra.dbg.target.TargetMethod.ParameterDescription;
* 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.
* In general, the options are also stored as attributes, so that the current values are retrievable
* by the client. Note that not every attribute denotes a writable option. The list of configurable
* options, along with a description of each, is retrieved using {@link #getConfigurableOptions()}.
*
* <p>
* Options should be close to their scope of applicability. For example, if an object affects the
@ -51,6 +50,11 @@ public interface TargetConfigurable extends TargetObject {
/**
* Write a single option to this object
*
* <p>
* TODO: This should probably be replaced with a {@code configure(Map<String,Object> options)}
* method. That should also make it easy to validate the arguments using the same mechanisms as
* for {@link TargetMethod#invoke(Map)}.
*
* @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.
@ -59,7 +63,16 @@ public interface TargetConfigurable extends TargetObject {
*/
public CompletableFuture<Void> writeConfigurationOption(String key, Object value);
public default Map<String, ParameterDescription<?>> getConfigParameters() {
/**
* Get the map of writable configuration options
*
* <p>
* TODO: Implement this properly in all subclasses to advertise their parameters. Then remove
* this default implementation.
*
* @return a map of names to option descriptions
*/
public default Map<String, ParameterDescription<?>> getConfigurableOptions() {
return new HashMap<>();
}
}