Merge remote-tracking branch 'origin/GP-1825_d-millar_configState--SQUASHED'

This commit is contained in:
Ryan Kurtz
2022-03-22 12:49:21 -04:00
5 changed files with 35 additions and 30 deletions
@@ -33,7 +33,6 @@ public interface DbgModelTargetProcess extends //
DbgModelTargetAccessConditioned, // DbgModelTargetAccessConditioned, //
DbgModelTargetAttacher, // DbgModelTargetAttacher, //
DbgModelTargetAttachable, // DbgModelTargetAttachable, //
DbgModelTargetLauncher, //
DbgModelTargetDeletable, // DbgModelTargetDeletable, //
DbgModelTargetDetachable, // DbgModelTargetDetachable, //
DbgModelTargetKillable, // DbgModelTargetKillable, //
@@ -85,8 +85,6 @@ public class DbgModelTargetProcessImpl extends DbgModelTargetObjectImpl
protected final DbgModelTargetMemoryContainer memory; protected final DbgModelTargetMemoryContainer memory;
protected final DbgModelTargetModuleContainer modules; protected final DbgModelTargetModuleContainer modules;
protected final DbgModelTargetThreadContainer threads; protected final DbgModelTargetThreadContainer threads;
// Note: not sure section info is available from the dbgeng
//protected final DbgModelTargetProcessSectionContainer sections;
private Integer base = 16; private Integer base = 16;
@@ -99,19 +97,16 @@ public class DbgModelTargetProcessImpl extends DbgModelTargetObjectImpl
this.debug = new DbgModelTargetDebugContainerImpl(this); this.debug = new DbgModelTargetDebugContainerImpl(this);
this.memory = new DbgModelTargetMemoryContainerImpl(this); this.memory = new DbgModelTargetMemoryContainerImpl(this);
this.modules = new DbgModelTargetModuleContainerImpl(this); this.modules = new DbgModelTargetModuleContainerImpl(this);
//this.sections = new DbgModelTargetProcessSectionContainerImpl(this);
this.threads = new DbgModelTargetThreadContainerImpl(this); this.threads = new DbgModelTargetThreadContainerImpl(this);
changeAttributes(List.of(), List.of( // changeAttributes(List.of(), List.of( //
debug, // debug, //
memory, // memory, //
modules, // modules, //
//sections, //
threads // threads //
), Map.of( // ), Map.of( //
ACCESSIBLE_ATTRIBUTE_NAME, accessible = false, // ACCESSIBLE_ATTRIBUTE_NAME, accessible = false, //
DISPLAY_ATTRIBUTE_NAME, getDisplay(), // DISPLAY_ATTRIBUTE_NAME, getDisplay(), //
TargetMethod.PARAMETERS_ATTRIBUTE_NAME, PARAMETERS, //
SUPPORTED_ATTACH_KINDS_ATTRIBUTE_NAME, SUPPORTED_KINDS, // SUPPORTED_ATTACH_KINDS_ATTRIBUTE_NAME, SUPPORTED_KINDS, //
SUPPORTED_STEP_KINDS_ATTRIBUTE_NAME, DbgModelTargetThreadImpl.SUPPORTED_KINDS // SUPPORTED_STEP_KINDS_ATTRIBUTE_NAME, DbgModelTargetThreadImpl.SUPPORTED_KINDS //
), "Initialized"); ), "Initialized");
@@ -145,11 +140,6 @@ public class DbgModelTargetProcessImpl extends DbgModelTargetObjectImpl
setExecutionState(targetState, "ThreadStateChanged"); setExecutionState(targetState, "ThreadStateChanged");
} }
@Override
public CompletableFuture<Void> launch(List<String> args) {
return model.gateFuture(DbgModelImplUtils.launch(getModel(), process, args));
}
@Override @Override
public CompletableFuture<Void> resume() { public CompletableFuture<Void> resume() {
return model.gateFuture(process.cont()); return model.gateFuture(process.cont());
@@ -73,7 +73,6 @@ public class DebuggerObjectsPlugin extends AbstractDebuggerPlugin
private DebuggerConsoleService consoleService; private DebuggerConsoleService consoleService;
private List<DebuggerObjectsProvider> providers = new ArrayList<>(); private List<DebuggerObjectsProvider> providers = new ArrayList<>();
private boolean firstPass = true;
private Program activeProgram; private Program activeProgram;
// Because there's no "primary" provider, save a copy of read config state to apply to new providers // Because there's no "primary" provider, save a copy of read config state to apply to new providers
private SaveState copiedSaveState = new SaveState(); private SaveState copiedSaveState = new SaveState();
@@ -87,6 +86,7 @@ public class DebuggerObjectsPlugin extends AbstractDebuggerPlugin
try { try {
ObjectContainer init = new ObjectContainer(null, null); ObjectContainer init = new ObjectContainer(null, null);
DebuggerObjectsProvider p = new DebuggerObjectsProvider(this, null, init, true); DebuggerObjectsProvider p = new DebuggerObjectsProvider(this, null, init, true);
p.readConfigState(copiedSaveState);
init.propagateProvider(p); init.propagateProvider(p);
p.update(init); p.update(init);
p.setVisible(true); p.setVisible(true);
@@ -228,6 +228,7 @@ public class DebuggerObjectsPlugin extends AbstractDebuggerPlugin
toRemove.add(p); toRemove.add(p);
} }
} }
writeConfigState(copiedSaveState);
for (DebuggerObjectsProvider p : toRemove) { for (DebuggerObjectsProvider p : toRemove) {
providers.remove(p); providers.remove(p);
} }
@@ -1438,21 +1438,15 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
public void performLaunch(ActionContext context) { public void performLaunch(ActionContext context) {
performAction(context, true, TargetLauncher.class, launcher -> { performAction(context, true, TargetLauncher.class, launcher -> {
if (currentProgram != null) { String argsKey = TargetCmdLineLauncher.CMDLINE_ARGS_NAME;
// TODO: A generic or pluggable way of deriving the default arguments // TODO: A generic or pluggable way of deriving the default arguments
String path = currentProgram.getExecutablePath(); String path = (currentProgram != null) ? currentProgram.getExecutablePath() : null;
String cmdlineArgs = launchDialog.getMemorizedArgument( launchDialog.setCurrentContext(path);
TargetCmdLineLauncher.CMDLINE_ARGS_NAME, String.class); String cmdlineArgs = launchDialog.getMemorizedArgument(argsKey, String.class);
if (path != null) { if (cmdlineArgs == null) {
if (cmdlineArgs == null) { cmdlineArgs = path;
launchDialog.setMemorizedArgument(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, launchDialog.setMemorizedArgument(argsKey, String.class,
String.class, path); cmdlineArgs);
}
else if (!cmdlineArgs.startsWith(path)) {
launchDialog.setMemorizedArgument(TargetCmdLineLauncher.CMDLINE_ARGS_NAME,
String.class, path);
}
}
} }
Map<String, ?> args = launchDialog.promptArguments(launcher.getParameters()); Map<String, ?> args = launchDialog.promptArguments(launcher.getParameters());
if (args == null) { if (args == null) {
@@ -51,6 +51,12 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
return new NameTypePair(parameter.name, parameter.type); return new NameTypePair(parameter.name, parameter.type);
} }
public static NameTypePair fromParameter(ParameterDescription<?> parameter,
Object context) {
String contextName = addContext(parameter.name, context);
return new NameTypePair(contextName, parameter.type);
}
public static NameTypePair fromString(String name) throws ClassNotFoundException { public static NameTypePair fromString(String name) throws ClassNotFoundException {
String[] parts = name.split(",", 2); String[] parts = name.split(",", 2);
if (parts.length != 2) { if (parts.length != 2) {
@@ -99,6 +105,7 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
// TODO: Not sure this is the best keying, but I think it works. // TODO: Not sure this is the best keying, but I think it works.
private Map<NameTypePair, Object> memorized = new HashMap<>(); private Map<NameTypePair, Object> memorized = new HashMap<>();
private Map<String, ?> arguments; private Map<String, ?> arguments;
private Object currentContext;
public DebuggerMethodInvocationDialog(PluginTool tool, String title, String buttonText, public DebuggerMethodInvocationDialog(PluginTool tool, String title, String buttonText,
Icon buttonIcon) { Icon buttonIcon) {
@@ -110,7 +117,7 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
} }
protected Object computeMemorizedValue(ParameterDescription<?> parameter) { protected Object computeMemorizedValue(ParameterDescription<?> parameter) {
return memorized.computeIfAbsent(NameTypePair.fromParameter(parameter), return memorized.computeIfAbsent(NameTypePair.fromParameter(parameter, currentContext),
ntp -> parameter.defaultValue); ntp -> parameter.defaultValue);
} }
@@ -187,7 +194,7 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
return paramEditors.keySet() return paramEditors.keySet()
.stream() .stream()
.collect(Collectors.toMap(param -> param.name, .collect(Collectors.toMap(param -> param.name,
param -> memorized.get(NameTypePair.fromParameter(param)))); param -> memorized.get(NameTypePair.fromParameter(param, currentContext))));
} }
public Map<String, ?> getArguments() { public Map<String, ?> getArguments() {
@@ -195,10 +202,12 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
} }
public <T> void setMemorizedArgument(String name, Class<T> type, T value) { public <T> void setMemorizedArgument(String name, Class<T> type, T value) {
name = addContext(name, currentContext);
memorized.put(new NameTypePair(name, type), value); memorized.put(new NameTypePair(name, type), value);
} }
public <T> T getMemorizedArgument(String name, Class<T> type) { public <T> T getMemorizedArgument(String name, Class<T> type) {
name = addContext(name, currentContext);
return type.cast(memorized.get(new NameTypePair(name, type))); return type.cast(memorized.get(new NameTypePair(name, type)));
} }
@@ -206,7 +215,7 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
PropertyEditor editor = (PropertyEditor) evt.getSource(); PropertyEditor editor = (PropertyEditor) evt.getSource();
ParameterDescription<?> param = paramEditors.getKey(editor); ParameterDescription<?> param = paramEditors.getKey(editor);
memorized.put(NameTypePair.fromParameter(param), editor.getValue()); memorized.put(NameTypePair.fromParameter(param, currentContext), editor.getValue());
} }
public void writeConfigState(SaveState saveState) { public void writeConfigState(SaveState saveState) {
@@ -236,4 +245,16 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
} }
} }
} }
public Object getCurrentContext() {
return currentContext;
}
public void setCurrentContext(Object currentContext) {
this.currentContext = currentContext;
}
static private String addContext(String name, Object context) {
return context == null ? name : name + ":" + context;
}
} }