mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 15:15:25 +02:00
Bug 228265
Allow a DSF Attach launch without needing cdt.launch
This commit is contained in:
parent
ff33479c3d
commit
34baaa437d
5 changed files with 126 additions and 1 deletions
BIN
plugins/org.eclipse.dd.gdb.ui/icons/full/obj16/exec_obj.gif
Normal file
BIN
plugins/org.eclipse.dd.gdb.ui/icons/full/obj16/exec_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 527 B |
|
@ -36,5 +36,14 @@
|
|||
</enabledWhen>
|
||||
</page>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.core.statusHandlers">
|
||||
<statusHandler
|
||||
class="org.eclipse.dd.gdb.internal.ui.launching.ProcessPrompter"
|
||||
code="100"
|
||||
id="org.eclipse.dd.gdb.ui.processPrompter"
|
||||
plugin="org.eclipse.dd.gdb.ui">
|
||||
</statusHandler>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -34,6 +34,7 @@ public class LaunchImages {
|
|||
}
|
||||
|
||||
private static final String T_TABS = "full/view16/"; //$NON-NLS-1$
|
||||
private static final String T_OBJS = "full/obj16/"; //$NON-NLS-1$
|
||||
|
||||
public static String IMG_VIEW_MAIN_TAB = NAME_PREFIX + "main_tab.gif"; //$NON-NLS-1$
|
||||
public static String IMG_VIEW_DEBUGGER_TAB = NAME_PREFIX + "debugger_tab.gif"; //$NON-NLS-1$
|
||||
|
@ -41,6 +42,9 @@ public class LaunchImages {
|
|||
public static final ImageDescriptor DESC_TAB_MAIN= createManaged(T_TABS, IMG_VIEW_MAIN_TAB);
|
||||
public static final ImageDescriptor DESC_TAB_DEBUGGER = createManaged(T_TABS, IMG_VIEW_DEBUGGER_TAB);
|
||||
|
||||
public static String IMG_OBJS_EXEC= NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_OBJS_EXEC = createManaged(T_OBJS, IMG_OBJS_EXEC);
|
||||
|
||||
public static void initialize() {
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Ericsson - Modified for DSF
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.gdb.internal.ui.launching;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.IProcessInfo;
|
||||
import org.eclipse.cdt.core.IProcessList;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages;
|
||||
import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.debug.core.IStatusHandler;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
|
||||
|
||||
public class ProcessPrompter implements IStatusHandler {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus,
|
||||
* java.lang.Object)
|
||||
*/
|
||||
public Object handleStatus(IStatus status, Object source) throws CoreException {
|
||||
Shell shell = GdbUIPlugin.getShell();
|
||||
if (shell == null) {
|
||||
IStatus error = new Status(IStatus.ERROR, GdbUIPlugin.getUniqueIdentifier(),
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR,
|
||||
LaunchMessages.getString("CoreFileLaunchDelegate.No_Shell_available_in_Launch"), null); //$NON-NLS-1$
|
||||
throw new CoreException(error);
|
||||
}
|
||||
|
||||
ILabelProvider provider = new LabelProvider() {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
|
||||
*/
|
||||
public String getText(Object element) {
|
||||
IProcessInfo info = (IProcessInfo)element;
|
||||
IPath path = new Path(info.getName());
|
||||
return path.lastSegment() + " - " + info.getPid(); //$NON-NLS-1$
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
|
||||
*/
|
||||
public Image getImage(Object element) {
|
||||
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
|
||||
}
|
||||
};
|
||||
ILabelProvider qprovider = new LabelProvider() {
|
||||
|
||||
public String getText(Object element) {
|
||||
IProcessInfo info = (IProcessInfo)element;
|
||||
return info.getName();
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
|
||||
*/
|
||||
public Image getImage(Object element) {
|
||||
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
|
||||
}
|
||||
};
|
||||
TwoPaneElementSelector dialog = new TwoPaneElementSelector(shell, provider, qprovider);
|
||||
dialog.setTitle(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$
|
||||
dialog.setMessage(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$
|
||||
IProcessList plist = null;
|
||||
try {
|
||||
plist = CCorePlugin.getDefault().getProcessList();
|
||||
} catch (CoreException e) {
|
||||
GdbUIPlugin.errorDialog(LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), e.getStatus()); //$NON-NLS-1$
|
||||
}
|
||||
if (plist == null) {
|
||||
MessageDialog.openError(
|
||||
shell,
|
||||
LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), LaunchMessages.getString("LocalAttachLaunchDelegate.Platform_cannot_list_processes")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return null;
|
||||
}
|
||||
dialog.setElements(plist.getProcessList());
|
||||
if (dialog.open() == Window.OK) {
|
||||
IProcessInfo info = (IProcessInfo)dialog.getFirstResult();
|
||||
if (info != null) {
|
||||
return new Integer(info.getPid());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -186,7 +186,7 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate
|
|||
|
||||
protected int promptForProcessID(ILaunchConfiguration config) throws CoreException {
|
||||
IStatus fPromptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||
IStatus processPrompt = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||
IStatus processPrompt = new Status(IStatus.INFO, "org.eclipse.dd.gdb.ui", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||
// consult a status handler
|
||||
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(fPromptStatus);
|
||||
if (prompter != null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue