Skip to content

Commit a39d2ac

Browse files
committed
openocd: defaults big cleanup
1 parent 730ab05 commit a39d2ac

File tree

11 files changed

+271
-222
lines changed

11 files changed

+271
-222
lines changed

ilg.gnuarmeclipse.debug.gdbjtag.openocd/preferences.ini

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,29 @@ ${user.home}/local/gnuarmeclipse/OpenOCD:\
4545
# is not filled-in.
4646
tab.main.checkProgram=false
4747

48+
# Set to false to disable the folder check.
49+
folder.strict=true
50+
51+
# -----------------------------------------------------------------------------
52+
53+
# Server defaults
54+
gdb.server.doStart=true
4855
gdb.server.executable=${openocd_path}/${openocd_executable}
56+
gdb.server.other=
57+
58+
# Client defaults
59+
gdb.client.commands=set mem inaccessible-by-default off
4960
gdb.client.executable=${cross_prefix}gdb${cross_suffix}
50-
#gdb.server.other=
61+
gdb.client.other=
5162

52-
# Set to false to disable the folder check.
53-
folder.strict=true
63+
# OpenOCD specific
64+
gdb.openocd.doDebugInRam=false
65+
gdb.openocd.doInitialReset=true
66+
gdb.openocd.doPreRunReset=true
67+
gdb.openocd.enableSemihosting=true
68+
gdb.openocd.init.other=
69+
gdb.openocd.initialReset.type=init
70+
gdb.openocd.preRun.other=
71+
gdb.openocd.preRunReset.type=halt
5472

5573
# -----------------------------------------------------------------------------

ilg.gnuarmeclipse.debug.gdbjtag.openocd/src/ilg/gnuarmeclipse/debug/gdbjtag/openocd/Configuration.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public static String getGdbServerCommand(ILaunchConfiguration configuration) {
2626
try {
2727
if (!configuration.getAttribute(
2828
ConfigurationAttributes.DO_START_GDB_SERVER,
29-
ConfigurationAttributes.DO_START_GDB_SERVER_DEFAULT))
29+
DefaultPreferences.DO_START_GDB_SERVER_DEFAULT))
3030
return null;
3131

3232
executable = configuration.getAttribute(
3333
ConfigurationAttributes.GDB_SERVER_EXECUTABLE,
34-
ConfigurationAttributes.GDB_SERVER_EXECUTABLE_DEFAULT);
34+
DefaultPreferences.GDB_SERVER_EXECUTABLE_DEFAULT);
3535
// executable = Utils.escapeWhitespaces(executable).trim();
3636
executable = executable.trim();
3737
if (executable.length() == 0)
@@ -69,7 +69,7 @@ public static String[] getGdbServerCommandLineArray(
6969
try {
7070
if (!configuration.getAttribute(
7171
ConfigurationAttributes.DO_START_GDB_SERVER,
72-
ConfigurationAttributes.DO_START_GDB_SERVER_DEFAULT))
72+
DefaultPreferences.DO_START_GDB_SERVER_DEFAULT))
7373
return null;
7474

7575
String executable = getGdbServerCommand(configuration);
@@ -83,18 +83,18 @@ public static String[] getGdbServerCommandLineArray(
8383
+ Integer.toString(configuration
8484
.getAttribute(
8585
ConfigurationAttributes.GDB_SERVER_GDB_PORT_NUMBER,
86-
ConfigurationAttributes.GDB_SERVER_GDB_PORT_NUMBER_DEFAULT)));
86+
DefaultPreferences.GDB_SERVER_GDB_PORT_NUMBER_DEFAULT)));
8787

8888
lst.add("-c");
8989
lst.add("telnet_port "
9090
+ Integer.toString(configuration
9191
.getAttribute(
9292
ConfigurationAttributes.GDB_SERVER_TELNET_PORT_NUMBER,
93-
ConfigurationAttributes.GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT)));
93+
DefaultPreferences.GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT)));
9494

9595
String other = configuration.getAttribute(
9696
ConfigurationAttributes.GDB_SERVER_OTHER,
97-
ConfigurationAttributes.GDB_SERVER_OTHER_DEFAULT).trim();
97+
DefaultPreferences.GDB_SERVER_OTHER_DEFAULT).trim();
9898

9999
other = DebugUtils.resolveAll(other, configuration.getAttributes());
100100

