Skip to content

Add connect to running target in OpenCD #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have time now to check the full code, what does this call?

Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,8 @@ private void propagateConnectToRunningChanged() {
boolean enabled = fDoConnectToRunning.getSelection();

fDoGdbServerInitRegs.setEnabled(!enabled);

fTabStartup.doConnectToRunningChanged(!enabled);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,9 @@ public void initializeFrom(ILaunchConfiguration configuration) {

updateUseFileEnablement();

doConnectToRunningChanged(configuration.getAttribute(ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT));

} catch (CoreException e) {
Activator.log(e.getStatus());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public interface ConfigurationAttributes extends org.eclipse.embedcdt.debug.gdbj

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

public static final String DO_CONNECT_TO_RUNNING = PREFIX + ".doConnectToRunning"; //$NON-NLS-1$

public static final String GDB_SERVER_EXECUTABLE = PREFIX + ".gdbServerExecutable"; //$NON-NLS-1$

public static final String GDB_SERVER_CONNECTION_ADDRESS = PREFIX + ".gdbServerConnectionAddress"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,19 @@ public IStatus addGnuMcuResetCommands(List<String> commandsList) {
return status;
}

if (DebugUtils.getAttribute(fAttributes, IGDBJtagConstants.ATTR_LOAD_IMAGE,
IGDBJtagConstants.DEFAULT_LOAD_IMAGE)
&& !DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_DEBUG_IN_RAM,
DefaultPreferences.DO_DEBUG_IN_RAM_DEFAULT)) {

status = addLoadImageCommands(commandsList);

if (!status.isOK()) {
return status;
boolean doConnectToRunning = DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT);
if (!doConnectToRunning) {
if (DebugUtils.getAttribute(fAttributes, IGDBJtagConstants.ATTR_LOAD_IMAGE,
IGDBJtagConstants.DEFAULT_LOAD_IMAGE)
&& !DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_DEBUG_IN_RAM,
DefaultPreferences.DO_DEBUG_IN_RAM_DEFAULT)) {

status = addLoadImageCommands(commandsList);

if (!status.isOK()) {
return status;
}
}
}

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

IStatus status = addStartRestartCommands(true, commandsList);
boolean doReset = !DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT);

IStatus status = addStartRestartCommands(doReset, commandsList);

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

if (DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_FIRST_RESET,
DefaultPreferences.DO_FIRST_RESET_DEFAULT)) {
boolean noReset = DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT);

String commandStr = DefaultPreferences.DO_FIRST_RESET_COMMAND;
String resetType = DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.FIRST_RESET_TYPE,
DefaultPreferences.FIRST_RESET_TYPE_DEFAULT);
commandsList.add(commandStr + resetType);
if (!noReset) {
String commandStr;
if (DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_FIRST_RESET,
DefaultPreferences.DO_FIRST_RESET_DEFAULT)) {

// Although the manual claims that reset always does a
// halt, better issue it explicitly
commandStr = DefaultPreferences.HALT_COMMAND;
commandsList.add(commandStr);
commandStr = DefaultPreferences.DO_FIRST_RESET_COMMAND;
String resetType = DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.FIRST_RESET_TYPE,
DefaultPreferences.FIRST_RESET_TYPE_DEFAULT);
commandsList.add(commandStr + resetType);

// Although the manual claims that reset always does a
// halt, better issue it explicitly
commandStr = DefaultPreferences.HALT_COMMAND;
commandsList.add(commandStr);
}
}

String otherInits = DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.OTHER_INIT_COMMANDS,
Expand Down Expand Up @@ -155,17 +168,17 @@ public IStatus addStartRestartCommands(boolean doReset, List<String> commandsLis
commandStr = DefaultPreferences.HALT_COMMAND;
commandsList.add(commandStr);
}
}

