Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1825: removed redundant set GP-1825: config/launch should always follow root GP-1825: writing state on disconnect GP-1825: adding context to dialogs GP-1825: fix for configState

d-millar18ed2c06a6f7
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/iface2/DbgModelTargetProcess.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/iface2/DbgModelTargetProcess.java
index 3222e8eae0..fe70a1c952 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/iface2/DbgModelTargetProcess.java
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/iface2/DbgModelTargetProcess.java
@@ -33,7 +33,6 @@ public interface DbgModelTargetProcess extends //
DbgModelTargetAccessConditioned, //
DbgModelTargetAttacher, //
DbgModelTargetAttachable, //
- DbgModelTargetLauncher, //
DbgModelTargetDeletable, //
DbgModelTargetDetachable, //
DbgModelTargetKillable, //
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetProcessImpl.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetProcessImpl.java
index 87194d3931..cb322ee3b6 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetProcessImpl.java
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetProcessImpl.java
@@ -85,8 +85,6 @@ public class DbgModelTargetProcessImpl extends DbgModelTargetObjectImpl
protected final DbgModelTargetMemoryContainer memory;
protected final DbgModelTargetModuleContainer modules;
protected final DbgModelTargetThreadContainer threads;
- // Note: not sure section info is available from the dbgeng
- //protected final DbgModelTargetProcessSectionContainer sections;
private Integer base = 16;
@@ -99,19 +97,16 @@ public class DbgModelTargetProcessImpl extends DbgModelTargetObjectImpl
this.debug = new DbgModelTargetDebugContainerImpl(this);
this.memory = new DbgModelTargetMemoryContainerImpl(this);
this.modules = new DbgModelTargetModuleContainerImpl(this);
- //this.sections = new DbgModelTargetProcessSectionContainerImpl(this);
this.threads = new DbgModelTargetThreadContainerImpl(this);
changeAttributes(List.of(), List.of( //
debug, //
memory, //
modules, //
- //sections, //
threads //
), Map.of( //
ACCESSIBLE_ATTRIBUTE_NAME, accessible = false, //
DISPLAY_ATTRIBUTE_NAME, getDisplay(), //
- TargetMethod.PARAMETERS_ATTRIBUTE_NAME, PARAMETERS, //
SUPPORTED_ATTACH_KINDS_ATTRIBUTE_NAME, SUPPORTED_KINDS, //
SUPPORTED_STEP_KINDS_ATTRIBUTE_NAME, DbgModelTargetThreadImpl.SUPPORTED_KINDS //
), "Initialized");
@@ -145,11 +140,6 @@ public class DbgModelTargetProcessImpl extends DbgModelTargetObjectImpl
setExecutionState(targetState, "ThreadStateChanged");
}
- @Override
- public CompletableFuture<Void> launch(List<String> args) {
- return model.gateFuture(DbgModelImplUtils.launch(getModel(), process, args));
- }
-
@Override
public CompletableFuture<Void> resume() {
return model.gateFuture(process.cont());
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsPlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsPlugin.java
index 14210fd37a..2ca4f917d9 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsPlugin.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsPlugin.java
@@ -73,7 +73,6 @@ public class DebuggerObjectsPlugin extends AbstractDebuggerPlugin
private DebuggerConsoleService consoleService;
private List<DebuggerObjectsProvider> providers = new ArrayList<>();
- private boolean firstPass = true;
private Program activeProgram;
// Because there's no "primary" provider, save a copy of read config state to apply to new providers
private SaveState copiedSaveState = new SaveState();
@@ -87,6 +86,7 @@ public class DebuggerObjectsPlugin extends AbstractDebuggerPlugin
try {
ObjectContainer init = new ObjectContainer(null, null);
DebuggerObjectsProvider p = new DebuggerObjectsProvider(this, null, init, true);
+ p.readConfigState(copiedSaveState);
init.propagateProvider(p);
p.update(init);
p.setVisible(true);
@@ -228,6 +228,7 @@ public class DebuggerObjectsPlugin extends AbstractDebuggerPlugin
toRemove.add(p);
}
}
+ writeConfigState(copiedSaveState);
for (DebuggerObjectsProvider p : toRemove) {
providers.remove(p);
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsProvider.java
index d97732bfb3..f7560a6857 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsProvider.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsProvider.java
@@ -1381,21 +1381,15 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
public void performLaunch(ActionContext context) {
performAction(context, true, TargetLauncher.class, launcher -> {
- if (currentProgram != null) {
- // TODO: A generic or pluggable way of deriving the default arguments
- String path = currentProgram.getExecutablePath();
- String cmdlineArgs = launchDialog.getMemorizedArgument(
- TargetCmdLineLauncher.CMDLINE_ARGS_NAME, String.class);
- if (path != null) {
- if (cmdlineArgs == null) {
- launchDialog.setMemorizedArgument(TargetCmdLineLauncher.CMDLINE_ARGS_NAME,
- String.class, path);
- }
- else if (!cmdlineArgs.startsWith(path)) {
- launchDialog.setMemorizedArgument(TargetCmdLineLauncher.CMDLINE_ARGS_NAME,
- String.class, path);
- }
- }
+ String argsKey = TargetCmdLineLauncher.CMDLINE_ARGS_NAME;
+ // TODO: A generic or pluggable way of deriving the default arguments
+ String path = (currentProgram != null) ? currentProgram.getExecutablePath() : null;
+ launchDialog.setCurrentContext(path);
+ String cmdlineArgs = launchDialog.getMemorizedArgument(argsKey, String.class);
+ if (cmdlineArgs == null) {
+ cmdlineArgs = path;
+ launchDialog.setMemorizedArgument(argsKey, String.class,
+ cmdlineArgs);
}
Map<String, ?> args = launchDialog.promptArguments(launcher.getParameters());
if (args == null) {
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/components/DebuggerMethodInvocationDialog.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/components/DebuggerMethodInvocationDialog.java
index fc3e46e454..901a24ae27 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/components/DebuggerMethodInvocationDialog.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/components/DebuggerMethodInvocationDialog.java
@@ -51,6 +51,12 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
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 {
String[] parts = name.split(",", 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.
private Map<NameTypePair, Object> memorized = new HashMap<>();
private Map<String, ?> arguments;
+ private Object currentContext;
public DebuggerMethodInvocationDialog(PluginTool tool, String title, String buttonText,
Icon buttonIcon) {
@@ -110,7 +117,7 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
}
protected Object computeMemorizedValue(ParameterDescription<?> parameter) {
- return memorized.computeIfAbsent(NameTypePair.fromParameter(parameter),
+ return memorized.computeIfAbsent(NameTypePair.fromParameter(parameter, currentContext),
ntp -> parameter.defaultValue);
}
@@ -187,7 +194,7 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
return paramEditors.keySet()
.stream()
.collect(Collectors.toMap(param -> param.name,
- param -> memorized.get(NameTypePair.fromParameter(param))));
+ param -> memorized.get(NameTypePair.fromParameter(param, currentContext))));
}
public Map<String, ?> getArguments() {
@@ -195,10 +202,12 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
}
public <T> void setMemorizedArgument(String name, Class<T> type, T value) {
+ name = addContext(name, currentContext);
memorized.put(new NameTypePair(name, type), value);
}
public <T> T getMemorizedArgument(String name, Class<T> type) {
+ name = addContext(name, currentContext);
return type.cast(memorized.get(new NameTypePair(name, type)));
}
@@ -206,7 +215,7 @@ public class DebuggerMethodInvocationDialog extends DialogComponentProvider
public void propertyChange(PropertyChangeEvent evt) {
PropertyEditor editor = (PropertyEditor) evt.getSource();
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) {
@@ -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;
+ }
}