@@ -125,7 +125,7 @@ public static String getGdbServerOtherConfig(ILaunchConfiguration config)
125125
throws CoreException {
126126

127127
return config.getAttribute(ConfigurationAttributes.GDB_SERVER_OTHER,
128-
ConfigurationAttributes.GDB_SERVER_OTHER_DEFAULT).trim();
128+
DefaultPreferences.GDB_SERVER_OTHER_DEFAULT).trim();
129129
}
130130

131131
// ------------------------------------------------------------------------
@@ -185,8 +185,7 @@ public static String[] getGdbClientCommandLineArray(
185185
try {
186186
other = configuration.getAttribute(
187187
ConfigurationAttributes.GDB_CLIENT_OTHER_OPTIONS,
188-
ConfigurationAttributes.GDB_CLIENT_OTHER_OPTIONS_DEFAULT)
189-
.trim();
188+
DefaultPreferences.GDB_CLIENT_OTHER_OPTIONS_DEFAULT).trim();
190189

191190
other = DebugUtils.resolveAll(other, configuration.getAttributes());
192191

@@ -219,7 +218,7 @@ public static boolean getDoStartGdbServer(ILaunchConfiguration config)
219218
throws CoreException {
220219

221220
return config.getAttribute(ConfigurationAttributes.DO_START_GDB_SERVER,
222-
ConfigurationAttributes.DO_START_GDB_SERVER_DEFAULT);
221+
DefaultPreferences.DO_START_GDB_SERVER_DEFAULT);
223222
}
224223

225224
public static boolean getDoAddServerConsole(ILaunchConfiguration config)
@@ -229,7 +228,7 @@ public static boolean getDoAddServerConsole(ILaunchConfiguration config)
229228
&& config
230229
.getAttribute(
231230
ConfigurationAttributes.DO_GDB_SERVER_ALLOCATE_CONSOLE,
232-
ConfigurationAttributes.DO_GDB_SERVER_ALLOCATE_CONSOLE_DEFAULT);
231+
DefaultPreferences.DO_GDB_SERVER_ALLOCATE_CONSOLE_DEFAULT);
233232
}
234233

235234
// ------------------------------------------------------------------------

ilg.gnuarmeclipse.debug.gdbjtag.openocd/src/ilg/gnuarmeclipse/debug/gdbjtag/openocd/ConfigurationAttributes.java

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,104 +13,70 @@
1313

