mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 03:53:21 +02:00
fix for 148415 by Corey Ashford
This commit is contained in:
parent
27d806f738
commit
a0368c245a
5 changed files with 136 additions and 7 deletions
|
@ -33,12 +33,12 @@ import org.eclipse.cdt.managedbuilder.macros.IFileContextBuildMacroValues;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.IFileContextData;
|
import org.eclipse.cdt.managedbuilder.macros.IFileContextData;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.IOptionContextData;
|
import org.eclipse.cdt.managedbuilder.macros.IOptionContextData;
|
||||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||||
|
import org.eclipse.cdt.utils.Platform;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.PluginVersionIdentifier;
|
import org.eclipse.core.runtime.PluginVersionIdentifier;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,10 @@ import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
||||||
import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
|
import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
|
||||||
|
import org.eclipse.cdt.utils.Platform;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
//import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 IBM Corporation 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:
|
||||||
|
* IBM Corporation - Initial API and implementation (Corey Ashford)
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.utils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
|
public final class Platform {
|
||||||
|
|
||||||
|
// This class duplicates all of the methods in org.eclipse.core.runtime.Platform
|
||||||
|
// that are used by the CDT. getOSArch() needs a few tweaks because the value returned
|
||||||
|
// by org.eclipse.core.runtime.Platform.getOSArch represents what the JVM thinks the
|
||||||
|
// architecture is. In some cases, we may actually be running on a 64-bit machine,
|
||||||
|
// but the JVM thinks it's running on a 32-bit machine. Without this change, the CDT
|
||||||
|
// will not handle 64-bit executables on some ppc64. This method could easily be
|
||||||
|
// extended to handle other platforms with similar issues.
|
||||||
|
//
|
||||||
|
// Unfortunately, the org.eclipse.core.runtime.Platform is final, so we cannot just
|
||||||
|
// extend it and and then override the getOSArch method, so getBundle and getOS just
|
||||||
|
// encapsulate calls to the same methods in org.eclipse.core.runtime.Platform.
|
||||||
|
|
||||||
|
public static final String OS_LINUX = org.eclipse.core.runtime.Platform.OS_LINUX;
|
||||||
|
|
||||||
|
private static boolean ppcArchIsCached = false;
|
||||||
|
private static String cachedPpcArch = null;
|
||||||
|
|
||||||
|
public static Bundle getBundle(String symbolicName) {
|
||||||
|
return org.eclipse.core.runtime.Platform.getBundle(symbolicName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOS() {
|
||||||
|
return org.eclipse.core.runtime.Platform.getOS();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOSArch() {
|
||||||
|
String arch = org.eclipse.core.runtime.Platform.getOSArch();
|
||||||
|
if (arch.equals(org.eclipse.core.runtime.Platform.ARCH_PPC)) {
|
||||||
|
// Determine if the platform is actually a ppc64 machine
|
||||||
|
if (!ppcArchIsCached) {
|
||||||
|
Process unameProcess;
|
||||||
|
String cmd[] = {"uname", "-p"};
|
||||||
|
|
||||||
|
ppcArchIsCached = true;
|
||||||
|
try {
|
||||||
|
unameProcess = Runtime.getRuntime().exec(cmd);
|
||||||
|
|
||||||
|
InputStreamReader inputStreamReader = new InputStreamReader(unameProcess.getInputStream());
|
||||||
|
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
||||||
|
cachedPpcArch = bufferedReader.readLine();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
cachedPpcArch = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cachedPpcArch != null) {
|
||||||
|
return cachedPpcArch;
|
||||||
|
} else {
|
||||||
|
return arch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arch;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,12 +20,14 @@ import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
import org.eclipse.cdt.debug.core.ICDIDebugger;
|
import org.eclipse.cdt.debug.core.ICDIDebugger;
|
||||||
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||||
import org.eclipse.cdt.debug.core.ICDebugger;
|
import org.eclipse.cdt.debug.core.ICDebugger;
|
||||||
|
import org.eclipse.cdt.utils.Platform;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class DebugConfiguration implements ICDebugConfiguration {
|
public class DebugConfiguration implements ICDebugConfiguration {
|
||||||
/**
|
/**
|
||||||
* The configuration element of the extension.
|
* The configuration element of the extension.
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.eclipse.cdt.debug.mi.internal.ui;
|
package org.eclipse.cdt.debug.mi.internal.ui;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
|
@ -24,6 +25,7 @@ import org.eclipse.cdt.debug.mi.ui.IMILaunchConfigurationComponent;
|
||||||
import org.eclipse.cdt.debug.mi.ui.MIUIUtils;
|
import org.eclipse.cdt.debug.mi.ui.MIUIUtils;
|
||||||
import org.eclipse.cdt.debug.ui.AbstractCDebuggerPage;
|
import org.eclipse.cdt.debug.ui.AbstractCDebuggerPage;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
|
import org.eclipse.cdt.utils.Platform;
|
||||||
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;
|
||||||
|
@ -71,6 +73,10 @@ public class StandardGDBDebuggerPage extends AbstractCDebuggerPage implements Ob
|
||||||
|
|
||||||
private boolean fIsInitializing = false;
|
private boolean fIsInitializing = false;
|
||||||
|
|
||||||
|
private static boolean gdb64ExistsIsCached = false;
|
||||||
|
|
||||||
|
private static boolean cachedGdb64Exists;
|
||||||
|
|
||||||
public void createControl( Composite parent ) {
|
public void createControl( Composite parent ) {
|
||||||
Composite comp = new Composite( parent, SWT.NONE );
|
Composite comp = new Composite( parent, SWT.NONE );
|
||||||
comp.setLayout( new GridLayout() );
|
comp.setLayout( new GridLayout() );
|
||||||
|
@ -83,7 +89,7 @@ public class StandardGDBDebuggerPage extends AbstractCDebuggerPage implements Ob
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) {
|
public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) {
|
||||||
configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT );
|
configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand());
|
||||||
configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT );
|
configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT );
|
||||||
configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, MIPlugin.getDefault().getCommandFactoryManager().getDefaultDescriptor( getDebuggerIdentifier() ).getIdentifier() );
|
configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, MIPlugin.getDefault().getCommandFactoryManager().getDefaultDescriptor( getDebuggerIdentifier() ).getIdentifier() );
|
||||||
configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT );
|
configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT );
|
||||||
|
@ -91,6 +97,52 @@ public class StandardGDBDebuggerPage extends AbstractCDebuggerPage implements Ob
|
||||||
fSolibBlock.setDefaults( configuration );
|
fSolibBlock.setDefaults( configuration );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String defaultGdbCommand() {
|
||||||
|
String gdbCommand = null;
|
||||||
|
|
||||||
|
if (Platform.getOS().equals(Platform.OS_LINUX) &&
|
||||||
|
Platform.getOSArch().equals("ppc64")) {
|
||||||
|
// On SLES 9 and 10 for ppc64 arch, there is a separate
|
||||||
|
// 64-bit capable gdb called gdb64. It can
|
||||||
|
// also debug 32-bit executables, so let's see if it exists.
|
||||||
|
if (!gdb64ExistsIsCached) {
|
||||||
|
Process unameProcess;
|
||||||
|
int interruptedRetryCount = 5;
|
||||||
|
|
||||||
|
String cmd[] = {"gdb64", "--version"};
|
||||||
|
|
||||||
|
gdb64ExistsIsCached = true;
|
||||||
|
|
||||||
|
while (interruptedRetryCount >= 0) {
|
||||||
|
try {
|
||||||
|
unameProcess = Runtime.getRuntime().exec(cmd);
|
||||||
|
int exitStatus = unameProcess.waitFor();
|
||||||
|
|
||||||
|
cachedGdb64Exists = (exitStatus == 0);
|
||||||
|
break;
|
||||||
|
} catch (IOException e) {
|
||||||
|
cachedGdb64Exists = false;
|
||||||
|
break;
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Never should get here, really. The chances of the command being interrupted
|
||||||
|
// are very small
|
||||||
|
cachedGdb64Exists = false;
|
||||||
|
interruptedRetryCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cachedGdb64Exists) {
|
||||||
|
gdbCommand = "gdb64"; //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
gdbCommand = IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gdbCommand = IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT;
|
||||||
|
}
|
||||||
|
return gdbCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isValid( ILaunchConfiguration launchConfig ) {
|
public boolean isValid( ILaunchConfiguration launchConfig ) {
|
||||||
boolean valid = fGDBCommandText.getText().length() != 0;
|
boolean valid = fGDBCommandText.getText().length() != 0;
|
||||||
if ( valid ) {
|
if ( valid ) {
|
||||||
|
@ -106,10 +158,10 @@ public class StandardGDBDebuggerPage extends AbstractCDebuggerPage implements Ob
|
||||||
|
|
||||||
public void initializeFrom( ILaunchConfiguration configuration ) {
|
public void initializeFrom( ILaunchConfiguration configuration ) {
|
||||||
setInitializing( true );
|
setInitializing( true );
|
||||||
String gdbCommand = IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT;
|
String gdbCommand = defaultGdbCommand();
|
||||||
String gdbInit = IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT;
|
String gdbInit = IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT;
|
||||||
try {
|
try {
|
||||||
gdbCommand = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT );
|
gdbCommand = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand());
|
||||||
}
|
}
|
||||||
catch( CoreException e ) {
|
catch( CoreException e ) {
|
||||||
}
|
}
|
||||||
|
@ -120,7 +172,6 @@ public class StandardGDBDebuggerPage extends AbstractCDebuggerPage implements Ob
|
||||||
}
|
}
|
||||||
if ( fSolibBlock != null )
|
if ( fSolibBlock != null )
|
||||||
fSolibBlock.initializeFrom( configuration );
|
fSolibBlock.initializeFrom( configuration );
|
||||||
fGDBCommandText.setText( gdbCommand );
|
|
||||||
fGDBInitText.setText( gdbInit );
|
fGDBInitText.setText( gdbInit );
|
||||||
|
|
||||||
String debuggerID = getDebuggerIdentifier();
|
String debuggerID = getDebuggerIdentifier();
|
||||||
|
|
Loading…
Add table
Reference in a new issue