Bug 525692: Execute run commands before resume

The -exec-continue command must be last in the GDB
Hardware Debugging launch sequence to ensure any run
commands are executed before application code.

Change-Id: I1eae32698e80d1c1b36da4bbdf21d85d363bcd05
Signed-off-by: John Dallaway <john@dallaway.org.uk>
diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java
index 0bed0cb..c94e436 100644
--- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java
+++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2016 QNX Software Systems and others.
+ * Copyright (c) 2007, 2017 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
@@ -15,6 +15,7 @@
  *     Marc Khouzam (Ericsson) - Updated to extend FinalLaunchSequence instead of copying it (bug 324101)
  *     William Riley (Renesas) - Memory viewing broken (Bug 413483)
  *     Marc Khouzam (Ericsson) - Cannot disable Delay command (bug 413437)
+ *     John Dallaway - Execute run commands before resume (Bug 525692)
  *******************************************************************************/
 package org.eclipse.cdt.debug.gdbjtag.core;
 
@@ -174,8 +175,8 @@
 					
 					"stepSetProgramCounter",   //$NON-NLS-1$
 					"stepStopScript",   //$NON-NLS-1$
-					"stepResumeScript",   //$NON-NLS-1$
 					"stepUserDebugCommands",   //$NON-NLS-1$
+					"stepResumeScript",   //$NON-NLS-1$
 					"stepJTAGCleanup",   //$NON-NLS-1$
 			};
 		}
diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagStartupTab.java b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagStartupTab.java
index f318938..0be23fd 100644
--- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagStartupTab.java
+++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagStartupTab.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007 - 2015 QNX Software Systems and others.
+ * Copyright (c) 2007 - 2017 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
@@ -9,6 +9,7 @@
  *     QNX Software Systems - Initial API and implementation
  *     Andy Jin - Hardware debugging UI improvements, bug 229946
  *     Andy Jin - Added DSF debugging, bug 248593
+ *     John Dallaway - Execute run commands before resume, bug 525692
  *******************************************************************************/
 
 package org.eclipse.cdt.debug.gdbjtag.ui;
@@ -430,7 +431,12 @@
 		symbolsFileBrowse.setEnabled(enabled);
 	}
 
+	/** Implementation migrated to {@link #createRunGroup(Composite)} */
+	@Deprecated
 	public void createRunOptionGroup(Composite parent) {
+	}
+
+	public void createRunGroup(Composite parent) {
 		Group group = new Group(parent, SWT.NONE);
 		GridLayout layout = new GridLayout();
 		group.setLayout(layout);
@@ -438,7 +444,7 @@
 		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 1;
 		group.setLayoutData(gd);
-		group.setText(Messages.getString("GDBJtagStartupTab.runOptionGroup_Text"));
+		group.setText(Messages.getString("GDBJtagStartupTab.runGroup_Text"));
 		
 		setPcRegister = new Button(group, SWT.CHECK);
 		setPcRegister.setText(Messages.getString("GDBJtagStartupTab.setPcRegister_Text"));
@@ -496,6 +502,18 @@
 			}
 		});
 
+		runCommands = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
+		gd = new GridData(GridData.FILL_BOTH);
+		gd.horizontalSpan = 2;
+		gd.heightHint = 60;
+		runCommands.setLayoutData(gd);
+		runCommands.addModifyListener(new ModifyListener() {
+			@Override
+			public void modifyText(ModifyEvent evt) {
+				scheduleUpdateJob();
+			}
+		});
+
 		setResume = new Button(group, SWT.CHECK);
 		setResume.setText(Messages.getString("GDBJtagStartupTab.setResume_Text"));
 		gd = new GridData();
@@ -544,26 +562,6 @@
 		resume = setResume.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(Messages.getString("GDBJtagStartupTab.runGroup_Text"));
-
-		runCommands = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
-		gd = new GridData(GridData.FILL_BOTH);
-		gd.heightHint = 60;
-		runCommands.setLayoutData(gd);
-		runCommands.addModifyListener(new ModifyListener() {
-			@Override
-			public void modifyText(ModifyEvent evt) {
-				scheduleUpdateJob();
-			}
-		});
-	}
-	
 	/* (non-Javadoc)
 	 * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
 	 */