1414
public interface ConfigurationAttributes {
1515

16+
// ------------------------------------------------------------------------
17+
1618
public static final String PREFIX = Activator.PLUGIN_ID;
1719

20+
// ------------------------------------------------------------------------
21+
1822
// TabDebugger
1923

2024
// Must be in sync with plugin.xml definition
2125
public static final String JTAG_DEVICE = "GNU ARM OpenOCD";
2226

2327
public static final String DO_START_GDB_SERVER = PREFIX
2428
+ ".doStartGdbServer"; //$NON-NLS-1$
25-
public static final boolean DO_START_GDB_SERVER_DEFAULT = true;
2629

2730
public static final String GDB_SERVER_EXECUTABLE = PREFIX
2831
+ ".gdbServerExecutable"; //$NON-NLS-1$
29-
public static final String GDB_SERVER_EXECUTABLE_DEFAULT = "${openocd_path}/${openocd_executable}";
30-
31-
public static final String GDB_SERVER_EXECUTABLE_DEFAULT_NAME = "openocd";
3232

3333
public static final String GDB_SERVER_CONNECTION_ADDRESS = PREFIX
3434
+ ".gdbServerConnectionAddress"; //$NON-NLS-1$
35-
public static final String GDB_SERVER_CONNECTION_ADDRESS_DEFAULT = "";
3635

3736
public static final String GDB_SERVER_GDB_PORT_NUMBER = PREFIX
3837
+ ".gdbServerGdbPortNumber"; //$NON-NLS-1$
39-
public static final int GDB_SERVER_GDB_PORT_NUMBER_DEFAULT = 3333;
4038

4139
public static final String GDB_SERVER_TELNET_PORT_NUMBER = PREFIX
4240
+ ".gdbServerTelnetPortNumber"; //$NON-NLS-1$
43-
public static final int GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT = 4444;
4441

4542
public static final String GDB_SERVER_LOG = PREFIX + ".gdbServerLog"; //$NON-NLS-1$
46-
public static final String GDB_SERVER_LOG_DEFAULT = ""; //$NON-NLS-1$
4743

4844
public static final String GDB_SERVER_OTHER = PREFIX + ".gdbServerOther"; //$NON-NLS-1$
49-
public static final String GDB_SERVER_OTHER_DEFAULT = ""; //$NON-NLS-1$
5045

5146
public static final String DO_GDB_SERVER_ALLOCATE_CONSOLE = PREFIX
5247
+ ".doGdbServerAllocateConsole"; //$NON-NLS-1$
53-
public static final boolean DO_GDB_SERVER_ALLOCATE_CONSOLE_DEFAULT = true;
5448

5549
public static final String DO_GDB_SERVER_ALLOCATE_TELNET_CONSOLE = PREFIX
5650
+ ".doGdbServerAllocateTelnetConsole"; //$NON-NLS-1$
57-
public static final boolean DO_GDB_SERVER_ALLOCATE_TELNET_CONSOLE_DEFAULT = false;
58-
59-
public static final String GDB_CLIENT_EXECUTABLE_DEFAULT = "${cross_prefix}gdb${cross_suffix}";
6051

6152
public static final String GDB_CLIENT_OTHER_OPTIONS = PREFIX
6253
+ ".gdbClientOtherOptions"; //$NON-NLS-1$
63-
public static final String GDB_CLIENT_OTHER_OPTIONS_DEFAULT = "";
6454

6555
public static final String GDB_CLIENT_OTHER_COMMANDS = PREFIX
6656
+ ".gdbClientOtherCommands"; //$NON-NLS-1$
67-
public static final String GDB_CLIENT_OTHER_COMMANDS_DEFAULT = "set mem inaccessible-by-default off\n";
6857

69-
public static final boolean USE_REMOTE_TARGET_DEFAULT = true;
70-
public static final String REMOTE_IP_ADDRESS_LOCALHOST = "localhost"; //$NON-NLS-1$
71-
public static final String REMOTE_IP_ADDRESS_DEFAULT = REMOTE_IP_ADDRESS_LOCALHOST; //$NON-NLS-1$
72-
public static final int REMOTE_PORT_NUMBER_DEFAULT = GDB_SERVER_GDB_PORT_NUMBER_DEFAULT;
73-
74-
public static final boolean UPDATE_THREAD_LIST_DEFAULT = false;
58+
// ------------------------------------------------------------------------
7559

7660
// TabStartup
7761
public static final String DO_FIRST_RESET = PREFIX + ".doFirstReset"; //$NON-NLS-1$
78-
public static final boolean DO_FIRST_RESET_DEFAULT = true;
79-
public static final String DO_FIRST_RESET_COMMAND = "monitor reset ";
80-
81-
public static final String HALT_COMMAND = "monitor halt";
82-
8362
public static final String FIRST_RESET_TYPE = PREFIX + ".firstResetType"; //$NON-NLS-1$
84-
public static final String FIRST_RESET_TYPE_DEFAULT = "init";
8563

8664
public static final String ENABLE_SEMIHOSTING = PREFIX
8765
+ ".enableSemihosting"; //$NON-NLS-1$
88-
public static final boolean ENABLE_SEMIHOSTING_DEFAULT = true;
89-
public static final String ENABLE_SEMIHOSTING_COMMAND = "monitor arm semihosting enable";
9066

9167
public static final String OTHER_INIT_COMMANDS = PREFIX
9268
+ ".otherInitCommands"; //$NON-NLS-1$
93-
public static final String OTHER_INIT_COMMANDS_DEFAULT = "";
9469

9570
public static final String DO_DEBUG_IN_RAM = PREFIX + ".doDebugInRam"; //$NON-NLS-1$
96-
public static final boolean DO_DEBUG_IN_RAM_DEFAULT = false;
9771

9872
public static final String DO_SECOND_RESET = PREFIX + ".doSecondReset"; //$NON-NLS-1$
99-
public static final boolean DO_SECOND_RESET_DEFAULT = true;
100-
public static final String DO_SECOND_RESET_COMMAND = "monitor reset ";
10173

10274
public static final String SECOND_RESET_TYPE = PREFIX + ".secondResetType"; //$NON-NLS-1$
103-
public static final String SECOND_RESET_TYPE_DEFAULT = "halt";
104-
105-
public static final boolean DO_STOP_AT_DEFAULT = true;
106-
public static final String STOP_AT_NAME_DEFAULT = "main";
10775

10876
public static final String OTHER_RUN_COMMANDS = PREFIX
10977
+ ".otherRunCommands"; //$NON-NLS-1$
110-
public static final String OTHER_RUN_COMMANDS_DEFAULT = "";
11178

11279
public static final String DO_CONTINUE = PREFIX + ".doContinue"; //$NON-NLS-1$
113-
public static final boolean DO_CONTINUE_DEFAULT = true;
114-
public static final String DO_CONTINUE_COMMAND = "continue";
11580

81+
// ------------------------------------------------------------------------
11682
}

