1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 19:25:38 +02:00

Bug 87556: Post-mortem debug fails silently if core file is inaccessible. Applied patch from Joanne Woo (Monta Vista).

This commit is contained in:
Mikhail Khodjaiants 2005-06-15 17:58:08 +00:00
parent d0824d23fd
commit 0467fe740a
4 changed files with 42 additions and 5 deletions

View file

@ -1,3 +1,10 @@
2005-05-15 Mikhail Khodjaiants
Bug 87556: Post-mortem debug fails silently if core file is inaccessible.
Applied patch from Joanne Woo (Monta Vista).
* CoreFilePrompter.java
* CoreFileLaunchDelegate.java
* LaunchMessages.properties
2005-05-18 David Inglis 2005-05-18 David Inglis
Fixed bug 39581 & part of 46746 Fixed bug 39581 & part of 46746

View file

@ -4,10 +4,14 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html * http://www.eclipse.org/legal/cpl-v10.html
* *
* Contributors: QNX Software Systems - Initial API and implementation * Contributors:
* QNX Software Systems - Initial API and implementation
* Monta Vista - Joanne Woo - Bug 87556
**************************************************************************************************/ **************************************************************************************************/
package org.eclipse.cdt.launch.internal; package org.eclipse.cdt.launch.internal;
import java.io.File;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
@ -37,7 +41,6 @@ import org.eclipse.debug.core.model.IProcess;
public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate { public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
if (monitor == null) { if (monitor == null) {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
@ -63,12 +66,22 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
cancel(LaunchMessages.getString("CoreFileLaunchDelegate.No_Corefile_selected"), //$NON-NLS-1$ cancel(LaunchMessages.getString("CoreFileLaunchDelegate.No_Corefile_selected"), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NO_COREFILE); ICDTLaunchConfigurationConstants.ERR_NO_COREFILE);
} }
File file = new File(corefile.toString());
if (!file.exists() || !file.canRead()) {
cancel(LaunchMessages.getString("CoreFileLaunchDelegate.Corefile_not_readable"), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NO_COREFILE);
}
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, corefile.toString()); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, corefile.toString());
wc.launch(mode, new SubProgressMonitor(monitor, 9)); wc.launch(mode, new SubProgressMonitor(monitor, 9));
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, (String)null); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, (String)null);
cancel("", -1); //$NON-NLS-1$ cancel("", -1); //$NON-NLS-1$
} else { } else {
File file = new File(path);
if (!file.exists() || !file.canRead()) {
abort(LaunchMessages.getString("CoreFileLaunchDelegate.Corefile_not_readable"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NO_COREFILE);
}
dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, new SubProgressMonitor(monitor, 8)); dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, new SubProgressMonitor(monitor, 8));
try { try {
// set the source locator // set the source locator

View file

@ -3,10 +3,14 @@
* accompanying materials are made available under the terms of the Common Public License v1.0 which * accompanying materials are made available under the terms of the Common Public License v1.0 which
* accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html * accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
* *
* Contributors: QNX Software Systems - initial API and implementation * Contributors:
* QNX Software Systems - initial API and implementation
* Monta Vista - Joanne Woo - Bug 87556
**************************************************************************************************/ **************************************************************************************************/
package org.eclipse.cdt.launch.internal.ui; package org.eclipse.cdt.launch.internal.ui;
import java.io.File;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -18,6 +22,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.IStatusHandler; import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.ErrorDialog;
public class CoreFilePrompter implements IStatusHandler { public class CoreFilePrompter implements IStatusHandler {
@ -52,9 +57,17 @@ public class CoreFilePrompter implements IStatusHandler {
dialog.setFilterPath(initPath); dialog.setFilterPath(initPath);
String res = dialog.open(); String res = dialog.open();
if (res != null) { if (res != null) {
File file = new File(res);
if (!file.exists() || !file.canRead()) {
ErrorDialog.openError(shell, LaunchMessages.getString("CoreFileLaunchDelegate.postmortem_debugging_failed"), //$NON-NLS-1$
LaunchMessages.getString("CoreFileLaunchDelegate.Corefile_not_accessible"), //$NON-NLS-1$
new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
ICDTLaunchConfigurationConstants.ERR_NO_COREFILE,
LaunchMessages.getString("CoreFileLaunchDelegate.Corefile_not_readable"), null)); //$NON-NLS-1$
}
return new Path(res); return new Path(res);
} }
return null; return null;
} }
} }

View file

@ -6,7 +6,8 @@
# http://www.eclipse.org/legal/cpl-v10.html # http://www.eclipse.org/legal/cpl-v10.html
# #
# Contributors: # Contributors:
# QNX Software Systems - Initial API and implementation # QNX Software Systems - Initial API and implementation
# Monta Vista - Joanne Woo - Bug 87556
####################################################################### #######################################################################
AbstractCLaunchDelegate.Debugger_not_installed=CDT Debugger not installed AbstractCLaunchDelegate.Debugger_not_installed=CDT Debugger not installed
@ -43,6 +44,9 @@ CoreFileLaunchDelegate.Launching_postmortem_debugger=Launching postmortem debugg
CoreFileLaunchDelegate.No_Corefile_selected=No Corefile selected CoreFileLaunchDelegate.No_Corefile_selected=No Corefile selected
CoreFileLaunchDelegate.No_Shell_available_in_Launch=No Shell available in Launch CoreFileLaunchDelegate.No_Shell_available_in_Launch=No Shell available in Launch
CoreFileLaunchDelegate.Select_Corefile=Select Corefile CoreFileLaunchDelegate.Select_Corefile=Select Corefile
CoreFileLaunchDelegate.Corefile_not_accessible=Core file is not accessible.
CoreFileLaunchDelegate.Corefile_not_readable=Core file does not exist or is not readable.
CoreFileLaunchDelegate.postmortem_debugging_failed=Post-mortem debugging failed
CApplicationLaunchShortcut.Application_Launcher=Application Launcher CApplicationLaunchShortcut.Application_Launcher=Application Launcher
CApplicationLaunchShortcut.ChooseConfigToDebug=Choose a debug configuration to debug CApplicationLaunchShortcut.ChooseConfigToDebug=Choose a debug configuration to debug