if (DebugUtils.getAttribute(fAttributes, IGDBJtagConstants.ATTR_LOAD_IMAGE,
IGDBJtagConstants.DEFAULT_LOAD_IMAGE)
&& DebugUtils.getAttribute(fAttributes, ConfigurationAttributes.DO_DEBUG_IN_RAM,
DefaultPreferences.DO_DEBUG_IN_RAM_DEFAULT)) {

IStatus status = addLoadImageCommands(commandsList);
IStatus status = addLoadImageCommands(commandsList);

if (!status.isOK()) {
return status;
if (!status.isOK()) {
return status;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class DefaultPreferences extends org.eclipse.embedcdt.debug.gdbjtag.core.

// Not yet preferences
public static final boolean DO_START_GDB_SERVER_DEFAULT = true;
public static final boolean DO_CONNECT_TO_RUNNING_DEFAULT = false;
public static final String GDB_SERVER_CONNECTION_ADDRESS_DEFAULT = "";
public static final int GDB_SERVER_GDB_PORT_NUMBER_DEFAULT = 3333;
public static final int GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT = 4444;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public class TabDebugger extends AbstractLaunchConfigurationTab {

private Text fGdbServerOtherOptions;

private Button fDoConnectToRunning;

private Button fDoGdbServerAllocateConsole;
private Button fDoGdbServerAllocateTelnetConsole;

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

private TabStartup fTabStartup;

// ------------------------------------------------------------------------

protected TabDebugger(TabStartup tabStartup) {
super();

fTabStartup = tabStartup;
fDefaultPreferences = Activator.getInstance().getDefaultPreferences();
fPersistentPreferences = Activator.getInstance().getPersistentPreferences();
}
Expand Down Expand Up @@ -232,12 +236,31 @@ private void createGdbServerGroup(Composite parent) {
}

{
fDoStartGdbServer = new Button(comp, SWT.CHECK);
fDoStartGdbServer.setText(Messages.DebuggerTab_doStartGdbServer_Text);
fDoStartGdbServer.setToolTipText(Messages.DebuggerTab_doStartGdbServer_ToolTipText);
GridData gd = new GridData();

Composite local = new Composite(comp, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
local.setLayout(layout);

GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = ((GridLayout) comp.getLayout()).numColumns;
fDoStartGdbServer.setLayoutData(gd);
local.setLayoutData(gd);
{
fDoStartGdbServer = new Button(local, SWT.CHECK);
fDoStartGdbServer.setText(Messages.DebuggerTab_doStartGdbServer_Text);
fDoStartGdbServer.setToolTipText(Messages.DebuggerTab_doStartGdbServer_ToolTipText);
gd = new GridData(GridData.FILL_HORIZONTAL);
fDoStartGdbServer.setLayoutData(gd);

fDoConnectToRunning = new Button(local, SWT.CHECK);
fDoConnectToRunning.setText(Messages.DebuggerTab_noReset_Text);
fDoConnectToRunning.setToolTipText(Messages.DebuggerTab_noReset_ToolTipText);
gd = new GridData(GridData.FILL_HORIZONTAL);
fDoConnectToRunning.setLayoutData(gd);
}

}

{
Expand Down Expand Up @@ -399,6 +422,16 @@ public void widgetSelected(SelectionEvent e) {
}
});

fDoConnectToRunning.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// updateLaunchConfigurationDialog();
fTabStartup.doConnectToRunningChanged(fDoConnectToRunning.getSelection());

scheduleUpdateJob();
}
});

fGdbServerExecutable.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
Expand Down Expand Up @@ -765,6 +798,15 @@ private void doStartGdbClientChanged() {
fGdbClientOtherCommands.setEnabled(enabled);
}

private void propagateConnectToRunningChanged() {

if (fDoStartGdbServer.getSelection()) {

boolean enabled = fDoConnectToRunning.getSelection();
fTabStartup.doConnectToRunningChanged(!enabled);
}
}

protected void updateDecorations() {
if (fDoStartGdbServer.getSelection()) {
if (DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT.equals(fTargetIpAddress.getText())) {
Expand Down Expand Up @@ -804,6 +846,10 @@ public void initializeFrom(ILaunchConfiguration configuration) {
fDoStartGdbServer.setSelection(
configuration.getAttribute(ConfigurationAttributes.DO_START_GDB_SERVER, booleanDefault));

fDoConnectToRunning
.setSelection(configuration.getAttribute(ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT));

// Executable
stringDefault = fPersistentPreferences.getGdbServerExecutable();
fGdbServerExecutable.setText(
Expand Down Expand Up @@ -881,6 +927,7 @@ public void initializeFrom(ILaunchConfiguration configuration) {
}

doStartGdbServerChanged();
propagateConnectToRunningChanged();

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

fDoConnectToRunning.setSelection(DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT);

// Executable
stringDefault = fDefaultPreferences.getGdbServerExecutable();
fGdbServerExecutable.setText(stringDefault);
Expand Down Expand Up @@ -1092,6 +1141,10 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(ConfigurationAttributes.DO_START_GDB_SERVER, booleanValue);
fPersistentPreferences.putGdbServerDoStart(booleanValue);

// Connect to running
configuration.setAttribute(ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
fDoConnectToRunning.getSelection());

// Executable
stringValue = fGdbServerExecutable.getText().trim();
configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_EXECUTABLE, stringValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,21 @@ public void widgetSelected(SelectionEvent e) {
fDoContinue.addSelectionListener(scheduleUpdateJobSelectionAdapter);
}

public void doConnectToRunningChanged(boolean flag) {

fDoFirstReset.setEnabled(!flag);
fFirstResetType.setEnabled(!flag);

fDoSecondReset.setEnabled(!flag);
fSecondResetType.setEnabled(!flag);
fSecondResetWarning.setEnabled(!flag);

fLoadExecutable.setEnabled(!flag);

fSetPcRegister.setEnabled(!flag);
fPcRegister.setEnabled(!flag);
}

@Override
public boolean isValid(ILaunchConfiguration launchConfig) {
if (!super.isValid(launchConfig))
Expand Down Expand Up @@ -985,6 +1000,8 @@ public void initializeFrom(ILaunchConfiguration configuration) {
pcRegisterChanged();
stopAtChanged();
updateUseFileEnablement();
doConnectToRunningChanged(configuration.getAttribute(ConfigurationAttributes.DO_CONNECT_TO_RUNNING,
DefaultPreferences.DO_CONNECT_TO_RUNNING_DEFAULT));

} catch (CoreException e) {
Activator.log(e.getStatus());
Expand Down