1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

added support for corefile processing

This commit is contained in:
David Inglis 2002-08-29 19:30:45 +00:00
parent 5836a1ff35
commit 88c2aee2e7
3 changed files with 130 additions and 57 deletions

View file

@ -12,7 +12,6 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
@ -120,10 +119,18 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
}
else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
int pid = getProcessID();
if ( pid == -1 ) {
monitor.setCanceled(true);
return;
}
dsession = cdebugger.createAttachSession(config, exe, pid);
}
else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
IPath corefile = getCoreFilePath((IProject)cproject.getResource());
if ( corefile == null ) {
monitor.setCanceled(true);
return;
}
dsession = cdebugger.createCoreSession(config, exe, corefile);
}
}
@ -167,10 +174,14 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
monitor.done();
}
private IPath getCoreFilePath(IProject project) {
Shell shell = LaunchUIPlugin.getShell();
private IPath getCoreFilePath(final IProject project) {
final Shell shell = LaunchUIPlugin.getShell();
final String res[] = {null};
if ( shell == null )
return null;
Display display = shell.getDisplay();
display.syncExec(new Runnable() {
public void run() {
FileDialog dialog = new FileDialog( shell );
dialog.setText( "Select Corefile" );
@ -184,9 +195,12 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
initPath = project.getLocation().toString();
}
dialog.setFilterPath( initPath );
String res = dialog.open();
if ( res != null )
return new Path( res );
res[0] = dialog.open();
}
});
if ( res[0] != null ) {
return new Path( res[0] );
}
return null;
}

View file

@ -19,6 +19,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin {
* Launch UI plug-in instance
*/
private static LaunchUIPlugin fgPlugin;
private static Shell debugDialogShell;
/**
* Constructor for LaunchUIPlugin.
@ -47,10 +48,22 @@ public class LaunchUIPlugin extends AbstractUIPlugin {
}
public static Shell getShell() {
Shell shell = null;
if (getActiveWorkbenchWindow() != null) {
return getActiveWorkbenchWindow().getShell();
shell = getActiveWorkbenchWindow().getShell();
}
return null;
if ( shell == null ) {
if ( debugDialogShell != null ) {
if (!debugDialogShell.isDisposed() )
return debugDialogShell;
debugDialogShell = null;
}
}
return shell;
}
public static void setDebugDialogShell(Shell shell) {
debugDialogShell = shell;
}
/**

View file

@ -13,6 +13,7 @@ import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@ -33,9 +34,8 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
public class CDebuggerTab extends CLaunchConfigurationTab {
Combo fDCombo;
Button stopInMain;
protected Combo fDCombo;
protected Button fStopInMain;
protected Button fAttachButton;
protected Button fCoreButton;
protected Button fRunButton;
@ -49,9 +49,11 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
protected ILaunchConfiguration fLaunchConfiguration;
public void createControl(Composite parent) {
GridData gd;
Composite comp = new Composite(parent, SWT.NONE);
setControl(comp);
GridLayout topLayout = new GridLayout(3, false);
GridLayout topLayout = new GridLayout(2, false);
comp.setLayout(topLayout);
Label dlabel = new Label(comp, SWT.NONE);
dlabel.setText("Debugger:");
@ -61,23 +63,43 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
handleDebuggerComboBoxModified();
}
});
stopInMain = new Button(comp, SWT.CHECK);
stopInMain.setText("Stop at main() on startup.");
GridData gd = new GridData();
gd.horizontalIndent = 10;
stopInMain.setLayoutData(gd);
Composite radioComp = new Composite(comp, SWT.NONE);
GridLayout radioLayout = new GridLayout(3, true);
radioLayout.marginHeight = 0;
radioLayout.marginWidth = 0;
radioComp.setLayout(radioLayout);
gd = new GridData();
gd.horizontalSpan = 3;
gd.horizontalSpan = 2;
radioComp.setLayoutData(gd);
fRunButton = createRadioButton(radioComp, "Run program in debugger.");
fRunButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if ( fRunButton.getSelection() == true ) {
fStopInMain.setEnabled(true);
} else {
fStopInMain.setEnabled(false);
}
updateLaunchConfigurationDialog();
}
});
fAttachButton = createRadioButton(radioComp, "Attach to running process.");
fAttachButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog();
}
});
fCoreButton = createRadioButton(radioComp, "View Corefile.");
fCoreButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog();
}
});
fStopInMain = new Button(comp, SWT.CHECK);
fStopInMain.setText("Stop at main() on startup.");
gd = new GridData();
gd.horizontalSpan = 2;
fStopInMain.setLayoutData(gd);
Group debuggerGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
debuggerGroup.setText("Debugger Options");
@ -88,8 +110,9 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
tabHolderLayout.numColumns = 1;
getDynamicTabHolder().setLayout(tabHolderLayout);
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 3;
gd.horizontalSpan = 2;
getDynamicTabHolder().setLayoutData(gd);
LaunchUIPlugin.setDebugDialogShell(parent.getShell());
}
protected void setDynamicTabHolder(Composite tabHolder) {
@ -163,6 +186,9 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
int x = 0;
int selndx = 0;
for (int i = 0; i < debugConfigs.length; i++) {
if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)
|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)
|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
String supported[] = debugConfigs[i].getPlatforms();
for (int j = 0; j < supported.length; j++) {
if (supported[j].equals("*") || supported[j].equalsIgnoreCase(platform)) {
@ -176,6 +202,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
}
}
}
}
fDCombo.select(selndx);
fDCombo.getParent().layout(true);
}
@ -204,20 +231,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
dynamicTab.initializeFrom(config);
}
if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false) == true) {
stopInMain.setSelection(true);
}
String mode =
config.getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
fAttachButton.setSelection(true);
}
else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
fCoreButton.setSelection(true);
}
else {
fRunButton.setSelection(true);
fStopInMain.setSelection(true);
}
}
catch (CoreException e) {
@ -235,7 +249,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
else {
dynamicTab.performApply(config);
}
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, stopInMain.getSelection());
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
if (fAttachButton.getSelection() == true) {
config.setAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
@ -247,6 +261,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
}
else {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
config.setAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
@ -262,7 +277,12 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
setErrorMessage("No debugger avalible");
return false;
}
if ( !fRunButton.getSelection()
&& !fAttachButton.getSelection()
&& !fCoreButton.getSelection() ) {
setErrorMessage("Select a Debug mode.");
return false;
}
ILaunchConfigurationTab dynamicTab = getDynamicTab();
if (dynamicTab != null) {
return dynamicTab.isValid(config);
@ -308,8 +328,34 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
getDynamicTab().getControl().setVisible(true);
getDynamicTabHolder().layout(true);
fRunButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN));
fRunButton.setSelection(false);
fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH));
fAttachButton.setSelection(false);
fCoreButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE));
fCoreButton.setSelection(false);
try {
String mode =
getLaunchConfiguration().getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN) && fRunButton.isEnabled()) {
fRunButton.setSelection(true);
}
else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH) && fAttachButton.isEnabled()) {
fAttachButton.setSelection(true);
}
else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE) && fCoreButton.isEnabled()) {
fCoreButton.setSelection(true);
}
if ( fRunButton.getSelection() == true ) {
fStopInMain.setEnabled(true);
} else {
fStopInMain.setEnabled(false);
}
}
catch (CoreException e) {
}
}
/**