ilg.gnuarmeclipse.debug.gdbjtag.openocd/src/ilg/gnuarmeclipse/debug/gdbjtag/openocd/DefaultPreferenceInitializer.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ public void initializeDefaultPreferences() {
5252
.println("DefaultPreferenceInitializer.initializeDefaultPreferences()");
5353
}
5454

55+
DefaultPreferences.putBoolean(
56+
PersistentPreferences.GDB_SERVER_DO_START,
57+
DefaultPreferences.DO_START_GDB_SERVER_DEFAULT);
58+
59+
DefaultPreferences.putString(PersistentPreferences.GDB_CLIENT_COMMANDS,
60+
DefaultPreferences.GDB_CLIENT_OTHER_COMMANDS_DEFAULT);
61+
62+
DefaultPreferences.putBoolean(
63+
PersistentPreferences.TAB_MAIN_CHECK_PROGRAM,
64+
DefaultPreferences.TAB_MAIN_CHECK_PROGRAM_DEFAULT);
65+
5566
// When the 'ilg.gnuarmeclipse.managedbuild.cross' node is completely
5667
// added to /default, a NodeChangeEvent is raised.
5768
// This is the moment when all final default values are in, possibly

ilg.gnuarmeclipse.debug.gdbjtag.openocd/src/ilg/gnuarmeclipse/debug/gdbjtag/openocd/DefaultPreferences.java

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,69 @@ public class DefaultPreferences {
2020

2121
// ------------------------------------------------------------------------
2222

23+
// Constants
24+
public static final String REMOTE_IP_ADDRESS_LOCALHOST = "localhost"; //$NON-NLS-1$
25+
26+
// ------------------------------------------------------------------------
27+
28+
// Preferences
29+
protected static final boolean TAB_MAIN_CHECK_PROGRAM_DEFAULT = false;
30+
31+
protected static final String GDB_SERVER_EXECUTABLE_DEFAULT = "${openocd_path}/${openocd_executable}";
32+
33+
public static final String GDB_SERVER_EXECUTABLE_DEFAULT_NAME = "openocd";
34+
protected static final String GDB_CLIENT_EXECUTABLE_DEFAULT = "${cross_prefix}gdb${cross_suffix}";
35+
36+
// ------------------------------------------------------------------------
37+
38+
// Not yet preferences
39+
public static final boolean DO_START_GDB_SERVER_DEFAULT = true;
40+
public static final String GDB_SERVER_CONNECTION_ADDRESS_DEFAULT = "";
41+
public static final int GDB_SERVER_GDB_PORT_NUMBER_DEFAULT = 3333;
42+
public static final int GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT = 4444;
43+
public static final String GDB_SERVER_LOG_DEFAULT = ""; //$NON-NLS-1$
44+
public static final String GDB_SERVER_OTHER_DEFAULT = ""; //$NON-NLS-1$
45+
public static final boolean DO_GDB_SERVER_ALLOCATE_CONSOLE_DEFAULT = true;
46+
public static final boolean DO_GDB_SERVER_ALLOCATE_TELNET_CONSOLE_DEFAULT = false;
47+
48+
public static final String GDB_CLIENT_OTHER_OPTIONS_DEFAULT = "";
49+
50+
public static final boolean USE_REMOTE_TARGET_DEFAULT = true;
51+
public static final String REMOTE_IP_ADDRESS_DEFAULT = REMOTE_IP_ADDRESS_LOCALHOST; //$NON-NLS-1$
52+
public static final int REMOTE_PORT_NUMBER_DEFAULT = GDB_SERVER_GDB_PORT_NUMBER_DEFAULT;
53+
54+
public static final boolean UPDATE_THREAD_LIST_DEFAULT = false;
55+
56+
public static final boolean DO_FIRST_RESET_DEFAULT = true;
57+
public static final String FIRST_RESET_TYPE_DEFAULT = "init";
58+
59+
public static final boolean ENABLE_SEMIHOSTING_DEFAULT = true;
60+
61+
public static final boolean DO_DEBUG_IN_RAM_DEFAULT = false;
62+
63+
public static final boolean DO_SECOND_RESET_DEFAULT = true;
64+
65+
public static final String SECOND_RESET_TYPE_DEFAULT = "halt";
66+
67+
public static final boolean DO_STOP_AT_DEFAULT = true;
68+
public static final String STOP_AT_NAME_DEFAULT = "main";
69+
70+
public static final boolean DO_CONTINUE_DEFAULT = true;
71+
72+
// ------------------------------------------------------------------------
73+
74+
// Debugger commands
75+
public static final String GDB_CLIENT_OTHER_COMMANDS_DEFAULT = "set mem inaccessible-by-default off\n";
76+
public static final String DO_FIRST_RESET_COMMAND = "monitor reset ";
77+
public static final String HALT_COMMAND = "monitor halt";
78+
public static final String ENABLE_SEMIHOSTING_COMMAND = "monitor arm semihosting enable";
79+
public static final String DO_SECOND_RESET_COMMAND = "monitor reset ";
80+
public static final String DO_CONTINUE_COMMAND = "continue";
81+
public static final String OTHER_INIT_COMMANDS_DEFAULT = "";
82+
public static final String OTHER_RUN_COMMANDS_DEFAULT = "";
83+
84+
// ------------------------------------------------------------------------
85+
2386
// TODO: remove DEPRECATED
2487
// These values are deprecated. Use the definitions in PersistentValues.
2588
private static final String GDB_SERVER_EXECUTABLE_DEPRECATED = "gdb.server.executable.default";
@@ -74,39 +137,50 @@ public static boolean getBoolean(String key, boolean defaultValue) {
74137
return getPreferences().getBoolean(key, defaultValue);
75138
}
76139

77-
private static void putString(String key, String value) {
140+
public static void putString(String key, String value) {
78141
getPreferences().put(key, value);
79142
}
80143

144+
public static void putInt(String key, int value) {
145+
getPreferences().putInt(key, value);
146+
}
147+
148+
public static void putBoolean(String key, boolean value) {
149+
getPreferences().putBoolean(key, value);
150+
}
151+
81152
// ------------------------------------------------------------------------
82153

83-
public static String getGdbServerExecutable(String defValue) {
154+
public static String getGdbServerExecutable() {
84155
String value = getString(PersistentPreferences.GDB_SERVER_EXECUTABLE,
85156
null);
86157
if (value != null) {
87158
return value;
88159
}
89-
return getString(GDB_SERVER_EXECUTABLE_DEPRECATED, defValue);
160+
return getString(GDB_SERVER_EXECUTABLE_DEPRECATED,
161+
GDB_SERVER_EXECUTABLE_DEFAULT);
90162
}
91163

92-
public static String getGdbClientExecutable(String defValue) {
164+
public static String getGdbClientExecutable() {
93165
String value = getString(PersistentPreferences.GDB_CLIENT_EXECUTABLE,
94166
null);
95167
if (value != null) {
96168
return value;
97169
}
98-
return getString(GDB_CLIENT_EXECUTABLE_DEPRECATED, defValue);
170+
return getString(GDB_CLIENT_EXECUTABLE_DEPRECATED,
171+
GDB_CLIENT_EXECUTABLE_DEFAULT);
99172
}
100173

101174
// ------------------------------------------------------------------------
102175

103-
public static String getOpenocdConfig(String defValue) {
176+
public static String getOpenocdConfig() {
104177
String value = getString(
105178
PersistentPreferences.GDB_SERVER_OTHER_OPTIONS, null);
106179
if (value != null) {
107180
return value;
108181
}
109-
return getString(OPENOCD_CONFIG_DEPRECATED, defValue);
182+
return getString(OPENOCD_CONFIG_DEPRECATED,
183+
DefaultPreferences.GDB_SERVER_OTHER_DEFAULT);
110184
}
111185

112186
// ------------------------------------------------------------------------

0 commit comments

Comments
 (0)