1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
@ -120,10 +119,18 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
} }
else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) { else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
int pid = getProcessID(); int pid = getProcessID();
if ( pid == -1 ) {
monitor.setCanceled(true);
return;
}
dsession = cdebugger.createAttachSession(config, exe, pid); dsession = cdebugger.createAttachSession(config, exe, pid);
} }
else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) { else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
IPath corefile = getCoreFilePath((IProject)cproject.getResource()); IPath corefile = getCoreFilePath((IProject)cproject.getResource());
if ( corefile == null ) {
monitor.setCanceled(true);
return;
}
dsession = cdebugger.createCoreSession(config, exe, corefile); dsession = cdebugger.createCoreSession(config, exe, corefile);
} }
} }
@ -167,26 +174,33 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
monitor.done(); monitor.done();
} }
private IPath getCoreFilePath(IProject project) { private IPath getCoreFilePath(final IProject project) {
Shell shell = LaunchUIPlugin.getShell(); final Shell shell = LaunchUIPlugin.getShell();
final String res[] = {null};
if ( shell == null ) if ( shell == null )
return null; return null;
FileDialog dialog = new FileDialog( shell ); Display display = shell.getDisplay();
dialog.setText( "Select Corefile" ); display.syncExec(new Runnable() {
public void run() {
FileDialog dialog = new FileDialog( shell );
dialog.setText( "Select Corefile" );
String initPath = null; String initPath = null;
try { try {
initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath")); initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath"));
}
catch (CoreException e) {
}
if ( initPath == null || initPath.equals("") ) {
initPath = project.getLocation().toString();
}
dialog.setFilterPath( initPath );
res[0] = dialog.open();
}
});
if ( res[0] != null ) {
return new Path( res[0] );
} }
catch (CoreException e) {
}
if ( initPath == null || initPath.equals("") ) {
initPath = project.getLocation().toString();
}
dialog.setFilterPath( initPath );
String res = dialog.open();
if ( res != null )
return new Path( res );
return null; return null;
} }

View file

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