1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 22:22:11 +02:00

Initial code for supporting hardware debugging with GDB, mainly with JTAG.

This commit is contained in:
Doug Schaefer 2007-04-16 19:02:30 +00:00
parent 12de1eb9a0
commit aa17ffe74c
25 changed files with 1015 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.debug.gdbjtag.core</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,15 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CDT GDB JTAG Core Plug-in
Bundle-SymbolicName: org.eclipse.cdt.debug.gdbjtag.core;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.cdt.debug.gdbjtag.core.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.debug.core,
org.eclipse.cdt.launch,
org.eclipse.cdt.debug.core,
org.eclipse.cdt.debug.mi.core,
org.eclipse.cdt.core
Eclipse-LazyStart: true
Export-Package: org.eclipse.cdt.debug.gdbjtag.core

View file

@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml

View file

@ -0,0 +1 @@
launchConfig.name=GDB Hardware Debugging

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
delegate="org.eclipse.cdt.debug.gdbjtag.core.GDBJtagLaunchConfigurationDelegate"
id="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType"
modes="debug"
name="%launchConfig.name"
public="true"
sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer"/>
</extension>
</plugin>

View file

@ -0,0 +1,50 @@
package org.eclipse.cdt.debug.gdbjtag.core;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.cdt.debug.gdbremote.core";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,37 @@
/**********************************************************************
* Copyright (c) 2007 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
/**
* @author Doug Schaefer
*
*/
public class GDBJtagCommandFactory extends CommandFactory {
/**
*
*/
public GDBJtagCommandFactory() {
// TODO Auto-generated constructor stub
}
/**
* @param miVersion
*/
public GDBJtagCommandFactory(String miVersion) {
super(miVersion);
// TODO Auto-generated constructor stub
}
}

View file

@ -0,0 +1,24 @@
/**********************************************************************
* Copyright (c) 2006 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core;
/**
* @author Doug Schaefer
*
*/
public class GDBJtagConstants {
public static final String DEBUGGER_ID = "org.eclipse.cdt.debug.mi.core.CDebuggerNew"; //$NON-NLS-1$
public static final String LAUNCH_ATTR_INIT_COMMANDS = Activator.PLUGIN_ID + ".initCommands"; //$NON-NLS-1$
public static final String LAUNCH_ATTR_RUN_COMMANDS = Activator.PLUGIN_ID + ".runCommands"; //$NON-NLS-1$
}

View file

@ -0,0 +1,50 @@
/**********************************************************************
* Copyright (c) 2007 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core;
import java.io.File;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.mi.core.AbstractGDBCDIDebugger;
import org.eclipse.cdt.debug.mi.core.MIPlugin;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
/**
* @author Doug Schaefer
*
*/
public class GDBJtagDebugger extends AbstractGDBCDIDebugger {
public ICDISession createSession(ILaunch launch, File executable,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
return null;
}
public ICDISession createDebuggerSession(ILaunch launch, IBinaryObject exe,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
return null;
}
protected CommandFactory getCommandFactory(ILaunchConfiguration config)
throws CoreException {
String miVersion = MIPlugin.getMIVersion(config);
return new GDBJtagCommandFactory(miVersion);
}
}

View file

