GP-2502: add option to set timeout

This commit is contained in:
d-millar
2023-01-27 17:22:28 -05:00
parent d8a144eeee
commit 10d776fe09
4 changed files with 81 additions and 2 deletions
@@ -347,6 +347,10 @@
resulting changes in the GUI may be distracting for some. To disable updates to the Objects resulting changes in the GUI may be distracting for some. To disable updates to the Objects
Viewer, toggle "Updates While Running" off.</P> Viewer, toggle "Updates While Running" off.</P>
<H3><A name="set_node_timout">Set Node Timeout</A></H3>
<P>Set the default value for the timeout used when expanding a node, i.e. populating its children.</P>
<H2><A name="color"></A>Color Options</H2> <H2><A name="color"></A>Color Options</H2>
<P>The debugger represents different types of objects with different colors. Bear in mind these <P>The debugger represents different types of objects with different colors. Bear in mind these
@@ -182,6 +182,7 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
ImportFromXMLAction importFromXMLAction; ImportFromXMLAction importFromXMLAction;
ImportFromFactsAction importFromFactsAction; ImportFromFactsAction importFromFactsAction;
OpenWinDbgTraceAction openTraceAction; OpenWinDbgTraceAction openTraceAction;
SetTimeoutAction setTimeoutAction;
private ToggleDockingAction actionToggleBase; private ToggleDockingAction actionToggleBase;
private ToggleDockingAction actionToggleSubscribe; private ToggleDockingAction actionToggleSubscribe;
@@ -204,6 +205,8 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
private boolean updateWhileRunning = true; private boolean updateWhileRunning = true;
@AutoConfigStateField @AutoConfigStateField
private boolean suppressDescent = false; private boolean suppressDescent = false;
@AutoConfigStateField
private int nodeTimeout = 60;
Set<TargetConfigurable> configurables = new HashSet<>(); Set<TargetConfigurable> configurables = new HashSet<>();
private String lastMethod = ""; private String lastMethod = "";
@@ -857,7 +860,7 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
.buildAndInstallLocal(this); .buildAndInstallLocal(this);
groupTargetIndex++; groupTargetIndex++;
/* /*
actionSuppressDescent = new ToggleActionBuilder("Automatically populate containers", plugin.getName()) actionSuppressDescent = new ToggleActionBuilder("Automatically populate containers", plugin.getName())
.menuPath("Maintenance","&Auto-populate") .menuPath("Maintenance","&Auto-populate")
@@ -1222,6 +1225,7 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
importFromXMLAction = new ImportFromXMLAction(tool, plugin.getName(), this); importFromXMLAction = new ImportFromXMLAction(tool, plugin.getName(), this);
importFromFactsAction = new ImportFromFactsAction(tool, plugin.getName(), this); importFromFactsAction = new ImportFromFactsAction(tool, plugin.getName(), this);
openTraceAction = new OpenWinDbgTraceAction(tool, plugin.getName(), this); openTraceAction = new OpenWinDbgTraceAction(tool, plugin.getName(), this);
setTimeoutAction = new SetTimeoutAction(tool, plugin.getName(), this);
} }
//@formatter:on //@formatter:on
@@ -1858,6 +1862,14 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
this.autoRecord = autorecord; this.autoRecord = autorecord;
} }
public int getNodeTimeout() {
return nodeTimeout;
}
public void setNodeTimeout(int timeout) {
this.nodeTimeout = timeout;
}
public void updateActions(ObjectContainer providerContainer) { public void updateActions(ObjectContainer providerContainer) {
TargetObject obj = getSelectedObject(); TargetObject obj = getSelectedObject();
if (obj != null) { if (obj != null) {
@@ -1889,6 +1901,7 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
actionToggleAutoRecord.setSelected(autoRecord); actionToggleAutoRecord.setSelected(autoRecord);
actionToggleHideIntrinsics.setSelected(hideIntrinsics); actionToggleHideIntrinsics.setSelected(hideIntrinsics);
actionToggleSelectionOnly.setSelected(selectionOnly); actionToggleSelectionOnly.setSelected(selectionOnly);
setTimeoutAction.setNodeTimeout(nodeTimeout);
methodDialog.readConfigState(saveState); methodDialog.readConfigState(saveState);
} }
@@ -0,0 +1,61 @@
/* ###
* 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.app.plugin.core.debug.gui.objects.actions;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.MenuData;
import ghidra.app.plugin.core.debug.gui.objects.DebuggerObjectsProvider;
import ghidra.app.script.AskDialog;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.HelpLocation;
public class SetTimeoutAction extends DockingAction {
DebuggerObjectsProvider provider;
int timeout = 0;
public SetTimeoutAction(PluginTool tool, String owner, DebuggerObjectsProvider provider) {
super("SetTimeout", owner);
setMenuBarData(
new MenuData(new String[] { "Maintenance", "&Set Node Timeout" }, null, "M100"));
setHelpLocation(new HelpLocation(owner, "set_node_timeout"));
this.provider = provider;
provider.addLocalAction(this);
this.timeout = provider.getNodeTimeout();
}
@Override
public boolean isEnabledForContext(ActionContext context) {
return true;
}
@Override
public void actionPerformed(ActionContext context) {
AskDialog<String> dialog =
new AskDialog<String>("Set Node Timeout", "Seconds", AskDialog.INT, timeout);
if (dialog.isCanceled()) {
return;
}
timeout = Integer.parseInt(dialog.getValueAsString());
provider.setNodeTimeout(timeout);
}
public void setNodeTimeout(int timeout) {
this.timeout = timeout;
}
}
@@ -85,7 +85,8 @@ public class ObjectNode extends GTreeSlowLoadingNode { //extends GTreeNode
if (cf != null) { if (cf != null) {
// NB: We're allowed to do this because we're guaranteed to be // NB: We're allowed to do this because we're guaranteed to be
// in our own thread by the GTreeSlowLoadingNode // in our own thread by the GTreeSlowLoadingNode
ObjectContainer oc = cf.get(60, TimeUnit.SECONDS); ObjectContainer oc =
cf.get(tree.getProvider().getNodeTimeout(), TimeUnit.SECONDS);
return tree.update(oc); return tree.update(oc);
} }
} }