diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java index eeb6f969fc..7dba84da35 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java @@ -143,7 +143,7 @@ public interface DebuggerResources { HelpLocation HELP_PROVIDER_BREAKPOINTS = new HelpLocation( PluginUtils.getPluginNameFromClass(DebuggerBreakpointsPlugin.class), HELP_ANCHOR_PLUGIN); - String TITLE_PROVIDER_LISTING = "Listing"; + String TITLE_PROVIDER_LISTING = "Dynamic"; ImageIcon ICON_PROVIDER_LISTING = ICON_LISTING; HelpLocation HELP_PROVIDER_LISTING = new HelpLocation( PluginUtils.getPluginNameFromClass(DebuggerListingPlugin.class), HELP_ANCHOR_PLUGIN); @@ -198,6 +198,8 @@ public interface DebuggerResources { HelpLocation HELP_PROVIDER_WATCHES = new HelpLocation( PluginUtils.getPluginNameFromClass(DebuggerWatchesPlugin.class), HELP_ANCHOR_PLUGIN); + String TITLE_PROVIDER_INTERPRETER = "Interpreter"; + String BOOKMARK_CATEGORY_MEMORY_READ_ERROR = "Debugger Memory Read Error"; String OPTION_NAME_COLORS_STALE_MEMORY = "Colors.Stale Memory"; diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/AbstractDebuggerWrappedConsoleConnection.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/AbstractDebuggerWrappedConsoleConnection.java index 383e24703a..f5a74b38ef 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/AbstractDebuggerWrappedConsoleConnection.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/AbstractDebuggerWrappedConsoleConnection.java @@ -28,6 +28,7 @@ import docking.action.ToggleDockingAction; import ghidra.app.plugin.core.console.CodeCompletion; import ghidra.app.plugin.core.debug.gui.DebuggerResources; import ghidra.app.plugin.core.debug.gui.DebuggerResources.PinInterpreterAction; +import ghidra.app.plugin.core.interpreter.InterpreterComponentProvider; import ghidra.app.plugin.core.interpreter.InterpreterConsole; import ghidra.dbg.target.TargetConsole.Channel; import ghidra.dbg.target.TargetConsole.TargetConsoleListener; @@ -35,6 +36,7 @@ import ghidra.dbg.target.TargetInterpreter; import ghidra.dbg.target.TargetInterpreter.TargetInterpreterListener; import ghidra.dbg.target.TargetObject; import ghidra.util.Msg; +import ghidra.util.Swing; public abstract class AbstractDebuggerWrappedConsoleConnection implements DebuggerInterpreterConnection { @@ -71,26 +73,29 @@ public abstract class AbstractDebuggerWrappedConsoleConnection provider.setSubTitle(display)); } @Override public void promptChanged(TargetInterpreter i, String prompt) { - guiConsole.setPrompt(prompt); + Swing.runLater(() -> guiConsole.setPrompt(prompt)); } @Override public void invalidated(TargetObject object, String reason) { - if (object == targetConsole) { // Redundant - if (pinned) { - running.set(false); - plugin.disableConsole(targetConsole, guiConsole); + Swing.runLater(() -> { + if (object == targetConsole) { // Redundant + if (pinned) { + running.set(false); + plugin.disableConsole(targetConsole, guiConsole); + } + else { + plugin.destroyConsole(targetConsole, guiConsole); + } } - else { - plugin.destroyConsole(targetConsole, guiConsole); - } - } + }); } } @@ -108,9 +113,6 @@ public abstract class AbstractDebuggerWrappedConsoleConnection connection) { - InterpreterConsole console = consoleService.createInterpreterPanel(connection, true); + //InterpreterConsole console = consoleService.createInterpreterPanel(connection, true); + // TODO: Just fix the console plugin + InterpreterConsole console = new DebuggerInterpreterProvider( + (InterpreterPanelPlugin) consoleService, connection, true); connection.setConsole(console); connection.runInBackground(); } diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/DebuggerInterpreterProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/DebuggerInterpreterProvider.java new file mode 100644 index 0000000000..27a9a94a31 --- /dev/null +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/DebuggerInterpreterProvider.java @@ -0,0 +1,42 @@ +/* ### + * 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.interpreters; + +import ghidra.app.plugin.core.interpreter.*; + +public class DebuggerInterpreterProvider extends InterpreterComponentProvider { + + // If only ComponentProvider#subTitle weren't private + // Really, if only InterpreterComponentProvider#getSubTitle weren't overridden + // TODO: Have it just call setSubTitle in its constructor + protected String subTitle; + + public DebuggerInterpreterProvider(InterpreterPanelPlugin plugin, + InterpreterConnection interpreter, boolean visible) { + super(plugin, interpreter, visible); + } + + @Override + public void setSubTitle(String subTitle) { + this.subTitle = subTitle; + super.setSubTitle(subTitle); + } + + @Override + public String getSubTitle() { + return subTitle; + } +} diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java index e1c07d5c1e..64a687cf80 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java @@ -15,7 +15,8 @@ */ package ghidra.app.plugin.core.debug.gui.listing; -import static ghidra.app.plugin.core.debug.gui.DebuggerResources.*; +import static ghidra.app.plugin.core.debug.gui.DebuggerResources.ICON_REGISTER_MARKER; +import static ghidra.app.plugin.core.debug.gui.DebuggerResources.OPTION_NAME_COLORS_REGISTER_MARKERS; import java.awt.Color; import java.io.File; @@ -29,6 +30,7 @@ import javax.swing.JLabel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import org.apache.commons.lang3.StringUtils; import org.jdom.Element; import docking.ActionContext; @@ -416,7 +418,13 @@ public class DebuggerListingProvider extends CodeViewerProvider implements Listi addListingDisplayListener(this); this.setNorthComponent(locationLabel); - updateTitle(); + if (isConnected) { + setTitle(DebuggerResources.TITLE_PROVIDER_LISTING); + } + else { + setTitle("[" + DebuggerResources.TITLE_PROVIDER_LISTING + "]"); + } + updateTitle(); // Actually, the subtitle setHelpLocation(DebuggerResources.HELP_PROVIDER_LISTING); } @@ -630,28 +638,25 @@ public class DebuggerListingProvider extends CodeViewerProvider implements Listi } } - protected String computeTitle() { + protected String computeSubTitle() { TraceProgramView view = current.getView(); - String prefix = trackingSpec == null ? "Dynamic" : trackingSpec.computeTitle(current); - if (prefix == null) { - prefix = "Dynamic"; + List parts = new ArrayList<>(); + if (trackingSpec != null) { + String specTitle = trackingSpec.computeTitle(current); + if (specTitle != null) { + parts.add(specTitle); + } } - String title; - if (view == null) { - title = prefix; + if (view != null) { + parts.add(current.getTrace().getDomainFile().getName()); } - else { - title = prefix + ": " + current.getTrace().getDomainFile().getName(); - } - if (followsCurrentThread) { - return title; - } - return "[" + title + "]"; + return StringUtils.join(parts, ", "); } - @Override + // TODO: Once refactored, this is not part of the abstract impl. + @Override // Since we want to override, we can't rename updateSubTitle protected void updateTitle() { - setTitle(computeTitle()); + setSubTitle(computeSubTitle()); } protected TraceSection getSmallestSectionAt(Address address) { diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRegistersProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRegistersProvider.java index 140f0a5ec8..d4a65de9fe 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRegistersProvider.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRegistersProvider.java @@ -378,21 +378,25 @@ public class DebuggerRegistersProvider extends ComponentProviderAdapter @SuppressWarnings("unused") private final AutoService.Wiring autoServiceWiring; - @AutoOptionDefined(name = DebuggerResources.OPTION_NAME_COLORS_REGISTER_STALE, // - description = "Text color for registers whose value is not known", // - help = @HelpInfo(anchor = "colors")) + @AutoOptionDefined( + name = DebuggerResources.OPTION_NAME_COLORS_REGISTER_STALE, // + description = "Text color for registers whose value is not known", // + help = @HelpInfo(anchor = "colors")) protected Color registerStaleColor = DebuggerResources.DEFAULT_COLOR_REGISTER_STALE; - @AutoOptionDefined(name = DebuggerResources.OPTION_NAME_COLORS_REGISTER_STALE_SEL, // - description = "Selected text color for registers whose value is not known", // - help = @HelpInfo(anchor = "colors")) + @AutoOptionDefined( + name = DebuggerResources.OPTION_NAME_COLORS_REGISTER_STALE_SEL, // + description = "Selected text color for registers whose value is not known", // + help = @HelpInfo(anchor = "colors")) protected Color registerStaleSelColor = DebuggerResources.DEFAULT_COLOR_REGISTER_STALE_SEL; - @AutoOptionDefined(name = DebuggerResources.OPTION_NAME_COLORS_REGISTER_CHANGED, // - description = "Text color for registers whose value just changed", // - help = @HelpInfo(anchor = "colors")) + @AutoOptionDefined( + name = DebuggerResources.OPTION_NAME_COLORS_REGISTER_CHANGED, // + description = "Text color for registers whose value just changed", // + help = @HelpInfo(anchor = "colors")) protected Color registerChangesColor = DebuggerResources.DEFAULT_COLOR_REGISTER_CHANGED; - @AutoOptionDefined(name = DebuggerResources.OPTION_NAME_COLORS_REGISTER_CHANGED_SEL, // - description = "Selected text color for registers whose value just changed", // - help = @HelpInfo(anchor = "colors")) + @AutoOptionDefined( + name = DebuggerResources.OPTION_NAME_COLORS_REGISTER_CHANGED_SEL, // + description = "Selected text color for registers whose value just changed", // + help = @HelpInfo(anchor = "colors")) protected Color registerChangesSelColor = DebuggerResources.DEFAULT_COLOR_REGISTER_CHANGED_SEL; @SuppressWarnings("unused") @@ -638,18 +642,13 @@ public class DebuggerRegistersProvider extends ComponentProviderAdapter return isClone; } - protected String computeTitle() { + protected String computeSubTitle() { TraceThread curThread = current.getThread(); - String threadPart = curThread == null ? "" : (": " + curThread.getName()); - if (isClone) { - return "[" + DebuggerResources.TITLE_PROVIDER_REGISTERS + threadPart + ", " + - current.getSnap() + "]"; - } - return DebuggerResources.TITLE_PROVIDER_REGISTERS + threadPart; + return curThread == null ? "" : curThread.getName(); } - protected void updateTitle() { - setTitle(computeTitle()); + protected void updateSubTitle() { + setSubTitle(computeSubTitle()); } private void removeOldTraceListener() { @@ -711,7 +710,7 @@ public class DebuggerRegistersProvider extends ComponentProviderAdapter readTheseCoords = false; doSetTrace(current.getTrace()); doSetRecorder(current.getRecorder()); - updateTitle(); + updateSubTitle(); loadRegistersAndValues(); contextChanged(); diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProvider.java index 1b4b9964cb..e17a73151e 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProvider.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProvider.java @@ -218,6 +218,7 @@ public class DebuggerStackProvider extends ComponentProviderAdapter { this.autoServiceWiring = AutoService.wireServicesConsumed(plugin, this); + setTitle(DebuggerResources.TITLE_PROVIDER_STACK); setIcon(DebuggerResources.ICON_PROVIDER_STACK); setHelpLocation(DebuggerResources.HELP_PROVIDER_STACK); setWindowMenuGroup(DebuggerPluginPackage.NAME); @@ -394,14 +395,13 @@ public class DebuggerStackProvider extends ComponentProviderAdapter { selectCurrentFrame(); } - protected String computeTitle() { + protected String computeSubTitle() { TraceThread curThread = current.getThread(); - String threadPart = curThread == null ? "" : (": " + curThread.getName()); - return DebuggerResources.TITLE_PROVIDER_STACK + threadPart; + return curThread == null ? "" : curThread.getName(); } - protected void updateTitle() { - setTitle(computeTitle()); + protected void updateSubTitle() { + setSubTitle(computeSubTitle()); } private void removeOldListeners() { @@ -437,7 +437,7 @@ public class DebuggerStackProvider extends ComponentProviderAdapter { doSetTrace(current.getTrace()); loadStack(); - updateTitle(); + updateSubTitle(); } protected void selectCurrentFrame() {