1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 08:46:02 +02:00

Bug 379225: Address FindBugs issues for DSF-GDB

Change-Id: I56b03d7eeae586d66788bd29bc54416c78479add
Reviewed-on: https://git.eclipse.org/r/5947
Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com>
IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com>
Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
Marc Khouzam 2012-05-11 11:03:16 -04:00
parent ece0987caf
commit 39c85abc38
11 changed files with 33 additions and 21 deletions

View file

@ -236,8 +236,12 @@ public class MulticoreVisualizerUIPlugin extends AbstractUIPlugin
/** Returns resource manager for this plugin */
public UIResourceManager getPluginResources() {
if (s_resources == null) {
s_resources = new UIResourceManager(this);
s_resources.setParentManager(CDTVisualizerUIPlugin.getResources());
// FindBugs reported that it is unsafe to set s_resources
// before we finish to initialize the object, because of
// multi-threading. This is why we use a temporary variable.
UIResourceManager resourceManager = new UIResourceManager(this);
resourceManager.setParentManager(CDTVisualizerUIPlugin.getResources());
s_resources = resourceManager;
}
return s_resources;
@ -245,7 +249,7 @@ public class MulticoreVisualizerUIPlugin extends AbstractUIPlugin
/** Releases resource manager for this plugin. */
public void cleanupPluginResources() {
s_resources.dispose();
if (s_resources != null) s_resources.dispose();
}
/** Convenience method for getting plugin resource manager */

View file

@ -69,6 +69,11 @@ public class VisualizerThread
return result;
}
@Override
public int hashCode() {
return m_pid ^ m_tid ^ m_gdbtid;
}
/** Returns string representation. */
@Override
public String toString() {

View file

@ -215,9 +215,9 @@ public class GdbPinProvider implements IPinProvider {
IDMContext dmc = null;
if (debugContext instanceof IAdaptable) {
dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class);
sessionId = dmc.getSessionId() + "."; //$NON-NLS-1$
if (dmc != null) {
sessionId = dmc.getSessionId() + "."; //$NON-NLS-1$
IMIExecutionDMContext execDmc = getExecutionDmc(dmc);
IProcessDMContext processDmc = getProcessDmc(dmc);

View file

@ -10,15 +10,16 @@
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.service.command.output;
import java.util.Arrays;
import org.eclipse.cdt.dsf.debug.service.command.ICommand;
import org.eclipse.cdt.dsf.debug.service.command.ICommandResult;
import org.eclipse.cdt.internal.core.ICoreInfo;
/**
* Result obtined from MIMetaGetCPUInfo.
* Result obtained from MIMetaGetCPUInfo.
* @since 4.1
*/
@SuppressWarnings("restriction")
public class MIMetaGetCPUInfoInfo implements ICommandResult {
private final ICoreInfo[] fCoresInfo;
@ -36,6 +37,6 @@ public class MIMetaGetCPUInfoInfo implements ICommandResult {
@Override
public String toString() {
return getClass().getSimpleName() + " (" + getInfo() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
return getClass().getSimpleName() + " (" + Arrays.toString(getInfo()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
}

View file

@ -65,7 +65,6 @@ import org.osgi.framework.BundleContext;
*
* @since 4.1
*/
@SuppressWarnings("restriction")
public class GDBHardwareAndOS extends AbstractDsfService implements IGDBHardwareAndOS, ICachingService {
@Immutable

View file

@ -256,7 +256,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints, I
*/
@Override
public boolean equals(Object obj) {
return baseEquals(obj) && (fReference == ((MIBreakpointDMContext) obj).fReference);
return baseEquals(obj) && (fReference.equals(((MIBreakpointDMContext)obj).fReference));
}
/* (non-Javadoc)

View file

@ -399,7 +399,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
@Override
public boolean equals(Object other) {
return super.baseEquals(other) &&
expression == null ? ((InvalidContextExpressionDMC) other).getExpression() == null : expression.equals(((InvalidContextExpressionDMC) other).getExpression());
(expression == null ? ((InvalidContextExpressionDMC) other).getExpression() == null : expression.equals(((InvalidContextExpressionDMC) other).getExpression()));
}
@Override

View file

@ -20,6 +20,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
@ -814,7 +815,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
} catch(IllegalArgumentException e2) {
// Message format string invalid. Fallback to just appending the strings.
clientMsg.append(message);
clientMsg.append(parameters);
clientMsg.append(Arrays.toString(parameters));
}
} else {
clientMsg.append(message);
@ -865,7 +866,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
} catch(IllegalArgumentException e2) {
// Message format string invalid. Fallback to just appending the strings.
clientMsg.append(message);
clientMsg.append(parameters);
clientMsg.append(Arrays.toString(parameters));
}
} else {
clientMsg.append(message);

View file

@ -36,12 +36,7 @@ public class CLITraceDumpInfo extends MIInfo {
// tdump parsed info
private String fTracepointNum = null;
private String fTraceFrameNumber = null;
/*
* Timestamp, if present in tracepoint frame data
* Note: not yet available in printout of command
* "tdump" -> revisit when it is.
*/
private String timestamp = null;
// keep the tdump header in parsed result or not - by default we keep
private static final boolean KEEP_HEADER = true;
@ -156,7 +151,9 @@ public class CLITraceDumpInfo extends MIInfo {
* @return the timestamp of the tracepoint frame
*/
public String getTimestamp() {
return timestamp;
// Timestamp not yet available in printout of command
// "tdump" -> revisit when it is.
return null;
}
}

View file

@ -41,8 +41,7 @@ public class CLITraceInfo extends MIInfo {
for (int i = 0; i < oobs.length; i++) {
if (oobs[i] instanceof MIConsoleStreamOutput) {
MIStreamRecord cons = (MIStreamRecord) oobs[i];
String str = cons.getString();
str.trim();
String str = cons.getString().trim();
if(str.length() > 0 ){
Pattern pattern = Pattern.compile("^Tracepoint\\s(\\d+)", Pattern.MULTILINE); //$NON-NLS-1$
Matcher matcher = pattern.matcher(str);

View file

@ -180,6 +180,9 @@ public class MIParser {
case '=' :
async = new MINotifyAsyncOutput();
break;
default :
assert false;
async = new MINotifyAsyncOutput();
}
async.setToken(id);
// Extract the Async-Class
@ -212,6 +215,9 @@ public class MIParser {
case '&' :
stream = new MILogStreamOutput();
break;
default :
assert false;
stream = new MIConsoleStreamOutput();
}
// translateCString() assumes that the leading " is deleted
if (buffer.length() > 0 && buffer.charAt(0) == '"') {