@ -0,0 +1,114 @@
/**********************************************************************
* Copyright (c) 2006 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
/**
* @author Doug Schaefer
*
*/
public class GDBJtagLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
protected String getPluginID() {
return Activator.PLUGIN_ID;
};
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
try {
// set the default source locator if required
setDefaultSourceLocator(launch, configuration);
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
ICDebugConfiguration debugConfig = getDebugConfig(configuration);
ICDISession dsession = null;
String debugMode = configuration
.getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (debugMode
.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
// dsession = ((EmbeddedGDBCDIDebugger) debugConfig
// .createDebugger()).createDebuggerSession(this,
// launch, exeFileInfo, new SubProgressMonitor(
// monitor, 8));
//
// ICDITarget[] dtargets = dsession.getTargets();
// // setFactory(dtargets);
// try {
//
// monitor.worked(1);
//
// executeGDBScript(
// configuration,
// LaunchConfigurationConstants.ATTR_DEBUGGER_COMMANDS_INIT,
// dtargets);
// monitor.worked(2);
//
// queryTargetState(dtargets);
//
// // create the Launch targets/processes for eclipse.
// for (int i = 0; i < dtargets.length; i++) {
// Target target = (Target) dtargets[i];
// target.setConfiguration(new Configuration(target));
// Process process = target.getProcess();
// IProcess iprocess = null;
// if (process != null) {
// iprocess = DebugPlugin.newProcess(launch,
// process, renderProcessLabel(exePath
// .toOSString()));
// }
// CDIDebugModel.newDebugTarget(launch, projectInfo,
// dtargets[i],
// renderTargetLabel(debugConfig), iprocess,
// exeFileInfo, true, true, false);
// /* FIX!!!! put up a console view for */
// // if (process != null) {
// // iprocess = DebugPlugin.newProcess(launch,
// // process,
// // renderProcessLabel(exePath.toOSString()));
// // }
// }
// executeGDBScript(
// configuration,
// LaunchConfigurationConstants.ATTR_DEBUGGER_COMMANDS_RUN,
// dtargets);
//
// } catch (CoreException e) {
// try {
// dsession.terminate();
// } catch (CDIException e1) {
// // ignore
// }
// throw e;
// }
}
} else {
cancel("TargetConfiguration not supported",
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
} finally {
monitor.done();
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.debug.gdbjtag.ui</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,18 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CDT GDB Remote UI Plug-in
Bundle-SymbolicName: org.eclipse.cdt.debug.gdbjtag.ui;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.cdt.debug.gdbjtag.ui.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.debug.ui,
org.eclipse.debug.core,
org.eclipse.cdt.launch,
org.eclipse.cdt.ui,
org.eclipse.cdt.debug.mi.core,
org.eclipse.cdt.debug.gdbjtag.core,
org.eclipse.core.variables,
org.eclipse.cdt.managedbuilder.ui
Eclipse-LazyStart: true

View file

@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.debug.ui.launchConfigurationTypeImages">
<launchConfigurationTypeImage
configTypeID="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType"
icon="icons/obj16/c_app.gif"
id="org.eclipse.cdt.debug.gdbjtag.launchConfigurationTypeImage"/>
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
class="org.eclipse.cdt.debug.gdbjtag.ui.GDBJtagLaunchConfigurationTabGroup"
id="org.eclipse.cdt.debug.gdbjtag.launchConfigurationTabGroup"
type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType"/>
</extension>
</plugin>

View file

@ -0,0 +1,50 @@
package org.eclipse.cdt.debug.gdbjtag.ui;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.cdt.debug.gdbremote.ui";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,235 @@
/**********************************************************************
* Copyright (c) 2006 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.debug.gdbjtag.ui;
import org.eclipse.cdt.debug.gdbjtag.core.GDBJtagConstants;
import org.eclipse.cdt.debug.mi.core.MIPlugin;
import org.eclipse.cdt.debug.mi.core.command.factories.CommandFactoryDescriptor;
import org.eclipse.cdt.debug.mi.core.command.factories.CommandFactoryManager;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
* @author Doug Schaefer
*
*/
public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
private CommandFactoryDescriptor[] cfDescs;
private int cfSelected = -1;
private Button useRemote;
private Composite remoteConnection;
private Text ipAddress;
private Text portNumber;
public String getName() {
return "Debugger";
}
public Image getImage() {
return GDBJtagImages.getDebuggerTabImage();
}
public void createControl(Composite parent) {
ScrolledComposite sc = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
setControl(sc);
Composite comp = new Composite(sc, SWT.NONE);
sc.setContent(comp);
GridLayout layout = new GridLayout();
comp.setLayout(layout);
Group group = new Group(comp, SWT.NONE);
layout = new GridLayout();
group.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(gd);
group.setText("GDB Setup");
createCommandControl(group);
createInitFileControl(group);
createCommandSetControl(group);
createProtocolControl(group);
createVerboseModeControl(group);
createRemoteControl(comp);
}
public void createCommandControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
comp.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
comp.setLayoutData(gd);
Label label = new Label(comp, SWT.NONE);
label.setText("GDB Command:");
gd = new GridData();
gd.horizontalSpan = 3;
label.setLayoutData(gd);
Text text = new Text(comp, SWT.SINGLE | SWT.BORDER);
text.setText("gdb");
gd = new GridData(GridData.FILL_HORIZONTAL);
text.setLayoutData(gd);
Button button = new Button(comp, SWT.NONE);
button.setText("Browse...");
button = new Button(comp, SWT.NONE);
button.setText("Variables...");
}
public void createInitFileControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
comp.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
comp.setLayoutData(gd);
Label label = new Label(comp, SWT.NONE);
label.setText("GDB Init File:");
gd = new GridData();
gd.horizontalSpan = 3;
label.setLayoutData(gd);
Text text = new Text(comp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
text.setLayoutData(gd);
Button button = new Button(comp, SWT.NONE);
button.setText("Browse...");
button = new Button(comp, SWT.NONE);
button.setText("Workspace...");
}
public void createCommandSetControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
comp.setLayout(layout);
Label label = new Label(comp, SWT.NONE);
label.setText("Command Set:");
Combo combo = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
// Get the command sets
CommandFactoryManager cfManager = MIPlugin.getDefault().getCommandFactoryManager();
CommandFactoryDescriptor defDesc = cfManager.getDefaultDescriptor(GDBJtagConstants.DEBUGGER_ID);
cfDescs = cfManager.getDescriptors(
GDBJtagConstants.DEBUGGER_ID);
for (int i = 0; i < cfDescs.length; ++i) {
combo.add(cfDescs[i].getName());
if (defDesc == cfDescs[i])
cfSelected = i;
}
if (cfSelected > -1)
combo.select(cfSelected);
}
public void createProtocolControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
comp.setLayout(layout);
Label label = new Label(comp, SWT.NONE);
label.setText("Protocol Version:");
Combo combo = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
if (cfSelected > -1) {
String[] vers = cfDescs[cfSelected].getMIVersions();
for (int i = 0; i < vers.length; ++i) {
combo.add(vers[i]);
}
}
combo.select(0);
}
public void createVerboseModeControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
comp.setLayout(layout);
Button button = new Button(comp, SWT.CHECK);
Label label = new Label(comp, SWT.NONE);
label.setText("Verbose console mode");
}
private void createRemoteControl(Composite parent) {
Group group = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
group.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(gd);
group.setText("Remote Connection");
useRemote = new Button(group, SWT.CHECK);
useRemote.setText("Use remote connection");
useRemote.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
useRemoteChanged();
}
});
remoteConnection = new Composite(group, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
remoteConnection.setLayout(layout);
Label label = new Label(remoteConnection, SWT.NONE);
label.setText("Host name or IP address:");
ipAddress = new Text(remoteConnection, SWT.BORDER);
label = new Label(remoteConnection, SWT.NONE);
label.setText("Port number:");
portNumber = new Text(remoteConnection, SWT.BORDER);
}
private void useRemoteChanged() {
boolean enabled = useRemote.getSelection();
ipAddress.setEnabled(enabled);
portNumber.setEnabled(enabled);
}
public void initializeFrom(ILaunchConfiguration configuration) {
useRemote.setSelection(true);
useRemoteChanged();
}
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
// TODO Auto-generated method stub
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
// TODO Auto-generated method stub
}
}

View file

@ -0,0 +1,67 @@
/**********************************************************************
* Copyright (c) 2006 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.debug.gdbjtag.ui;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
/**
* @author Doug Schaefer
*
*/
public class GDBJtagImages {
private static ImageRegistry imageRegistry = new ImageRegistry();
private static URL iconBaseURL = Activator.getDefault().getBundle().getEntry("/icons/"); //$NON-NLS-1$
private static final String NAME_PREFIX = Activator.PLUGIN_ID + '.';
private static final String T_TABS = "view16/"; //$NON-NLS-1$
private static final String IMG_VIEW_DEBUGGER_TAB = NAME_PREFIX + "debugger_tab.gif"; //$NON-NLS-1$
private static final String IMG_VIEW_STARTUP_TAB = NAME_PREFIX + "startup_tab.gif"; //$NON-NLS-1$
public static Image getDebuggerTabImage() {
return imageRegistry.get(IMG_VIEW_DEBUGGER_TAB);
}
public static Image getStartupTabImage() {
return imageRegistry.get(IMG_VIEW_STARTUP_TAB);
}
static {
createManaged(T_TABS, IMG_VIEW_DEBUGGER_TAB);
createManaged(T_TABS, IMG_VIEW_STARTUP_TAB);
}
private static void createManaged(String prefix, String name) {
imageRegistry.put(name, ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX.length()))));
}
private static URL makeIconFileURL(String prefix, String name) {
StringBuffer buffer= new StringBuffer(prefix);
buffer.append(name);
try {
return new URL(iconBaseURL, buffer.toString());
} catch (MalformedURLException e) {
LaunchUIPlugin.log(e);
return null;
}
}
}

