[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-debug-dev] Embedded CDT cocktail
|
http://www.zylin.com/embeddedcdt.zip
Ref. my earlier posts, I've hacked up a CDT that lets me debug my
embedded target:
- GDB decides whether or not it supports the executable.
- The debug session is launched in "idle" mode. This lets the user enter
the GDB commands of his choice to start the debug session, e.g. "run",
"target remote xxx", "attach", etc.
I've tested it briefly against my arm-elf BDI 2000 JTAG debugger. Seems
to work fine. Use at your own risk! :-)
Instructions:
1. Download Eclipse SDK M9
2. Unzip embeddedcdt.zip into the Eclipse directory
Some plans:
- Let user launch CDT/GDB without executable; lets the user use the GDB
"load" command.
- Remove combo button for multiple GDB debugger types
- Write a short webpage with some tips&tricks
- Retire project once the dust settles on these GDB&CDT issues, since I
believe the eventually CDT&GDB will handle all of this out of the box.
All I did was to delete code from CDT. Patch attached.
--
Øyvind Harboe
http://www.zylin.com
Index: src/org/eclipse/cdt/debug/core/ICDebugConfiguration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConfiguration.java,v
retrieving revision 1.5
diff -u -r1.5 ICDebugConfiguration.java
--- src/org/eclipse/cdt/debug/core/ICDebugConfiguration.java 23 Mar 2004 02:48:29 -0000 1.5
+++ src/org/eclipse/cdt/debug/core/ICDebugConfiguration.java 24 May 2004 14:53:29 -0000
@@ -12,9 +12,4 @@
ICDebugger getDebugger() throws CoreException;
String getName();
String getID();
- String getPlatform();
- String[] getCPUList();
- String[] getModeList();
- boolean supportsCPU(String cpu);
- boolean supportsMode(String mode);
}
Index: src/org/eclipse/cdt/debug/internal/core/DebugConfiguration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugConfiguration.java,v
retrieving revision 1.10
diff -u -r1.10 DebugConfiguration.java
--- src/org/eclipse/cdt/debug/internal/core/DebugConfiguration.java 21 May 2004 19:59:49 -0000 1.10
+++ src/org/eclipse/cdt/debug/internal/core/DebugConfiguration.java 24 May 2004 14:53:29 -0000
@@ -18,8 +18,6 @@
* The configuration element of the extension.
*/
private IConfigurationElement fElement;
- private HashSet fModes;
- private HashSet fCPUs;
public DebugConfiguration(IConfigurationElement element) {
fElement = element;
@@ -42,75 +40,6 @@
return getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
}
- public String getPlatform() {
- String platform = getConfigurationElement().getAttribute("platform"); //$NON-NLS-1$
- if (platform == null) {
- return PLATFORM_NATIVE;
- }
- return platform;
- }
-
- public String[] getCPUList() {
- return (String[]) getCPUs().toArray(new String[0]);
- }
- public String[] getModeList() {
- return (String[]) getModes().toArray(new String[0]);
- }
-
- public boolean supportsMode(String mode) {
- return getModes().contains(mode);
- }
-
- public boolean supportsCPU(String cpu) {
- String nativeCPU = Platform.getOSArch();
- boolean ret = false;
- if ( nativeCPU.startsWith(cpu) ) {
- ret = getCPUs().contains(PLATFORM_NATIVE);
- }
- return ret || getCPUs().contains(cpu);
- }
- /**
- * Returns the set of modes specified in the configuration data.
- *
- * @return the set of modes specified in the configuration data
- */
- protected Set getModes() {
- if (fModes == null) {
- String modes = getConfigurationElement().getAttribute("modes"); //$NON-NLS-1$
- if (modes == null) {
- return new HashSet(0);
- }
- StringTokenizer tokenizer = new StringTokenizer(modes, ","); //$NON-NLS-1$
- fModes = new HashSet(tokenizer.countTokens());
- while (tokenizer.hasMoreTokens()) {
- fModes.add(tokenizer.nextToken().trim());
- }
- }
- return fModes;
- }
-
- protected Set getCPUs() {
- if (fCPUs == null) {
- String cpus = getConfigurationElement().getAttribute("cpu"); //$NON-NLS-1$
- if (cpus == null) {
- fCPUs = new HashSet(1);
- fCPUs.add(PLATFORM_NATIVE);
- }
- else {
- String nativeCPU = Platform.getOSArch();
- StringTokenizer tokenizer = new StringTokenizer(cpus, ","); //$NON-NLS-1$
- fCPUs = new HashSet(tokenizer.countTokens());
- while (tokenizer.hasMoreTokens()) {
- String cpu = tokenizer.nextToken().trim();
- fCPUs.add(cpu);
- if (nativeCPU.startsWith(cpu)) { // os arch be cpu{le/be}
- fCPUs.add(PLATFORM_NATIVE);
- }
- }
- }
- }
- return fCPUs;
- }
}
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/plugin.properties,v
retrieving revision 1.6
diff -u -r1.6 plugin.properties
--- plugin.properties 6 Apr 2003 01:07:23 -0000 1.6
+++ plugin.properties 24 May 2004 14:53:39 -0000
@@ -4,3 +4,4 @@
GDBDebugger.name=GDB Debugger
CygwinGDBDebugger.name=Cygwin GDB Debugger
GDBServer.name=GDB Server
+NonNativeGDB.name=Non-native GDB
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/plugin.xml,v
retrieving revision 1.22
diff -u -r1.22 plugin.xml
--- plugin.xml 18 May 2004 17:34:37 -0000 1.22
+++ plugin.xml 24 May 2004 14:53:39 -0000
@@ -24,28 +24,11 @@
<extension
point="org.eclipse.cdt.debug.core.CDebugger">
<debugger
- platform="native"
- name="%GDBDebugger.name"
+ platform="*"
+ name="%NonNativeGDB.name"
modes="run,core,attach"
- cpu="native"
class="org.eclipse.cdt.debug.mi.core.GDBDebugger"
id="org.eclipse.cdt.debug.mi.core.CDebugger">
- </debugger>
- <debugger
- platform="win32"
- name="%CygwinGDBDebugger.name"
- modes="run,core,attach"
- cpu="native"
- class="org.eclipse.cdt.debug.mi.core.CygwinGDBDebugger"
- id="org.eclipse.cdt.debug.mi.core.CygwinCDebugger">
- </debugger>
- <debugger
- platform="*"
- name="%GDBServer.name"
- modes="run"
- cpu="*"
- class="org.eclipse.cdt.debug.mi.core.GDBServerDebugger"
- id="org.eclipse.cdt.debug.mi.core.GDBServerCDebugger">
</debugger>
</extension>
Index: cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java,v
retrieving revision 1.2
diff -u -r1.2 Target.java
--- cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java 16 Mar 2004 20:03:56 -0000 1.2
+++ cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java 24 May 2004 14:53:40 -0000
@@ -347,9 +347,9 @@
throw new MI2CDIException(e);
}
} else if (mi.getMIInferior().isTerminated()) {
- restart();
+ // Leave starting to user
} else {
- restart();
+ // Leave starting to user
}
}
Index: src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java,v
retrieving revision 1.34
diff -u -r1.34 CDebugUIPlugin.java
--- src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java 21 May 2004 19:59:45 -0000 1.34
+++ src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java 24 May 2004 14:53:48 -0000
@@ -231,7 +231,7 @@
protected void initializeDebuggerPageMap() {
fDebuggerPageMap = new HashMap(10);
- IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint("CDebuggerPage"); //$NON-NLS-1$
+ IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.cdt.debug.ui.CDebuggerPage"); //$NON-NLS-1$
IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
for (int i = 0; i < infos.length; i++) {
String id = infos[i].getAttribute("debuggerID"); //$NON-NLS-1$
Index: src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java,v
retrieving revision 1.22
diff -u -r1.22 CApplicationLaunchShortcut.java
--- src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java 18 May 2004 16:43:58 -0000 1.22
+++ src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java 24 May 2004 14:53:58 -0000
@@ -115,10 +115,7 @@
List debugList = new ArrayList(debugConfigs.length);
String os = Platform.getOS();
for (int i = 0; i < debugConfigs.length; i++) {
- String platform = debugConfigs[i].getPlatform();
- if (platform == null || platform.equals(ICDebugConfiguration.PLATFORM_NATIVE) || platform.equals(os)) {
debugList.add(debugConfigs[i]);
- }
}
debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
if (debugConfigs.length == 1) {
Index: src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java,v
retrieving revision 1.30
diff -u -r1.30 CDebuggerTab.java
--- src/org/eclipse/cdt/launch/ui/CDebuggerTab.java 18 May 2004 16:43:58 -0000 1.30
+++ src/org/eclipse/cdt/launch/ui/CDebuggerTab.java 24 May 2004 14:53:58 -0000
@@ -35,8 +35,6 @@
protected Combo fDCombo;
protected Button fStopInMain;
- protected Button fAttachButton;
- protected Button fRunButton;
protected Button fVarBookKeeping;
private final boolean DEFAULT_STOP_AT_MAIN = true;
@@ -70,25 +68,6 @@
radioLayout.marginHeight = 0;
radioLayout.marginWidth = 0;
radioComp.setLayout(radioLayout);
- fRunButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Run_program_in_debugger")); //$NON-NLS-1$
- fRunButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- if (fRunButton.getSelection() == true) {
- fStopInMain.setEnabled(true);
- } else {
- fStopInMain.setEnabled(false);
- }
- updateLaunchConfigurationDialog();
- }
- });
- fAttachButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Attach_to_running_process")); //$NON-NLS-1$
- fAttachButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- updateLaunchConfigurationDialog();
- }
- });
Composite optionComp = new Composite(comp, SWT.NONE);
layout = new GridLayout(2, false);
@@ -150,24 +129,11 @@
int x = 0;
int selndx = -1;
for (int i = 0; i < debugConfigs.length; i++) {
- if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)
- || debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
- String debuggerPlatform = debugConfigs[i].getPlatform();
- boolean isNative = configPlatform.equals(Platform.getOS());
- if (debuggerPlatform.equalsIgnoreCase(configPlatform)
- || (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) {
- if (debugConfigs[i].supportsCPU(programCPU)) {
fDCombo.add(debugConfigs[i].getName());
fDCombo.setData(Integer.toString(x), debugConfigs[i]);
// select first exact matching debugger for platform or requested selection
- if ((selndx == -1 && debuggerPlatform.equalsIgnoreCase(configPlatform))
- || selection.equals(debugConfigs[i].getID())) {
- selndx = x;
- }
+ selndx = x;
x++;
- }
- }
- }
}
// if no selection meaning nothing in config the force initdefault on tab
setInitializeDefault(selection.equals("") ? true : false); //$NON-NLS-1$
@@ -182,27 +148,6 @@
protected void updateComboFromSelection() {
handleDebuggerChanged();
ICDebugConfiguration debugConfig = getConfigForCurrentDebugger();
- if (debugConfig != null) {
- fRunButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN));
- fRunButton.setSelection(false);
- fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH));
- fAttachButton.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);
- }
- if (fRunButton.getSelection() == true) {
- fStopInMain.setEnabled(true);
- } else {
- fStopInMain.setEnabled(false);
- }
- } catch (CoreException ex) {
- }
- }
updateLaunchConfigurationDialog();
}
@@ -232,13 +177,6 @@
loadDebuggerComboBox(config, id);
String mode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
- if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
- fRunButton.setSelection(true);
- fAttachButton.setSelection(false);
- } else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
- fAttachButton.setSelection(true);
- fRunButton.setSelection(false);
- }
if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, DEFAULT_STOP_AT_MAIN) == true) {
fStopInMain.setSelection(true);
}
@@ -256,14 +194,6 @@
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING,
!fVarBookKeeping.getSelection());
- if (fAttachButton.getSelection() == true) {
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
- } else {
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
- }
}
}
@@ -275,10 +205,6 @@
if (super.isValid(config) == false) {
return false;
}
- if (!fRunButton.getSelection() && !fAttachButton.getSelection()) {
- setErrorMessage(LaunchUIPlugin.getResourceString("CDebuggerTab.Select_Debug_mode")); //$NON-NLS-1$
- return false;
- }
return true;
}
@@ -297,15 +223,7 @@
if (debugConfig == null) {
return false;
}
- String debuggerPlatform = debugConfig.getPlatform();
- boolean isNative = platform.equals(projectPlatform);
- if (debuggerPlatform.equalsIgnoreCase(projectPlatform)
- || (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) {
- if (debugConfig.supportsCPU(projectCPU)) {
- return true;
- }
- }
- return false;
+ return true;
}
/**
@@ -313,8 +231,7 @@
* currently selected debugger.
*/
protected ICDebugConfiguration getConfigForCurrentDebugger() {
- int selectedIndex = fDCombo.getSelectionIndex();
- return (ICDebugConfiguration) fDCombo.getData(Integer.toString(selectedIndex));
+ return (ICDebugConfiguration) fDCombo.getData(Integer.toString(0));
}
/**
Index: src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java,v
retrieving revision 1.14
diff -u -r1.14 CorefileDebuggerTab.java
--- src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java 18 May 2004 16:43:58 -0000 1.14
+++ src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java 24 May 2004 14:53:58 -0000
@@ -85,22 +85,11 @@
int x = 0;
int selndx = -1;
for (int i = 0; i < debugConfigs.length; i++) {
- if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
- String debuggerPlatform = debugConfigs[i].getPlatform();
- boolean platformMatch = configPlatform.equals(projectPlatform);
- if (debuggerPlatform.equalsIgnoreCase(projectPlatform) || (platformMatch && projectPlatform.equals("*"))) { //$NON-NLS-1$
- if (debugConfigs[i].supportsCPU(projectCPU)) {
fDCombo.add(debugConfigs[i].getName());
fDCombo.setData(Integer.toString(x), debugConfigs[i]);
// select first exact matching debugger for platform or requested selection
- if ((selndx == -1 && debuggerPlatform.equalsIgnoreCase(projectPlatform))
- || selection.equals(debugConfigs[i].getID())) {
- selndx = x;
- }
+ selndx = x;
x++;
- }
- }
- }
}
// if no selection meaning nothing in config the force initdefault on tab
setInitializeDefault(selection.equals("") ? true : false); //$NON-NLS-1$
@@ -167,14 +156,7 @@
if (debugConfig == null) {
return false;
}
- String debuggerPlatform = debugConfig.getPlatform();
- boolean platformMatch = platform.equals(projectPlatform);
- if (debuggerPlatform.equalsIgnoreCase(projectPlatform) || (platformMatch && projectPlatform.equals("*"))) { //$NON-NLS-1$
- if (debugConfig.supportsCPU(projectCPU)) {
- return true;
- }
- }
- return false;
+ return true;
}
/**