mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +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:
parent
ece0987caf
commit
39c85abc38
11 changed files with 33 additions and 21 deletions
|
@ -236,8 +236,12 @@ public class MulticoreVisualizerUIPlugin extends AbstractUIPlugin
|
||||||
/** Returns resource manager for this plugin */
|
/** Returns resource manager for this plugin */
|
||||||
public UIResourceManager getPluginResources() {
|
public UIResourceManager getPluginResources() {
|
||||||
if (s_resources == null) {
|
if (s_resources == null) {
|
||||||
s_resources = new UIResourceManager(this);
|
// FindBugs reported that it is unsafe to set s_resources
|
||||||
s_resources.setParentManager(CDTVisualizerUIPlugin.getResources());
|
// 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;
|
return s_resources;
|
||||||
|
@ -245,7 +249,7 @@ public class MulticoreVisualizerUIPlugin extends AbstractUIPlugin
|
||||||
|
|
||||||
/** Releases resource manager for this plugin. */
|
/** Releases resource manager for this plugin. */
|
||||||
public void cleanupPluginResources() {
|
public void cleanupPluginResources() {
|
||||||
s_resources.dispose();
|
if (s_resources != null) s_resources.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convenience method for getting plugin resource manager */
|
/** Convenience method for getting plugin resource manager */
|
||||||
|
|
|
@ -69,6 +69,11 @@ public class VisualizerThread
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return m_pid ^ m_tid ^ m_gdbtid;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns string representation. */
|
/** Returns string representation. */
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -215,9 +215,9 @@ public class GdbPinProvider implements IPinProvider {
|
||||||
IDMContext dmc = null;
|
IDMContext dmc = null;
|
||||||
if (debugContext instanceof IAdaptable) {
|
if (debugContext instanceof IAdaptable) {
|
||||||
dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class);
|
dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class);
|
||||||
sessionId = dmc.getSessionId() + "."; //$NON-NLS-1$
|
|
||||||
|
|
||||||
if (dmc != null) {
|
if (dmc != null) {
|
||||||
|
sessionId = dmc.getSessionId() + "."; //$NON-NLS-1$
|
||||||
IMIExecutionDMContext execDmc = getExecutionDmc(dmc);
|
IMIExecutionDMContext execDmc = getExecutionDmc(dmc);
|
||||||
IProcessDMContext processDmc = getProcessDmc(dmc);
|
IProcessDMContext processDmc = getProcessDmc(dmc);
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,16 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.service.command.output;
|
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.ICommand;
|
||||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandResult;
|
import org.eclipse.cdt.dsf.debug.service.command.ICommandResult;
|
||||||
import org.eclipse.cdt.internal.core.ICoreInfo;
|
import org.eclipse.cdt.internal.core.ICoreInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result obtined from MIMetaGetCPUInfo.
|
* Result obtained from MIMetaGetCPUInfo.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public class MIMetaGetCPUInfoInfo implements ICommandResult {
|
public class MIMetaGetCPUInfoInfo implements ICommandResult {
|
||||||
|
|
||||||
private final ICoreInfo[] fCoresInfo;
|
private final ICoreInfo[] fCoresInfo;
|
||||||
|
@ -36,6 +37,6 @@ public class MIMetaGetCPUInfoInfo implements ICommandResult {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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$
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -65,7 +65,6 @@ import org.osgi.framework.BundleContext;
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public class GDBHardwareAndOS extends AbstractDsfService implements IGDBHardwareAndOS, ICachingService {
|
public class GDBHardwareAndOS extends AbstractDsfService implements IGDBHardwareAndOS, ICachingService {
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
|
|
|
@ -256,7 +256,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints, I
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return baseEquals(obj) && (fReference == ((MIBreakpointDMContext) obj).fReference);
|
return baseEquals(obj) && (fReference.equals(((MIBreakpointDMContext)obj).fReference));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -399,7 +399,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
return super.baseEquals(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
|
@Override
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -814,7 +815,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
||||||
} catch(IllegalArgumentException e2) {
|
} catch(IllegalArgumentException e2) {
|
||||||
// Message format string invalid. Fallback to just appending the strings.
|
// Message format string invalid. Fallback to just appending the strings.
|
||||||
clientMsg.append(message);
|
clientMsg.append(message);
|
||||||
clientMsg.append(parameters);
|
clientMsg.append(Arrays.toString(parameters));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clientMsg.append(message);
|
clientMsg.append(message);
|
||||||
|
@ -865,7 +866,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
||||||
} catch(IllegalArgumentException e2) {
|
} catch(IllegalArgumentException e2) {
|
||||||
// Message format string invalid. Fallback to just appending the strings.
|
// Message format string invalid. Fallback to just appending the strings.
|
||||||
clientMsg.append(message);
|
clientMsg.append(message);
|
||||||
clientMsg.append(parameters);
|
clientMsg.append(Arrays.toString(parameters));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clientMsg.append(message);
|
clientMsg.append(message);
|
||||||
|
|
|
@ -36,12 +36,7 @@ public class CLITraceDumpInfo extends MIInfo {
|
||||||
// tdump parsed info
|
// tdump parsed info
|
||||||
private String fTracepointNum = null;
|
private String fTracepointNum = null;
|
||||||
private String fTraceFrameNumber = 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
|
// keep the tdump header in parsed result or not - by default we keep
|
||||||
private static final boolean KEEP_HEADER = true;
|
private static final boolean KEEP_HEADER = true;
|
||||||
|
|
||||||
|
@ -156,7 +151,9 @@ public class CLITraceDumpInfo extends MIInfo {
|
||||||
* @return the timestamp of the tracepoint frame
|
* @return the timestamp of the tracepoint frame
|
||||||
*/
|
*/
|
||||||
public String getTimestamp() {
|
public String getTimestamp() {
|
||||||
return timestamp;
|
// Timestamp not yet available in printout of command
|
||||||
|
// "tdump" -> revisit when it is.
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,7 @@ public class CLITraceInfo extends MIInfo {
|
||||||
for (int i = 0; i < oobs.length; i++) {
|
for (int i = 0; i < oobs.length; i++) {
|
||||||
if (oobs[i] instanceof MIConsoleStreamOutput) {
|
if (oobs[i] instanceof MIConsoleStreamOutput) {
|
||||||
MIStreamRecord cons = (MIStreamRecord) oobs[i];
|
MIStreamRecord cons = (MIStreamRecord) oobs[i];
|
||||||
String str = cons.getString();
|
String str = cons.getString().trim();
|
||||||
str.trim();
|
|
||||||
if(str.length() > 0 ){
|
if(str.length() > 0 ){
|
||||||
Pattern pattern = Pattern.compile("^Tracepoint\\s(\\d+)", Pattern.MULTILINE); //$NON-NLS-1$
|
Pattern pattern = Pattern.compile("^Tracepoint\\s(\\d+)", Pattern.MULTILINE); //$NON-NLS-1$
|
||||||
Matcher matcher = pattern.matcher(str);
|
Matcher matcher = pattern.matcher(str);
|
||||||
|
|
|
@ -180,6 +180,9 @@ public class MIParser {
|
||||||
case '=' :
|
case '=' :
|
||||||
async = new MINotifyAsyncOutput();
|
async = new MINotifyAsyncOutput();
|
||||||
break;
|
break;
|
||||||
|
default :
|
||||||
|
assert false;
|
||||||
|
async = new MINotifyAsyncOutput();
|
||||||
}
|
}
|
||||||
async.setToken(id);
|
async.setToken(id);
|
||||||
// Extract the Async-Class
|
// Extract the Async-Class
|
||||||
|
@ -212,6 +215,9 @@ public class MIParser {
|
||||||
case '&' :
|
case '&' :
|
||||||
stream = new MILogStreamOutput();
|
stream = new MILogStreamOutput();
|
||||||
break;
|
break;
|
||||||
|
default :
|
||||||
|
assert false;
|
||||||
|
stream = new MIConsoleStreamOutput();
|
||||||
}
|
}
|
||||||
// translateCString() assumes that the leading " is deleted
|
// translateCString() assumes that the leading " is deleted
|
||||||
if (buffer.length() > 0 && buffer.charAt(0) == '"') {
|
if (buffer.length() > 0 && buffer.charAt(0) == '"') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue