mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
Bug 303808: Update ConsolePageParticipant for GDB process
This patch officially limits the ConsolePageParticipant to handling consoles from the platform's console view, and not any consoles from the new Debugger Console view. The code currently behaves like this, but this patch cleans it up and no longer even checks for GDB consoles. The ConsolePageParticipant used to provide two things for the GDB console, when it was part of the platform's Console view: 1- it would select the GDB console when the GDB process was selected 2- it would provide a 'save' button for the GDB console For #1, when the GDB process is selected in the debug view, this patch selects the same inferior console as when the launch is selected which is the last inferior console. As for the synchronization of the Debugger Console views, it is already handled by each console itself. For #2 the save button must be handled differently based on the different type of debugger console (basic vs full). This should be done in another commit. Besides, the code, before this patch, was not adding the save button to the debugger consoles since those consoles are not an instanceof org.eclipse.debug.ui.console.IConsole as first checked in ConsolePagePartipant#isConsoleGdbCli() Change-Id: I0813ad2261633ce8630ab5842f06a047868856e8
This commit is contained in:
parent
37db6b290c
commit
c8ce2587e8
1 changed files with 31 additions and 37 deletions
|
@ -35,8 +35,9 @@ import org.eclipse.ui.part.IPageBookViewPage;
|
|||
|
||||
/**
|
||||
* A console page participant for DSF-GDB.
|
||||
* It adds a save button to both the gdb tracing console and the gdb CLI console.
|
||||
* It also brings to the front the proper inferior console when a container is selected.
|
||||
* It adds a save button to the gdb tracing console.
|
||||
* It also brings to the front the proper inferior console when an element of the
|
||||
* debug view is selected.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
|
@ -52,13 +53,13 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo
|
|||
fConsole = console;
|
||||
fView = (IConsoleView)fPage.getSite().getPage().findView(IConsoleConstants.ID_CONSOLE_VIEW);
|
||||
|
||||
if (isConsoleInferior(console) || isConsoleGdbCli(console)) {
|
||||
if (isConsoleInferior(console)) {
|
||||
// This console participant will affect all consoles, even those not for DSF-GDB.
|
||||
// Only consoles for GDBProcess or InferiorRuntimeProcess are what we care about for DSF-GDB
|
||||
// Only consoles for InferiorRuntimeProcess are what we care about for DSF-GDB
|
||||
DebugUITools.getDebugContextManager().getContextService(fPage.getSite().getWorkbenchWindow()).addDebugContextListener(this);
|
||||
}
|
||||
|
||||
if(console instanceof TracingConsole || isConsoleGdbCli(console)) {
|
||||
if (console instanceof TracingConsole) {
|
||||
TextConsole textConsole = (TextConsole) console;
|
||||
|
||||
// Add the save console action
|
||||
|
@ -70,22 +71,6 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the the console is the gdb CLI. We don't rely on the attached
|
||||
* process name. Instead we check if the process is an instance of GDBProcess
|
||||
* This gdb CLI console will only be used if the full GDB console is not available.
|
||||
*
|
||||
* @param console The console to check
|
||||
* @return true if the the console is the gdb CLI
|
||||
*/
|
||||
private boolean isConsoleGdbCli(IConsole console) {
|
||||
if(console instanceof org.eclipse.debug.ui.console.IConsole) {
|
||||
org.eclipse.debug.ui.console.IConsole debugConsole = (org.eclipse.debug.ui.console.IConsole)console;
|
||||
return (debugConsole.getProcess() instanceof GDBProcess);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the the console is for an inferior.
|
||||
*
|
||||
|
@ -93,7 +78,7 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo
|
|||
* @return true if the the console is for an inferior
|
||||
*/
|
||||
private boolean isConsoleInferior(IConsole console) {
|
||||
if(console instanceof org.eclipse.debug.ui.console.IConsole) {
|
||||
if (console instanceof org.eclipse.debug.ui.console.IConsole) {
|
||||
org.eclipse.debug.ui.console.IConsole debugConsole = (org.eclipse.debug.ui.console.IConsole)console;
|
||||
return (debugConsole.getProcess() instanceof InferiorRuntimeProcess);
|
||||
}
|
||||
|
@ -107,7 +92,7 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo
|
|||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (isConsoleInferior(fConsole) || isConsoleGdbCli(fConsole)) {
|
||||
if (isConsoleInferior(fConsole)) {
|
||||
DebugUITools.getDebugContextManager().getContextService(fPage.getSite().getWorkbenchWindow()).removeDebugContextListener(this);
|
||||
}
|
||||
fConsole = null;
|
||||
|
@ -132,32 +117,41 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo
|
|||
IAdaptable context = DebugUITools.getDebugContext();
|
||||
|
||||
// If the launch is selected, we should choose the first inferior being debugged
|
||||
if (context instanceof ILaunch) {
|
||||
ILaunch launch = (ILaunch)context;
|
||||
// If the GDB process is selected, and since the GDB console is not in the standard
|
||||
// console view, we should show a console that is part of the same launch as the
|
||||
// GDB process, so we can treat it the same as the launch selection case
|
||||
if (context instanceof ILaunch || context instanceof GDBProcess) {
|
||||
ILaunch launch;
|
||||
if (context instanceof ILaunch) {
|
||||
launch = (ILaunch)context;
|
||||
} else {
|
||||
launch = ((GDBProcess)context).getLaunch();
|
||||
}
|
||||
|
||||
// Note that ProcessConsolePageParticipant also handles the case
|
||||
// of ILaunch being selected. Usually, that class gets called
|
||||
// after our current class, so the console it chooses wins in the
|
||||
// case of ILaunch.
|
||||
// So, for consistency, when GDBProcess is selected, we choose the
|
||||
// same inferior chosen by ProcessConsolePageParticipant when
|
||||
// ILaunch is selected, which is the last (not the first) inferior
|
||||
// process.
|
||||
// Note that we could ignore the ILaunch case in this class
|
||||
// since it is already handled by ProcessConsolePageParticipant,
|
||||
// but just to be safe and future-proof, we also handle it.
|
||||
IProcess[] processes = launch.getProcesses();
|
||||
if (processes != null && processes.length > 0) {
|
||||
for (IProcess process : processes) {
|
||||
for (int i = processes.length-1; i >= 0; i--) {
|
||||
IProcess process = processes[i];
|
||||
if (process instanceof InferiorRuntimeProcess) {
|
||||
return process;
|
||||
}
|
||||
}
|
||||
|
||||
// No inferior? return the gdb process
|
||||
// We have to check that the process is actually from a DSF-GDB session,
|
||||
// since the current context could be for any debug session
|
||||
if (processes[0] instanceof GDBProcess) {
|
||||
return processes[0];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (context instanceof GDBProcess) {
|
||||
return (GDBProcess)context;
|
||||
}
|
||||
|
||||
if (context != null) {
|
||||
// Look for the process that this context refers to, so we can select its console
|
||||
IDMContext dmc = context.getAdapter(IDMContext.class);
|
||||
|
|
Loading…
Add table
Reference in a new issue