mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
use new cdescriptor operation for changes
This commit is contained in:
parent
0114d4cd78
commit
a85f27eed2
7 changed files with 140 additions and 87 deletions
|
@ -14,6 +14,7 @@ import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptorOperation;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -25,6 +26,7 @@ import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
@ -88,12 +90,14 @@ public class BinaryTests extends TestCase {
|
||||||
|
|
||||||
// since our test require that we can read the debug info from the exe whne must set the GNU elf
|
// since our test require that we can read the debug info from the exe whne must set the GNU elf
|
||||||
// binary parser since the default (generic elf binary parser) does not do this.
|
// binary parser since the default (generic elf binary parser) does not do this.
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(testProject.getProject());
|
ICDescriptorOperation op = new ICDescriptorOperation() {
|
||||||
desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
|
||||||
desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, "org.eclipse.cdt.core.GNU_ELF");
|
public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
|
||||||
|
descriptor.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
||||||
// Reset the binary parser the paths may have change.
|
descriptor.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, "org.eclipse.cdt.core.GNU_ELF");
|
||||||
CCorePlugin.getDefault().getCoreModel().resetBinaryParser(testProject.getProject());
|
}
|
||||||
|
};
|
||||||
|
CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(testProject.getProject(), op, null);
|
||||||
|
|
||||||
if (testProject==null)
|
if (testProject==null)
|
||||||
fail("Unable to create project");
|
fail("Unable to create project");
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class CPathEntryTest extends TestCase {
|
||||||
// We always have at least two entries:
|
// We always have at least two entries:
|
||||||
// 1) the default sourceEntry becomes the project
|
// 1) the default sourceEntry becomes the project
|
||||||
// 2) the default outputEntry becomes the project
|
// 2) the default outputEntry becomes the project
|
||||||
assertTrue("Expecting 3 pathentries", entries.length == (3 + 2));
|
assertTrue("Expecting 5 pathentries", entries.length == (3 + 2));
|
||||||
testProject.setRawPathEntries(null, null);
|
testProject.setRawPathEntries(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
2004-03-19 David Inglis
|
||||||
|
Update changing binary parser to use cdescriptor operation and remove call to deprecated call
|
||||||
|
Added check before changes to prevent uneccessary changes of the .cdtproject file.
|
||||||
|
* src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java
|
||||||
|
* src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java
|
||||||
|
* src/org/eclipse/cdt/ui/dialogs/GNUElfBinaryParserPage.java
|
||||||
|
|
||||||
2004-03-19 Hoda Amer
|
2004-03-19 Hoda Amer
|
||||||
Fix for bug#54325 Refactor: Check for name collision
|
Fix for bug#54325 Refactor: Check for name collision
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.ui.dialogs;
|
package org.eclipse.cdt.ui.dialogs;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -15,6 +15,7 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptorOperation;
|
||||||
import org.eclipse.cdt.core.ICExtensionReference;
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
|
@ -40,14 +41,14 @@ import org.eclipse.ui.help.WorkbenchHelp;
|
||||||
|
|
||||||
public class BinaryParserBlock extends AbstractBinaryParserPage {
|
public class BinaryParserBlock extends AbstractBinaryParserPage {
|
||||||
|
|
||||||
private static final String PREFIX = "BinaryParserBlock"; // $NON-NLS-1$ //$NON-NLS-1$
|
private static final String PREFIX = "BinaryParserBlock"; //$NON-NLS-1$
|
||||||
private static final String LABEL = PREFIX + ".label"; // $NON-NLS-1$ //$NON-NLS-1$
|
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
|
||||||
private static final String DESC = PREFIX + ".desc"; // $NON-NLS-1$ //$NON-NLS-1$
|
private static final String DESC = PREFIX + ".desc"; //$NON-NLS-1$
|
||||||
|
|
||||||
protected Combo comboBox;
|
protected Combo comboBox;
|
||||||
private HashMap idMap = new HashMap();
|
HashMap idMap = new HashMap();
|
||||||
private String initial;
|
String initial;
|
||||||
private Preferences fPrefs;
|
Preferences fPrefs;
|
||||||
|
|
||||||
public BinaryParserBlock(Preferences prefs) {
|
public BinaryParserBlock(Preferences prefs) {
|
||||||
super(CUIPlugin.getResourceString(LABEL));
|
super(CUIPlugin.getResourceString(LABEL));
|
||||||
|
@ -72,6 +73,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
|
||||||
gd.grabExcessHorizontalSpace = true;
|
gd.grabExcessHorizontalSpace = true;
|
||||||
comboBox.setLayoutData(gd);
|
comboBox.setLayoutData(gd);
|
||||||
comboBox.addSelectionListener(new SelectionAdapter() {
|
comboBox.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
getContainer().updateContainer();
|
getContainer().updateContainer();
|
||||||
handleBinaryParserChanged();
|
handleBinaryParserChanged();
|
||||||
|
@ -109,29 +111,43 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
monitor.beginTask(CUIMessages.getString("BinaryParserBlock.settingBinaryParser"), 2); //$NON-NLS-1$
|
monitor.beginTask(CUIMessages.getString("BinaryParserBlock.settingBinaryParser"), 2); //$NON-NLS-1$
|
||||||
String selected = comboBox.getText();
|
final String selected = comboBox.getText();
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
if (initial == null || !selected.equals(initial)) {
|
if (getContainer().getProject() != null) {
|
||||||
if (getContainer().getProject() != null) {
|
ICDescriptorOperation op = new ICDescriptorOperation() {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(getContainer().getProject());
|
|
||||||
desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
|
||||||
desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, (String) idMap.get(selected));
|
if (initial == null || !selected.equals(initial)) {
|
||||||
} else {
|
descriptor.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
||||||
|
descriptor.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, (String) idMap.get(selected));
|
||||||
|
}
|
||||||
|
monitor.worked(1);
|
||||||
|
// Give a chance to the contributions to save.
|
||||||
|
// We have to do it last to make sure the parser id
|
||||||
|
// is save
|
||||||
|
// in .cdtproject
|
||||||
|
ICOptionPage page = getCurrentBinaryParserPage();
|
||||||
|
if (page != null) {
|
||||||
|
page.performApply(new SubProgressMonitor(monitor, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(getContainer().getProject(), op, monitor);
|
||||||
|
} else {
|
||||||
|
if (initial == null || !selected.equals(initial)) {
|
||||||
fPrefs.setValue(CCorePlugin.PREF_BINARY_PARSER, (String) idMap.get(selected));
|
fPrefs.setValue(CCorePlugin.PREF_BINARY_PARSER, (String) idMap.get(selected));
|
||||||
}
|
}
|
||||||
initial = selected;
|
monitor.worked(1);
|
||||||
|
// Give a chance to the contributions to save.
|
||||||
|
// We have to do it last to make sure the parser id is save
|
||||||
|
// in .cdtproject
|
||||||
|
ICOptionPage page = getCurrentBinaryParserPage();
|
||||||
|
if (page != null) {
|
||||||
|
page.performApply(new SubProgressMonitor(monitor, 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
initial = selected;
|
||||||
}
|
}
|
||||||
monitor.worked(1);
|
|
||||||
// Give a chance to the contributions to save.
|
|
||||||
// We have to do it last to make sure the parser id is save
|
|
||||||
// in .cdtproject
|
|
||||||
super.performApply(new SubProgressMonitor(monitor, 1));
|
|
||||||
|
|
||||||
// Reset the binary parser the paths may have change.
|
|
||||||
if (getContainer().getProject() != null)
|
|
||||||
CCorePlugin.getDefault().getCoreModel().resetBinaryParser(getContainer().getProject());
|
|
||||||
|
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,4 +217,4 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
|
||||||
return (String) idMap.get(selected);
|
return (String) idMap.get(selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.dialogs;
|
package org.eclipse.cdt.ui.dialogs;
|
||||||
|
|
||||||
|
@ -52,7 +52,9 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
|
||||||
protected Text fCPPFiltCommandText;
|
protected Text fCPPFiltCommandText;
|
||||||
protected Text fCygPathCommandText;
|
protected Text fCygPathCommandText;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
|
@ -67,11 +69,10 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
|
||||||
monitor.beginTask(CUIMessages.getString("BinaryParserPage.task.savingAttributes"), 1); //$NON-NLS-1$
|
monitor.beginTask(CUIMessages.getString("BinaryParserPage.task.savingAttributes"), 1); //$NON-NLS-1$
|
||||||
IProject proj = getContainer().getProject();
|
IProject proj = getContainer().getProject();
|
||||||
if (proj != null) {
|
if (proj != null) {
|
||||||
|
String parserID = ""; //$NON-NLS-1$
|
||||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj);
|
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj);
|
||||||
ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
||||||
if (cext.length == 0) {
|
if (cext.length > 0) {
|
||||||
// The value was not save yet and we need to save it now
|
|
||||||
// to apply the changes. Search the extension for our own ID
|
|
||||||
IPluginDescriptor descriptor = CUIPlugin.getDefault().getDescriptor();
|
IPluginDescriptor descriptor = CUIPlugin.getDefault().getDescriptor();
|
||||||
IExtensionPoint point = descriptor.getExtensionPoint("BinaryParserPage"); //$NON-NLS-1$
|
IExtensionPoint point = descriptor.getExtensionPoint("BinaryParserPage"); //$NON-NLS-1$
|
||||||
IConfigurationElement[] infos = point.getConfigurationElements();
|
IConfigurationElement[] infos = point.getConfigurationElements();
|
||||||
|
@ -80,27 +81,27 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
|
||||||
String clazz = infos[i].getAttribute("class"); //$NON-NLS-1$
|
String clazz = infos[i].getAttribute("class"); //$NON-NLS-1$
|
||||||
String ego = getClass().getName();
|
String ego = getClass().getName();
|
||||||
if (clazz != null && clazz.equals(ego)) {
|
if (clazz != null && clazz.equals(ego)) {
|
||||||
cdesc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
parserID = id;
|
||||||
cdesc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, id);
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < cext.length; i++) {
|
||||||
|
if (cext[i].getID().equals(parserID)) {
|
||||||
|
String orig = cext[0].getExtensionData("addr2line"); //$NON-NLS-1$
|
||||||
|
if (orig == null || !orig.equals(addr2line)) {
|
||||||
|
cext[0].setExtensionData("addr2line", addr2line); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
orig = cext[0].getExtensionData("c++filt"); //$NON-NLS-1$
|
||||||
|
if (orig == null || !orig.equals(cppfilt)) {
|
||||||
|
cext[0].setExtensionData("c++filt", cppfilt); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
orig = cext[0].getExtensionData("cygpath"); //$NON-NLS-1$
|
||||||
|
if (orig == null || !orig.equals(cygpath)) {
|
||||||
|
cext[0].setExtensionData("cygpath", cygpath); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Try again.
|
|
||||||
cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
|
||||||
}
|
}
|
||||||
if (cext.length > 0) {
|
|
||||||
String orig = cext[0].getExtensionData("addr2line"); //$NON-NLS-1$
|
|
||||||
if (orig == null || !orig.equals(addr2line)) {
|
|
||||||
cext[0].setExtensionData("addr2line", addr2line); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
orig = cext[0].getExtensionData("c++filt"); //$NON-NLS-1$
|
|
||||||
if (orig == null || !orig.equals(cppfilt)) {
|
|
||||||
cext[0].setExtensionData("c++filt", cppfilt); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
orig = cext[0].getExtensionData("cygpath"); //$NON-NLS-1$
|
|
||||||
if (orig == null || !orig.equals(cygpath)) {
|
|
||||||
cext[0].setExtensionData("cygpath", cygpath); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Preferences store = getContainer().getPreferences();
|
Preferences store = getContainer().getPreferences();
|
||||||
if (store != null) {
|
if (store != null) {
|
||||||
|
@ -111,7 +112,9 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
||||||
*/
|
*/
|
||||||
public void performDefaults() {
|
public void performDefaults() {
|
||||||
|
@ -143,7 +146,9 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
|
||||||
fCygPathCommandText.setText((cygpath == null || cygpath.length() == 0) ? "cygpath" : cygpath); //$NON-NLS-1$;
|
fCygPathCommandText.setText((cygpath == null || cygpath.length() == 0) ? "cygpath" : cygpath); //$NON-NLS-1$;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||||
*/
|
*/
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
|
@ -157,6 +162,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
|
||||||
|
|
||||||
fAddr2LineCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
|
fAddr2LineCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
|
||||||
fAddr2LineCommandText.addModifyListener(new ModifyListener() {
|
fAddr2LineCommandText.addModifyListener(new ModifyListener() {
|
||||||
|
|
||||||
public void modifyText(ModifyEvent evt) {
|
public void modifyText(ModifyEvent evt) {
|
||||||
//updateLaunchConfigurationDialog();
|
//updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
|
@ -164,6 +170,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
|
||||||
|
|
||||||
Button button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$
|
Button button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$
|
||||||
button.addSelectionListener(new SelectionAdapter() {
|
button.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent evt) {
|
public void widgetSelected(SelectionEvent evt) {
|
||||||
handleAddr2LineButtonSelected();
|
handleAddr2LineButtonSelected();
|
||||||
//updateLaunchConfigurationDialog();
|
//updateLaunchConfigurationDialog();
|
||||||
|
@ -194,12 +201,14 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
|
||||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
fCPPFiltCommandText.setLayoutData(gd);
|
fCPPFiltCommandText.setLayoutData(gd);
|
||||||
fCPPFiltCommandText.addModifyListener(new ModifyListener() {
|
fCPPFiltCommandText.addModifyListener(new ModifyListener() {
|
||||||
|
|
||||||
public void modifyText(ModifyEvent evt) {
|
public void modifyText(ModifyEvent evt) {
|
||||||
//updateLaunchConfigurationDialog();
|
//updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$
|
button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$
|
||||||
button.addSelectionListener(new SelectionAdapter() {
|
button.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent evt) {
|
public void widgetSelected(SelectionEvent evt) {
|
||||||
handleCPPFiltButtonSelected();
|
handleCPPFiltButtonSelected();
|
||||||
//updateLaunchConfigurationDialog();
|
//updateLaunchConfigurationDialog();
|
||||||
|
@ -230,12 +239,14 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
|
||||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
fCygPathCommandText.setLayoutData(gd);
|
fCygPathCommandText.setLayoutData(gd);
|
||||||
fCygPathCommandText.addModifyListener(new ModifyListener() {
|
fCygPathCommandText.addModifyListener(new ModifyListener() {
|
||||||
|
|
||||||
public void modifyText(ModifyEvent evt) {
|
public void modifyText(ModifyEvent evt) {
|
||||||
//updateLaunchConfigurationDialog();
|
//updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$
|
button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$
|
||||||
button.addSelectionListener(new SelectionAdapter() {
|
button.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent evt) {
|
public void widgetSelected(SelectionEvent evt) {
|
||||||
handleCygPathButtonSelected();
|
handleCygPathButtonSelected();
|
||||||
//updateLaunchConfigurationDialog();
|
//updateLaunchConfigurationDialog();
|
||||||
|
@ -261,4 +272,4 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
|
||||||
performDefaults();
|
performDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.dialogs;
|
package org.eclipse.cdt.ui.dialogs;
|
||||||
|
|
||||||
|
@ -50,7 +50,9 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
|
||||||
protected Text fAddr2LineCommandText;
|
protected Text fAddr2LineCommandText;
|
||||||
protected Text fCPPFiltCommandText;
|
protected Text fCPPFiltCommandText;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
|
@ -64,11 +66,10 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
|
||||||
monitor.beginTask(CUIMessages.getString("BinaryParserPage.task.savingAttributes"), 1); //$NON-NLS-1$
|
monitor.beginTask(CUIMessages.getString("BinaryParserPage.task.savingAttributes"), 1); //$NON-NLS-1$
|
||||||
IProject proj = getContainer().getProject();
|
IProject proj = getContainer().getProject();
|
||||||
if (proj != null) {
|
if (proj != null) {
|
||||||
|
String parserID = ""; //$NON-NLS-1$
|
||||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj);
|
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj);
|
||||||
ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
||||||
if (cext.length == 0) {
|
if (cext.length > 0) {
|
||||||
// The value was not save yet and we need to save it now
|
|
||||||
// to apply the changes. Search the extension for our own ID
|
|
||||||
IPluginDescriptor descriptor = CUIPlugin.getDefault().getDescriptor();
|
IPluginDescriptor descriptor = CUIPlugin.getDefault().getDescriptor();
|
||||||
IExtensionPoint point = descriptor.getExtensionPoint("BinaryParserPage"); //$NON-NLS-1$
|
IExtensionPoint point = descriptor.getExtensionPoint("BinaryParserPage"); //$NON-NLS-1$
|
||||||
IConfigurationElement[] infos = point.getConfigurationElements();
|
IConfigurationElement[] infos = point.getConfigurationElements();
|
||||||
|
@ -77,23 +78,24 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
|
||||||
String clazz = infos[i].getAttribute("class"); //$NON-NLS-1$
|
String clazz = infos[i].getAttribute("class"); //$NON-NLS-1$
|
||||||
String ego = getClass().getName();
|
String ego = getClass().getName();
|
||||||
if (clazz != null && clazz.equals(ego)) {
|
if (clazz != null && clazz.equals(ego)) {
|
||||||
cdesc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
parserID = id;
|
||||||
cdesc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, id);
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < cext.length; i++) {
|
||||||
|
if (cext[i].getID().equals(parserID)) {
|
||||||
|
|
||||||
|
String orig = cext[0].getExtensionData("addr2line"); //$NON-NLS-1$
|
||||||
|
if (orig == null || !orig.equals(addr2line)) {
|
||||||
|
cext[0].setExtensionData("addr2line", addr2line); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
orig = cext[0].getExtensionData("c++filt"); //$NON-NLS-1$
|
||||||
|
if (orig == null || !orig.equals(cppfilt)) {
|
||||||
|
cext[0].setExtensionData("c++filt", cppfilt); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Try again.
|
|
||||||
cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
|
||||||
}
|
}
|
||||||
if (cext.length > 0) {
|
|
||||||
String orig = cext[0].getExtensionData("addr2line"); //$NON-NLS-1$
|
|
||||||
if (orig == null || !orig.equals(addr2line)) {
|
|
||||||
cext[0].setExtensionData("addr2line", addr2line); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
orig = cext[0].getExtensionData("c++filt"); //$NON-NLS-1$
|
|
||||||
if (orig == null || !orig.equals(cppfilt)) {
|
|
||||||
cext[0].setExtensionData("c++filt", cppfilt); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Preferences store = getContainer().getPreferences();
|
Preferences store = getContainer().getPreferences();
|
||||||
if (store != null) {
|
if (store != null) {
|
||||||
|
@ -103,7 +105,9 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
||||||
*/
|
*/
|
||||||
public void performDefaults() {
|
public void performDefaults() {
|
||||||
|
@ -131,7 +135,9 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
|
||||||
fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt); //$NON-NLS-1$
|
fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||||
*/
|
*/
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
|
@ -145,6 +151,7 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
|
||||||
|
|
||||||
fAddr2LineCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
|
fAddr2LineCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
|
||||||
fAddr2LineCommandText.addModifyListener(new ModifyListener() {
|
fAddr2LineCommandText.addModifyListener(new ModifyListener() {
|
||||||
|
|
||||||
public void modifyText(ModifyEvent evt) {
|
public void modifyText(ModifyEvent evt) {
|
||||||
//updateLaunchConfigurationDialog();
|
//updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
|
@ -152,6 +159,7 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
|
||||||
|
|
||||||
Button button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$
|
Button button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$
|
||||||
button.addSelectionListener(new SelectionAdapter() {
|
button.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent evt) {
|
public void widgetSelected(SelectionEvent evt) {
|
||||||
handleAddr2LineButtonSelected();
|
handleAddr2LineButtonSelected();
|
||||||
//updateLaunchConfigurationDialog();
|
//updateLaunchConfigurationDialog();
|
||||||
|
@ -182,12 +190,14 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
|
||||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
fCPPFiltCommandText.setLayoutData(gd);
|
fCPPFiltCommandText.setLayoutData(gd);
|
||||||
fCPPFiltCommandText.addModifyListener(new ModifyListener() {
|
fCPPFiltCommandText.addModifyListener(new ModifyListener() {
|
||||||
|
|
||||||
public void modifyText(ModifyEvent evt) {
|
public void modifyText(ModifyEvent evt) {
|
||||||
//updateLaunchConfigurationDialog();
|
//updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$
|
button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$
|
||||||
button.addSelectionListener(new SelectionAdapter() {
|
button.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent evt) {
|
public void widgetSelected(SelectionEvent evt) {
|
||||||
handleCPPFiltButtonSelected();
|
handleCPPFiltButtonSelected();
|
||||||
//updateLaunchConfigurationDialog();
|
//updateLaunchConfigurationDialog();
|
||||||
|
@ -213,4 +223,4 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
|
||||||
performDefaults();
|
performDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ import java.util.zip.ZipFile;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptorOperation;
|
||||||
import org.eclipse.cdt.core.model.IArchive;
|
import org.eclipse.cdt.core.model.IArchive;
|
||||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
@ -53,12 +54,16 @@ public class CProjectHelper {
|
||||||
|
|
||||||
ICProject cproject = CCorePlugin.getDefault().getCoreModel().create(project);
|
ICProject cproject = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||||
/* Try to guess at the correct binary parser.. elf or pe at this point.. */
|
/* Try to guess at the correct binary parser.. elf or pe at this point.. */
|
||||||
String os = System.getProperty("os.name");
|
ICDescriptorOperation op = new ICDescriptorOperation() {
|
||||||
boolean pe=(os.toLowerCase().indexOf("windows")!=-1);
|
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(project);
|
public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
|
||||||
desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
descriptor.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
||||||
desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, pe?"org.eclipse.cdt.core.PE":"org.eclipse.cdt.core.ELF");
|
String os = System.getProperty("os.name");
|
||||||
CCorePlugin.getDefault().getCoreModel().resetBinaryParser(project);
|
boolean pe=(os.toLowerCase().indexOf("windows")!=-1);
|
||||||
|
descriptor.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, pe?"org.eclipse.cdt.core.PE":"org.eclipse.cdt.core.ELF");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(project, op, null);
|
||||||
return cproject;
|
return cproject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue