Skip to content

Commit 940b534

Browse files
author
XL\zhangzegang
committed
Add connect to running target in OpenCD
Modify an effect bug of connect to running target in jlink
1 parent 4ed6716 commit 940b534

File tree

7 files changed

+121
-30
lines changed

7 files changed

+121
-30
lines changed

plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/debug/gdbjtag/jlink/ui/TabDebugger.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,8 @@ private void propagateConnectToRunningChanged() {
12111211
boolean enabled = fDoConnectToRunning.getSelection();
12121212

12131213
fDoGdbServerInitRegs.setEnabled(!enabled);
1214+
1215+
fTabStartup.doConnectToRunningChanged(!enabled);
12141216
}
12151217
}
12161218

plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/debug/gdbjtag/jlink/ui/TabStartup.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,9 @@ public void initializeFrom(ILaunchConfiguration configuration) {
13391339

13401340
updateUseFileEnablement();
13411341

1342+
doConnectToRunningChanged(configuration.getAttribute(ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
1343+
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT));
1344+
13421345
} catch (CoreException e) {
13431346
Activator.log(e.getStatus());
13441347
}

plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.core/src/org/eclipse/embedcdt/debug/gdbjtag/openocd/core/ConfigurationAttributes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public interface ConfigurationAttributes extends org.eclipse.embedcdt.debug.gdbj
3030

3131
public static final String DO_START_GDB_SERVER = PREFIX + ".doStartGdbServer"; //$NON-NLS-1$
3232

33+
public static final String DO_CONNECT_TO_RUNNING = PREFIX + ".doConnectToRunning"; //$NON-NLS-1$
34+
3335
public static final String GDB_SERVER_EXECUTABLE = PREFIX + ".gdbServerExecutable"; //$NON-NLS-1$
3436

3537
public static final String GDB_SERVER_CONNECTION_ADDRESS = PREFIX + ".gdbServerConnectionAddress"; //$NON-NLS-1$

plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.core/src/org/eclipse/embedcdt/debug/gdbjtag/openocd/core/dsf/DebuggerCommands.java

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,19 @@ public IStatus addGnuMcuResetCommands(List<String> commandsList) {
7575
return status;
7676
}
7777

78-
if (DebugUtils.getAttribute(fAttributes, IGDBJtagConstants.ATTR_LOAD_IMAGE,
79-
IGDBJtagConstants.DEFAULT_LOAD_IMAGE)
80-
&& !DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_DEBUG_IN_RAM,
81-
DefaultPreferences.DO_DEBUG_IN_RAM_DEFAULT)) {
82-
83-
status = addLoadImageCommands(commandsList);
84-
85-
if (!status.isOK()) {
86-
return status;
78+
boolean doConnectToRunning = DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
79+
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT);
80+
if (!doConnectToRunning) {
81+
if (DebugUtils.getAttribute(fAttributes, IGDBJtagConstants.ATTR_LOAD_IMAGE,
82+
IGDBJtagConstants.DEFAULT_LOAD_IMAGE)
83+
&& !DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_DEBUG_IN_RAM,
84+
DefaultPreferences.DO_DEBUG_IN_RAM_DEFAULT)) {
85+
86+
status = addLoadImageCommands(commandsList);
87+
88+
if (!status.isOK()) {
89+
return status;
90+
}
8791
}
8892
}
8993

@@ -93,7 +97,10 @@ public IStatus addGnuMcuResetCommands(List<String> commandsList) {
9397
@Override
9498
public IStatus addGnuMcuStartCommands(List<String> commandsList) {
9599

96-
IStatus status = addStartRestartCommands(true, commandsList);
100+
boolean doReset = !DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
101+
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT);
102+
103+
IStatus status = addStartRestartCommands(doReset, commandsList);
97104

98105
if (!status.isOK()) {
99106
return status;
@@ -107,18 +114,24 @@ public IStatus addGnuMcuStartCommands(List<String> commandsList) {
107114
@Override
108115
public IStatus addFirstResetCommands(List<String> commandsList) {
109116

110-
if (DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_FIRST_RESET,
111-
DefaultPreferences.DO_FIRST_RESET_DEFAULT)) {
117+
boolean noReset = DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
118+
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT);
112119

113-
String commandStr = DefaultPreferences.DO_FIRST_RESET_COMMAND;
114-
String resetType = DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.FIRST_RESET_TYPE,
115-
DefaultPreferences.FIRST_RESET_TYPE_DEFAULT);
116-
commandsList.add(commandStr + resetType);
120+
if (!noReset) {
121+
String commandStr;
122+
if (DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_FIRST_RESET,
123+
DefaultPreferences.DO_FIRST_RESET_DEFAULT)) {
117124

118-
// Although the manual claims that reset always does a
119-
// halt, better issue it explicitly
120-
commandStr = DefaultPreferences.HALT_COMMAND;
121-
commandsList.add(commandStr);
125+
commandStr = DefaultPreferences.DO_FIRST_RESET_COMMAND;
126+
String resetType = DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.FIRST_RESET_TYPE,
127+
DefaultPreferences.FIRST_RESET_TYPE_DEFAULT);
128+
commandsList.add(commandStr + resetType);
129+
130+
// Although the manual claims that reset always does a
131+
// halt, better issue it explicitly
132+
commandStr = DefaultPreferences.HALT_COMMAND;
133+
commandsList.add(commandStr);
134+
}
122135
}
123136

124137
String otherInits = DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.OTHER_INIT_COMMANDS,
@@ -155,17 +168,17 @@ public IStatus addStartRestartCommands(boolean doReset, List<String> commandsLis
155168
commandStr = DefaultPreferences.HALT_COMMAND;
156169
commandsList.add(commandStr);
157170
}
158-
}
159171

160172
if (DebugUtils.getAttribute(fAttributes, IGDBJtagConstants.ATTR_LOAD_IMAGE,
161173
IGDBJtagConstants.DEFAULT_LOAD_IMAGE)
162174
&& DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_DEBUG_IN_RAM,
163175
DefaultPreferences.DO_DEBUG_IN_RAM_DEFAULT)) {
164176

165-
IStatus status = addLoadImageCommands(commandsList);
177+
IStatus status = addLoadImageCommands(commandsList);
166178

167-
if (!status.isOK()) {
168-
return status;
179+
if (!status.isOK()) {
180+
return status;
181+
}
169182
}
170183
}
171184

plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.core/src/org/eclipse/embedcdt/debug/gdbjtag/openocd/core/preferences/DefaultPreferences.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class DefaultPreferences extends org.eclipse.embedcdt.debug.gdbjtag.core.
3939

4040
// Not yet preferences
4141
public static final boolean DO_START_GDB_SERVER_DEFAULT = true;
42+
public static final boolean DO_CONNECT_TO_RUNNING_DEFAULT = false;
4243
public static final String GDB_SERVER_CONNECTION_ADDRESS_DEFAULT = "";
4344
public static final int GDB_SERVER_GDB_PORT_NUMBER_DEFAULT = 3333;
4445
public static final int GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT = 4444;

plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/src/org/eclipse/embedcdt/debug/gdbjtag/openocd/ui/TabDebugger.java

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public class TabDebugger extends AbstractLaunchConfigurationTab {
9494

9595
private Text fGdbServerOtherOptions;
9696

97+
private Button fDoConnectToRunning;
98+
9799
private Button fDoGdbServerAllocateConsole;
98100
private Button fDoGdbServerAllocateTelnetConsole;
99101

@@ -117,11 +119,13 @@ public class TabDebugger extends AbstractLaunchConfigurationTab {
117119
private DefaultPreferences fDefaultPreferences;
118120
private PersistentPreferences fPersistentPreferences;
119121

122+
private TabStartup fTabStartup;
123+
120124
// ------------------------------------------------------------------------
121125

122126
protected TabDebugger(TabStartup tabStartup) {
123127
super();
124-
128+
fTabStartup = tabStartup;
125129
fDefaultPreferences = Activator.getInstance().getDefaultPreferences();
126130
fPersistentPreferences = Activator.getInstance().getPersistentPreferences();
127131
}
@@ -232,12 +236,31 @@ private void createGdbServerGroup(Composite parent) {
232236
}
233237

234238
{
235-
fDoStartGdbServer = new Button(comp, SWT.CHECK);
236-
fDoStartGdbServer.setText(Messages.DebuggerTab_doStartGdbServer_Text);
237-
fDoStartGdbServer.setToolTipText(Messages.DebuggerTab_doStartGdbServer_ToolTipText);
238-
GridData gd = new GridData();
239+
240+
Composite local = new Composite(comp, SWT.NONE);
241+
GridLayout layout = new GridLayout();
242+
layout.numColumns = 2;
243+
layout.marginHeight = 0;
244+
layout.marginWidth = 0;
245+
local.setLayout(layout);
246+
247+
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
239248
gd.horizontalSpan = ((GridLayout) comp.getLayout()).numColumns;
240-
fDoStartGdbServer.setLayoutData(gd);
249+
local.setLayoutData(gd);
250+
{
251+
fDoStartGdbServer = new Button(local, SWT.CHECK);
252+
fDoStartGdbServer.setText(Messages.DebuggerTab_doStartGdbServer_Text);
253+
fDoStartGdbServer.setToolTipText(Messages.DebuggerTab_doStartGdbServer_ToolTipText);
254+
gd = new GridData(GridData.FILL_HORIZONTAL);
255+
fDoStartGdbServer.setLayoutData(gd);
256+
257+
fDoConnectToRunning = new Button(local, SWT.CHECK);
258+
fDoConnectToRunning.setText(Messages.DebuggerTab_noReset_Text);
259+
fDoConnectToRunning.setToolTipText(Messages.DebuggerTab_noReset_ToolTipText);
260+
gd = new GridData(GridData.FILL_HORIZONTAL);
261+
fDoConnectToRunning.setLayoutData(gd);
262+
}
263+
241264
}
242265

243266
{
@@ -399,6 +422,16 @@ public void widgetSelected(SelectionEvent e) {
399422
}
400423
});
401424

425+
fDoConnectToRunning.addSelectionListener(new SelectionAdapter() {
426+
@Override
427+
public void widgetSelected(SelectionEvent e) {
428+
// updateLaunchConfigurationDialog();
429+
fTabStartup.doConnectToRunningChanged(fDoConnectToRunning.getSelection());
430+
431+
scheduleUpdateJob();
432+
}
433+
});
434+
402435
fGdbServerExecutable.addModifyListener(new ModifyListener() {
403436
@Override
404437
public void modifyText(ModifyEvent e) {
@@ -765,6 +798,15 @@ private void doStartGdbClientChanged() {
765798
fGdbClientOtherCommands.setEnabled(enabled);
766799
}
767800

801+
private void propagateConnectToRunningChanged() {
802+
803+
if (fDoStartGdbServer.getSelection()) {
804+
805+
boolean enabled = fDoConnectToRunning.getSelection();
806+
fTabStartup.doConnectToRunningChanged(!enabled);
807+
}
808+
}
809+
768810
protected void updateDecorations() {
769811
if (fDoStartGdbServer.getSelection()) {
770812
if (DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT.equals(fTargetIpAddress.getText())) {
@@ -804,6 +846,10 @@ public void initializeFrom(ILaunchConfiguration configuration) {
804846
fDoStartGdbServer.setSelection(
805847
configuration.getAttribute(ConfigurationAttributes.DO_START_GDB_SERVER, booleanDefault));
806848

849+
fDoConnectToRunning
850+
.setSelection(configuration.getAttribute(ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
851+
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT));
852+
807853
// Executable
808854
stringDefault = fPersistentPreferences.getGdbServerExecutable();
809855
fGdbServerExecutable.setText(
@@ -881,6 +927,7 @@ public void initializeFrom(ILaunchConfiguration configuration) {
881927
}
882928

883929
doStartGdbServerChanged();
930+
propagateConnectToRunningChanged();
884931

885932
// Force thread update
886933
boolean updateThreadsOnSuspend = configuration.getAttribute(
@@ -910,6 +957,8 @@ public void initializeFromDefaults() {
910957
// Start server locally
911958
fDoStartGdbServer.setSelection(DefaultPreferences.DO_START_GDB_SERVER_DEFAULT);
912959

960+
fDoConnectToRunning.setSelection(DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT);
961+
913962
// Executable
914963
stringDefault = fDefaultPreferences.getGdbServerExecutable();
915964
fGdbServerExecutable.setText(stringDefault);
@@ -1092,6 +1141,10 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
10921141
configuration.setAttribute(ConfigurationAttributes.DO_START_GDB_SERVER, booleanValue);
10931142
fPersistentPreferences.putGdbServerDoStart(booleanValue);
10941143

1144+
// Connect to running
1145+
configuration.setAttribute(ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
1146+
fDoConnectToRunning.getSelection());
1147+
10951148
// Executable
10961149
stringValue = fGdbServerExecutable.getText().trim();
10971150
configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_EXECUTABLE, stringValue);

plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/src/org/eclipse/embedcdt/debug/gdbjtag/openocd/ui/TabStartup.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,21 @@ public void widgetSelected(SelectionEvent e) {
782782
fDoContinue.addSelectionListener(scheduleUpdateJobSelectionAdapter);
783783
}
784784

785+
public void doConnectToRunningChanged(boolean flag) {
786+
787+
fDoFirstReset.setEnabled(!flag);
788+
fFirstResetType.setEnabled(!flag);
789+
790+
fDoSecondReset.setEnabled(!flag);
791+
fSecondResetType.setEnabled(!flag);
792+
fSecondResetWarning.setEnabled(!flag);
793+
794+
fLoadExecutable.setEnabled(!flag);
795+
796+
fSetPcRegister.setEnabled(!flag);
797+
fPcRegister.setEnabled(!flag);
798+
}
799+
785800
@Override
786801
public boolean isValid(ILaunchConfiguration launchConfig) {
787802
if (!super.isValid(launchConfig))
@@ -985,6 +1000,8 @@ public void initializeFrom(ILaunchConfiguration configuration) {
9851000
pcRegisterChanged();
9861001
stopAtChanged();
9871002
updateUseFileEnablement();
1003+
doConnectToRunningChanged(configuration.getAttribute(ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
1004+
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT));
9881005

9891006
} catch (CoreException e) {
9901007
Activator.log(e.getStatus());

0 commit comments

Comments
 (0)