View file

@ -0,0 +1,39 @@
/**********************************************************************
* Copyright (c) 2006 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.debug.gdbjtag.ui;
import org.eclipse.cdt.launch.ui.CMainTab;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
/**
* @author Doug Schaefer
*
*/
public class GDBJtagLaunchConfigurationTabGroup extends
AbstractLaunchConfigurationTabGroup {
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
new CMainTab(CMainTab.DONT_CHECK_PROGRAM),
new GDBJtagDebuggerTab(),
new GDBJtagStartupTab(),
new SourceLookupTab(),
new CommonTab()
};
setTabs(tabs);
}
}

View file

@ -0,0 +1,200 @@
/**********************************************************************
* Copyright (c) 2006 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.debug.gdbjtag.ui;
import org.eclipse.cdt.debug.gdbjtag.core.GDBJtagConstants;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.StringVariableSelectionDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
* @author Doug Schaefer
*
*/
public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab {
Text initCommands;
Button loadImage;
Text imageFileName;
Button defaultRun;
Text runCommands;
public String getName() {
return "Startup";
}
public Image getImage() {
return GDBJtagImages.getStartupTabImage();
}
public void createControl(Composite parent) {
ScrolledComposite sc = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
setControl(sc);
Composite comp = new Composite(sc, SWT.NONE);
sc.setContent(comp);
GridLayout layout = new GridLayout();
comp.setLayout(layout);
createInitGroup(comp);
createLoadGroup(comp);
createRunGroup(comp);
sc.setMinSize(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
public void createInitGroup(Composite parent) {
Group group = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
group.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(gd);
group.setText("Initialization Commands");
initCommands = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
initCommands.setLayoutData(gd);
initCommands.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
updateLaunchConfigurationDialog();
}
});
Button varsButton = new Button(group, SWT.NONE);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
varsButton.setLayoutData(gd);
varsButton.setText("Variables...");
varsButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleVarsButtonSelected(initCommands);
}
});
}
private void createLoadGroup(Composite parent) {
Group group = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
group.setLayout(layout);
layout.numColumns = 3;
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
group.setLayoutData(gd);
group.setText("Load Image");
loadImage = new Button(group, SWT.CHECK);
loadImage.setText("Automatically load image");
gd = new GridData();
gd.horizontalSpan = 3;
loadImage.setLayoutData(gd);
loadImage.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
loadImageChanged();
}
});
Label label = new Label(group, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 3;
label.setLayoutData(gd);
label.setText("Image file name:");
imageFileName = new Text(group, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
imageFileName.setLayoutData(gd);
Button button = new Button(group, SWT.NONE);
button.setText("Browse...");
button = new Button(group, SWT.NONE);
button.setText("Workspace...");
}
private void loadImageChanged() {
imageFileName.setEnabled(loadImage.getSelection());
}
public void createRunGroup(Composite parent) {
Group group = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
group.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(gd);
group.setText("Run Commands");
defaultRun = new Button(group, SWT.CHECK);
defaultRun.setText("Use default run command");
runCommands = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
runCommands.setLayoutData(gd);
runCommands.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
updateLaunchConfigurationDialog();
}
});
Button varsButton = new Button(group, SWT.NONE);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
varsButton.setLayoutData(gd);
varsButton.setText("Variables...");
varsButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleVarsButtonSelected(runCommands);
}
});
}
private void handleVarsButtonSelected(Text text) {
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
dialog.open();
text.append(dialog.getVariableExpression());
}
public void initializeFrom(ILaunchConfiguration configuration) {
try {
initCommands.setText(configuration.getAttribute(GDBJtagConstants.LAUNCH_ATTR_INIT_COMMANDS, "")); //$NON-NLS-1$
runCommands.setText(configuration.getAttribute(GDBJtagConstants.LAUNCH_ATTR_RUN_COMMANDS, "")); //$NON-NLS-1$)
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
}
}
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(GDBJtagConstants.LAUNCH_ATTR_INIT_COMMANDS, initCommands.getText());
configuration.setAttribute(GDBJtagConstants.LAUNCH_ATTR_RUN_COMMANDS, runCommands.getText());
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(GDBJtagConstants.LAUNCH_ATTR_INIT_COMMANDS, ""); //$NON-NLS-1$
configuration.setAttribute(GDBJtagConstants.LAUNCH_ATTR_RUN_COMMANDS, ""); //$NON-NLS-1$
}
}