Skip to content

Commit 2294072

Browse files
committed
gdbjtag.*: check & update preferences
- remove deprecated - add verbose trace
1 parent 742766b commit 2294072

File tree

8 files changed

+257
-238
lines changed

8 files changed

+257
-238
lines changed

ilg.gnumcueclipse.debug.gdbjtag.jlink/src/ilg/gnumcueclipse/debug/gdbjtag/jlink/DefaultPreferences.java

Lines changed: 56 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,6 @@ public class DefaultPreferences {
126126

127127
// ------------------------------------------------------------------------
128128

129-
// TODO: remove DEPRECATED
130-
// These values are deprecated. Use the definitions in PersistentValues.
131-
private static final String GDB_SERVER_EXECUTABLE_DEPRECATED = "gdb.server.executable.default";
132-
private static final String GDB_CLIENT_EXECUTABLE_DEPRECATED = "gdb.client.executable.default";
133-
134-
private static final String JLINK_INTRFACE_DEPRECATED = "interface.default";
135-
private static final String JLINK_ENABLE_SEMIHOSTING_DEPRECATED = "enableSemihosting.default";
136-
private static final String JLINK_ENABLE_SWO_DEPRECATED = "enableSwo.default";
137-
138-
private static final String JLINK_GDBSERVER_DEPRECATED = "jlink_gdbserver.default";
139-
private static final String JLINK_PATH_DEPRECATED = "jlink_path.default";
140-
141-
// ------------------------------------------------------------------------
142-
143129
/**
144130
* The DefaultScope preference store.
145131
*/
@@ -161,79 +147,94 @@ public static IEclipsePreferences getPreferences() {
161147
*
162148
* @param key
163149
* a string with the key to search.
164-
* @param defaulValue
150+
* @param defaultValue
165151
* a string with the default, possibly null.
166152
* @return a trimmed string, or a null default.
167153
*/
168-
private static String getString(String key, String defaulValue) {
154+
private static String getString(String key, String defaultValue) {
169155

170156
String value;
171-
value = getPreferences().get(key, defaulValue);
157+
value = getPreferences().get(key, defaultValue);
172158

173159
if (value != null) {
174160
value = value.trim();
175161
}
176162

163+
if (Activator.getInstance().isDebugging()) {
164+
System.out.println("jlink.DefaultPreferences.getString(\"" + key + "\", \"" + defaultValue + "\") = \""
165+
+ value + "\"");
166+
}
167+
177168
return value;
178169
}
179170

180171
public static boolean getBoolean(String key, boolean defaultValue) {
181172

182-
return getPreferences().getBoolean(key, defaultValue);
173+
boolean value = getPreferences().getBoolean(key, defaultValue);
174+
175+
if (Activator.getInstance().isDebugging()) {
176+
System.out
177+
.println("openocd.DefaultPreferences.getBoolean(\"" + key + "\", " + defaultValue + ") = " + value);
178+
}
179+
return value;
183180
}
184181

185-
private static int getInt(String name, int defValue) {
182+
private static int getInt(String key, int defaultValue) {
186183

187-
return getPreferences().getInt(name, defValue);
184+
int value = getPreferences().getInt(key, defaultValue);
185+
186+
if (Activator.getInstance().isDebugging()) {
187+
System.out
188+
.println("openocd.DefaultPreferences.getBoolean(\"" + key + "\", " + defaultValue + ") = " + value);
189+
}
190+
return value;
188191
}
189192

190193
public static void putString(String key, String value) {
194+
if (Activator.getInstance().isDebugging()) {
195+
System.out.println("jlink.DefaultPreferences.putString(\"" + key + "\", \"" + value + "\")");
196+
}
197+
191198
getPreferences().put(key, value);
192199
}
193200

194201
public static void putInt(String key, int value) {
202+
if (Activator.getInstance().isDebugging()) {
203+
System.out.println("jlink.DefaultPreferences.putInt(\"" + key + "\", " + value + ")");
204+
}
205+
195206
getPreferences().putInt(key, value);
196207
}
197208

198209
public static void putBoolean(String key, boolean value) {
210+
if (Activator.getInstance().isDebugging()) {
211+
System.out.println("jlink.DefaultPreferences.putBoolean(\"" + key + "\", " + value + ")");
212+
}
213+
199214
getPreferences().putBoolean(key, value);
200215
}
201216

202217
// ------------------------------------------------------------------------
203218

204219
public static String getGdbServerExecutable() {
205-
String value = getString(PersistentPreferences.GDB_SERVER_EXECUTABLE, null);
206-
if (value != null) {
207-
return value;
208-
}
209-
return getString(GDB_SERVER_EXECUTABLE_DEPRECATED, GDB_SERVER_EXECUTABLE_DEFAULT);
220+
String value = getString(PersistentPreferences.GDB_SERVER_EXECUTABLE, GDB_SERVER_EXECUTABLE_DEFAULT);
221+
return value;
210222
}
211223

212224
public static String getGdbClientExecutable() {
213-
String value = getString(PersistentPreferences.GDB_CLIENT_EXECUTABLE, null);
214-
if (value != null) {
215-
return value;
216-
}
217-
return getString(GDB_CLIENT_EXECUTABLE_DEPRECATED, GDB_CLIENT_EXECUTABLE_DEFAULT);
225+
String value = getString(PersistentPreferences.GDB_CLIENT_EXECUTABLE, GDB_CLIENT_EXECUTABLE_DEFAULT);
226+
return value;
218227
}
219228

220229
// ------------------------------------------------------------------------
221230

222231
public static String getExecutableName() {
223232

224233
String key = PersistentPreferences.EXECUTABLE_NAME;
225-
String value = getString(key, null);
226-
if (value == null) {
227-
228-
// TODO: remove DEPRECATED
229-
value = getString(PersistentPreferences.JLINK_GDBSERVER_DEPRECATED, null);
230-
if (value == null) {
231-
value = getString(JLINK_GDBSERVER_DEPRECATED, "");
232-
}
233-
}
234+
String value = getString(key, "");
234235

235236
if (Activator.getInstance().isDebugging()) {
236-
System.out.println("getExecutableName()=\"" + value + "\"");
237+
System.out.println("jlink.DefaultPreferences.getExecutableName() = \"" + value + "\"");
237238
}
238239
return value;
239240

@@ -242,10 +243,10 @@ public static String getExecutableName() {
242243
public static String getExecutableNameOs() {
243244

244245
String key = EclipseUtils.getKeyOs(PersistentPreferences.EXECUTABLE_NAME_OS);
245-
246246
String value = getString(key, "");
247+
247248
if (Activator.getInstance().isDebugging()) {
248-
System.out.println("getExecutableNameOs()=\"" + value + "\" (" + key + ")");
249+
System.out.println("jlink.DefaultPreferences.getExecutableNameOs() = \"" + value + "\" (" + key + ")");
249250
}
250251
return value;
251252
}
@@ -255,7 +256,7 @@ public static void putExecutableName(String value) {
255256
String key = PersistentPreferences.EXECUTABLE_NAME;
256257

257258
if (Activator.getInstance().isDebugging()) {
258-
System.out.println("Default " + key + "=" + value);
259+
System.out.println("jlink.DefaultPreferences.putExecutableName(\"" + value + "\")");
259260
}
260261
putString(key, value);
261262
}
@@ -265,18 +266,10 @@ public static void putExecutableName(String value) {
265266
public static String getInstallFolder() {
266267

267268
String key = PersistentPreferences.INSTALL_FOLDER;
268-
String value = getString(key, null);
269-
if (value == null) {
270-
271-
// TODO: remove DEPRECATED
272-
value = getString(PersistentPreferences.JLINK_PATH_DEPRECATED, null);
273-
if (value == null) {
274-
value = getString(JLINK_PATH_DEPRECATED, "");
275-
}
276-
}
269+
String value = getString(key, "");
277270

278271
if (Activator.getInstance().isDebugging()) {
279-
System.out.println("getInstallFolder()=\"" + value + "\"");
272+
System.out.println("jlink.DefaultPreferences.getInstallFolder()=\"" + value + "\"");
280273
}
281274
return value;
282275
}
@@ -286,7 +279,7 @@ public static void putInstallFolder(String value) {
286279
String key = PersistentPreferences.INSTALL_FOLDER;
287280

288281
if (Activator.getInstance().isDebugging()) {
289-
System.out.println("Default " + key + "=" + value);
282+
System.out.println("jlink.DefaultPreferences.putInstallFolder(\"" + value + "\")");
290283
}
291284
putString(key, value);
292285
}
@@ -297,8 +290,9 @@ public static String getSearchPath() {
297290

298291
String key = PersistentPreferences.SEARCH_PATH;
299292
String value = getString(key, "");
293+
300294
if (Activator.getInstance().isDebugging()) {
301-
System.out.println("getSearchPath()=\"" + value + "\"");
295+
System.out.println("jlink.DefaultPreferences.getSearchPath() = \"" + value + "\"");
302296
}
303297
return value;
304298
}
@@ -307,8 +301,9 @@ public static String getSearchPathOs() {
307301

308302
String key = EclipseUtils.getKeyOs(PersistentPreferences.SEARCH_PATH_OS);
309303
String value = getString(key, "");
304+
310305
if (Activator.getInstance().isDebugging()) {
311-
System.out.println("getSearchPathOs()=\"" + value + "\" (" + key + ")");
306+
System.out.println("jlink.DefaultPreferences.getSearchPathOs() = \"" + value + "\" (" + key + ")");
312307
}
313308
return value;
314309
}
@@ -318,19 +313,16 @@ public static void putSearchPath(String value) {
318313
String key = PersistentPreferences.SEARCH_PATH;
319314

320315
if (Activator.getInstance().isDebugging()) {
321-
System.out.println("Default " + key + "=" + value);
316+
System.out.println("jlink.DefaultPreferences.putSearchPath(\"" + value + "\")");
322317
}
323318
putString(key, value);
324319
}
325320

326321
// ------------------------------------------------------------------------
327322

328323
public static String getGdbServerInterface() {
329-
String value = getString(PersistentPreferences.GDB_SERVER_INTERFACE, null);
330-
if (value != null) {
331-
return value;
332-
}
333-
return getString(JLINK_INTRFACE_DEPRECATED, SERVER_INTERFACE_DEFAULT);
324+
String value = getString(PersistentPreferences.GDB_SERVER_INTERFACE, SERVER_INTERFACE_DEFAULT);
325+
return value;
334326
}
335327

336328
public static boolean getJLinkEnableSemihosting() {
@@ -342,7 +334,7 @@ public static boolean getJLinkEnableSemihosting() {
342334
} catch (BackingStoreException e) {
343335
;
344336
}
345-
return getBoolean(JLINK_ENABLE_SEMIHOSTING_DEPRECATED, ENABLE_SEMIHOSTING_DEFAULT);
337+
return ENABLE_SEMIHOSTING_DEFAULT;
346338
}
347339

348340
public static boolean getJLinkEnableSwo() {
@@ -353,7 +345,7 @@ public static boolean getJLinkEnableSwo() {
353345
} catch (BackingStoreException e) {
354346
;
355347
}
356-
return getBoolean(JLINK_ENABLE_SWO_DEPRECATED, ENABLE_SWO_DEFAULT);
348+
return ENABLE_SWO_DEFAULT;
357349
}
358350

359351
// ------------------------------------------------------------------------

ilg.gnumcueclipse.debug.gdbjtag.jlink/src/ilg/gnumcueclipse/debug/gdbjtag/jlink/PersistentPreferences.java

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
package ilg.gnumcueclipse.debug.gdbjtag.jlink;
1313

14-
import org.eclipse.cdt.core.templateengine.SharedDefaults;
1514
import org.eclipse.core.runtime.Platform;
1615
import org.eclipse.core.runtime.preferences.InstanceScope;
1716
import org.osgi.service.prefs.BackingStoreException;
@@ -101,52 +100,39 @@ public class PersistentPreferences {
101100

102101
public static final String TAB_MAIN_CHECK_PROGRAM = "tab.main.checkProgram";
103102

104-
// TODO: remove DEPRECATED
105-
public static final String JLINK_GDBSERVER_DEPRECATED = "jlink_gdbserver";
106-
public static final String JLINK_PATH_DEPRECATED = "jlink_path";
107-
108103
// ----- Getters ----------------------------------------------------------
109104

110-
private static String getString(String id, String defaultValue) {
105+
private static String getString(String key, String defaultValue) {
111106

112107
String value;
113-
value = Platform.getPreferencesService().getString(Activator.PLUGIN_ID, id, null, null);
114-
// System.out.println("Value of " + id + " is " + value);
108+
value = Platform.getPreferencesService().getString(Activator.PLUGIN_ID, key, defaultValue, null);
115109

116-
if (value != null) {
117-
return value;
110+
if (Activator.getInstance().isDebugging()) {
111+
System.out.println("jlink.PersistentPreferences.getString(\"" + key + "\", \"" + defaultValue + "\") = \""
112+
+ value + "\"");
118113
}
119-
120-
// For compatibility reasons, still keep this for a while, on older
121-
// versions preferences were erroneously saved in the shared defaults.
122-
id = Activator.PLUGIN_ID + "." + id;
123-
124-
value = SharedDefaults.getInstance().getSharedDefaultsMap().get(id);
125-
126-
if (value == null)
127-
value = "";
128-
129-
value = value.trim();
130-
if (!value.isEmpty()) {
131-
return value;
132-
}
133-
134-
return defaultValue;
114+
return value;
135115
}
136116

137117
// ----- Setters ----------------------------------------------------------
138118

139-
private static void putWorkspaceString(String id, String value) {
119+
private static void putWorkspaceString(String key, String value) {
140120

121+
if (Activator.getInstance().isDebugging()) {
122+
System.out.println("jlink.PersistentPreferences.putWorkspaceString(\"" + key + "\", \"" + value + "\")");
123+
}
141124
value = value.trim();
142125

143126
// Access the instanceScope
144127
Preferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
145-
preferences.put(id, value);
128+
preferences.put(key, value);
146129
}
147130

148131
public static void flush() {
149132

133+
if (Activator.getInstance().isDebugging()) {
134+
System.out.println("jlink.PersistentPreferences.flush()");
135+
}
150136
try {
151137
InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).flush();
152138
} catch (BackingStoreException e) {

0 commit comments

Comments
 (0)