27
27
import ilg .gnuarmeclipse .debug .gdbjtag .jlink .Utils ;
28
28
29
29
import java .io .File ;
30
+ import java .util .ArrayList ;
31
+ import java .util .List ;
30
32
31
33
import org .eclipse .cdt .debug .gdbjtag .core .IGDBJtagConstants ;
32
34
import org .eclipse .cdt .debug .gdbjtag .ui .GDBJtagImages ;
@@ -202,6 +204,18 @@ private void browseButtonSelected(String title, Text text) {
202
204
text .setText (str );
203
205
}
204
206
207
+ private void browseSaveButtonSelected (String title , Text text ) {
208
+ FileDialog dialog = new FileDialog (getShell (), SWT .SAVE );
209
+ dialog .setText (title );
210
+ String str = text .getText ().trim ();
211
+ int lastSeparatorIndex = str .lastIndexOf (File .separator );
212
+ if (lastSeparatorIndex != -1 )
213
+ dialog .setFilterPath (str .substring (0 , lastSeparatorIndex ));
214
+ str = dialog .open ();
215
+ if (str != null )
216
+ text .setText (str );
217
+ }
218
+
205
219
private void variablesButtonSelected (Text text ) {
206
220
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog (
207
221
getShell ());
@@ -279,6 +293,7 @@ public void widgetSelected(SelectionEvent e) {
279
293
public void widgetSelected (SelectionEvent e ) {
280
294
updateLaunchConfigurationDialog ();
281
295
296
+ doConnectToRunningChanged ();
282
297
tabStartup .doConnectToRunningChanged (doConnectToRunning
283
298
.getSelection ());
284
299
}
@@ -746,7 +761,7 @@ public void modifyText(ModifyEvent e) {
746
761
gdbServerLogBrowse .addSelectionListener (new SelectionAdapter () {
747
762
@ Override
748
763
public void widgetSelected (SelectionEvent e ) {
749
- browseButtonSelected (Messages
764
+ browseSaveButtonSelected (Messages
750
765
.getString ("DebuggerTab.gdbServerLogBrowse_Title" ),
751
766
gdbServerLog );
752
767
}
@@ -962,6 +977,16 @@ private void doStartGdbServerChanged() {
962
977
targetPortNumber .setEnabled (!enabled );
963
978
}
964
979
980
+ private void doConnectToRunningChanged () {
981
+
982
+ if (doStartGdbServer .getSelection ()) {
983
+
984
+ boolean enabled = doConnectToRunning .getSelection ();
985
+
986
+ doGdbServerInitRegs .setEnabled (!enabled );
987
+ }
988
+ }
989
+
965
990
@ Override
966
991
public void initializeFrom (ILaunchConfiguration configuration ) {
967
992
try {
@@ -1163,6 +1188,7 @@ else if (ConfigurationAttributes.ENDIANNESS_BIG
1163
1188
}
1164
1189
1165
1190
doStartGdbServerChanged ();
1191
+ doConnectToRunningChanged ();
1166
1192
1167
1193
// Force thread update
1168
1194
boolean updateThreadsOnSuspend = configuration
@@ -1552,8 +1578,9 @@ public static String getGdbServerCommand(ILaunchConfiguration configuration) {
1552
1578
1553
1579
public static String getGdbServerCommandLine (
1554
1580
ILaunchConfiguration configuration ) {
1555
- StringBuffer sb = new StringBuffer ();
1556
1581
1582
+ List <String > lst = new ArrayList <String >();
1583
+
1557
1584
try {
1558
1585
if (!configuration .getAttribute (
1559
1586
ConfigurationAttributes .DO_START_GDB_SERVER ,
@@ -1567,43 +1594,43 @@ public static String getGdbServerCommandLine(
1567
1594
if (executable .length () == 0 )
1568
1595
return null ;
1569
1596
1570
- sb . append (executable );
1597
+ lst . add (executable );
1571
1598
1572
- sb . append ( " -if " );
1573
- sb . append (configuration .getAttribute (
1599
+ lst . add ( " -if" );
1600
+ lst . add (configuration .getAttribute (
1574
1601
ConfigurationAttributes .INTERFACE ,
1575
1602
ConfigurationAttributes .INTERFACE_DEFAULT ));
1576
1603
1577
1604
String name = configuration .getAttribute (
1578
1605
ConfigurationAttributes .FLASH_DEVICE_NAME ,
1579
1606
ConfigurationAttributes .FLASH_DEVICE_NAME_DEFAULT ).trim ();
1580
1607
if (name .length () > 0 ) {
1581
- sb . append ( " -device " );
1582
- sb . append (name );
1608
+ lst . add ( " -device" );
1609
+ lst . add (name );
1583
1610
}
1584
1611
1585
- sb . append ( " -endian " );
1586
- sb . append (configuration .getAttribute (
1612
+ lst . add ( " -endian" );
1613
+ lst . add (configuration .getAttribute (
1587
1614
ConfigurationAttributes .ENDIANNESS ,
1588
1615
ConfigurationAttributes .ENDIANNESS_DEFAULT ));
1589
1616
1590
- sb . append ( " -speed " );
1591
- sb . append (configuration .getAttribute (
1617
+ lst . add ( " -speed" );
1618
+ lst . add (configuration .getAttribute (
1592
1619
ConfigurationAttributes .GDB_SERVER_SPEED ,
1593
1620
ConfigurationAttributes .GDB_SERVER_SPEED_DEFAULT ));
1594
1621
1595
- sb . append ( " -port " );
1596
- sb . append (Integer .toString (configuration .getAttribute (
1622
+ lst . add ( " -port" );
1623
+ lst . add (Integer .toString (configuration .getAttribute (
1597
1624
ConfigurationAttributes .GDB_SERVER_GDB_PORT_NUMBER ,
1598
1625
ConfigurationAttributes .GDB_SERVER_GDB_PORT_NUMBER_DEFAULT )));
1599
1626
1600
- sb . append ( " -swoport " );
1601
- sb . append (Integer .toString (configuration .getAttribute (
1627
+ lst . add ( " -swoport" );
1628
+ lst . add (Integer .toString (configuration .getAttribute (
1602
1629
ConfigurationAttributes .GDB_SERVER_SWO_PORT_NUMBER ,
1603
1630
ConfigurationAttributes .GDB_SERVER_SWO_PORT_NUMBER_DEFAULT )));
1604
1631
1605
- sb . append ( " -semiport " );
1606
- sb . append (Integer .toString (configuration
1632
+ lst . add ( "-telnetport " );
1633
+ lst . add (Integer .toString (configuration
1607
1634
.getAttribute (
1608
1635
ConfigurationAttributes .GDB_SERVER_TELNET_PORT_NUMBER ,
1609
1636
ConfigurationAttributes .GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT )));
@@ -1612,52 +1639,63 @@ public static String getGdbServerCommandLine(
1612
1639
.getAttribute (
1613
1640
ConfigurationAttributes .DO_GDB_SERVER_VERIFY_DOWNLOAD ,
1614
1641
ConfigurationAttributes .DO_GDB_SERVER_VERIFY_DOWNLOAD_DEFAULT )) {
1615
- sb . append ( " -vd " );
1642
+ lst . add ( " -vd" );
1616
1643
}
1617
1644
1618
- if (! configuration .getAttribute (
1645
+ if (configuration .getAttribute (
1619
1646
ConfigurationAttributes .DO_CONNECT_TO_RUNNING ,
1620
1647
ConfigurationAttributes .DO_CONNECT_TO_RUNNING_DEFAULT )) {
1648
+ lst .add ("-noreset" );
1649
+ lst .add ("-noir" );
1650
+ } else {
1621
1651
if (configuration
1622
1652
.getAttribute (
1623
1653
ConfigurationAttributes .DO_GDB_SERVER_INIT_REGS ,
1624
1654
ConfigurationAttributes .DO_GDB_SERVER_INIT_REGS_DEFAULT )) {
1625
- sb .append (" -ir " );
1655
+ lst .add ("-ir" );
1656
+ } else {
1657
+ lst .add ("-noir" );
1626
1658
}
1627
1659
}
1628
1660
1629
1661
if (configuration .getAttribute (
1630
1662
ConfigurationAttributes .DO_GDB_SERVER_LOCAL_ONLY ,
1631
1663
ConfigurationAttributes .DO_GDB_SERVER_LOCAL_ONLY_DEFAULT )) {
1632
- sb . append ( " -localhostonly " );
1664
+ lst . add ( " -localhostonly" );
1633
1665
}
1634
1666
1635
1667
if (configuration .getAttribute (
1636
1668
ConfigurationAttributes .DO_GDB_SERVER_SILENT ,
1637
1669
ConfigurationAttributes .DO_GDB_SERVER_SILENT_DEFAULT )) {
1638
- sb . append ( " -silent " );
1670
+ lst . add ( " -silent" );
1639
1671
}
1640
1672
1641
1673
String logFile = configuration .getAttribute (
1642
1674
ConfigurationAttributes .GDB_SERVER_LOG ,
1643
1675
ConfigurationAttributes .GDB_SERVER_LOG_DEFAULT ).trim ();
1644
1676
1645
1677
if (logFile .length () > 0 ) {
1646
- sb . append ( " -log " );
1647
- sb . append ( logFile );
1678
+ lst . add ( " -log" );
1679
+ lst . add ( Utils . escapeWhitespaces ( logFile ) );
1648
1680
}
1649
1681
1650
1682
String other = configuration .getAttribute (
1651
1683
ConfigurationAttributes .GDB_SERVER_OTHER ,
1652
1684
ConfigurationAttributes .GDB_SERVER_OTHER_DEFAULT ).trim ();
1653
1685
if (other .length () > 0 ) {
1654
- sb . append (other );
1686
+ lst . add (other );
1655
1687
}
1656
1688
} catch (CoreException e ) {
1657
1689
Activator .log (e );
1658
1690
return null ;
1659
1691
}
1660
1692
1693
+ StringBuffer sb = new StringBuffer ();
1694
+ for (String item : lst ) {
1695
+ sb .append (item );
1696
+ sb .append (' ' );
1697
+ }
1698
+
1661
1699
String str = null ;
1662
1700
try {
1663
1701
str = VariablesPlugin .getDefault ().getStringVariableManager ()
0 commit comments