Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2012-05-23 16:02:47 -0400
committerGerrit Code Review @ Eclipse.org2017-03-23 13:59:28 -0400
commita66ccee4f0c5356af2aef8dde72c613249d35d57 (patch)
treef44cfc64d70855a0bfb3c205baa79fbe47467261 /dsf-gdb
parentbe16270d15b626dcb5b9886b1161a1233d076922 (diff)
downloadorg.eclipse.cdt-a66ccee4f0c5356af2aef8dde72c613249d35d57.tar.gz
org.eclipse.cdt-a66ccee4f0c5356af2aef8dde72c613249d35d57.tar.xz
org.eclipse.cdt-a66ccee4f0c5356af2aef8dde72c613249d35d57.zip
Bug 379225: Address FindBugs issues for DSF-GDB
Diffstat (limited to 'dsf-gdb')
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java14
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java34
2 files changed, 32 insertions, 16 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java
index 8c8d6e3630..5f20ce05de 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java
@@ -242,6 +242,20 @@ public class MIBreakpointDMData implements IBreakpointDMData {
public boolean equals(MIBreakpointDMData other) {
return (fNature == other.fNature) && (fProperties.equals(other.fProperties));
}
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) return true;
+ if (!(other instanceof MIBreakpointDMData)) return false;
+ MIBreakpointDMData bpData = (MIBreakpointDMData)other;
+
+ return (fNature == bpData.fNature) && (fProperties.equals(bpData.fProperties));
+ }
+
+ @Override
+ public int hashCode() {
+ return fNature.hashCode() ^ fProperties.hashCode();
+ }
///////////////////////////////////////////////////////////////////////////
// IBreakpointDMData
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java
index f6a012526c..f1c34df49e 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java
@@ -278,20 +278,13 @@ public abstract class AbstractMIControl extends AbstractDsfService
commandHandle.getRequestMonitor().setStatus(genStatus("Connection is shut down")); //$NON-NLS-1$
commandHandle.getRequestMonitor().done();
}
- fCommandQueue.clear();
+ fCommandQueue.clear();
/*
* Now go through the commands which are outstanding in that they have been sent to the backend.
*/
- synchronized(fRxCommands) {
- for (CommandHandle commandHandle : fRxCommands.values()) {
- if (commandHandle.getRequestMonitor() == null) continue;
- commandHandle.getRequestMonitor().setStatus(genStatus( "Connection is shut down")); //$NON-NLS-1$
- commandHandle.getRequestMonitor().done();
- }
- fRxCommands.clear();
- }
-
+ cancelRxCommands();
+
/*
* Now handle any requests which have not been transmitted, but weconsider them handed off.
*/
@@ -307,6 +300,15 @@ public abstract class AbstractMIControl extends AbstractDsfService
fTxCommands.add(fTerminatorHandle);
}
+ private synchronized void cancelRxCommands() {
+ for (CommandHandle commandHandle : fRxCommands.values()) {
+ if (commandHandle.getRequestMonitor() == null) continue;
+ commandHandle.getRequestMonitor().setStatus(genStatus( "Connection is shut down")); //$NON-NLS-1$
+ commandHandle.getRequestMonitor().done();
+ }
+ fRxCommands.clear();
+ }
+
/**
* Queues the given MI command to be sent to the debugger back end.
*
@@ -621,10 +623,6 @@ public abstract class AbstractMIControl extends AbstractDsfService
while (true) {
CommandHandle commandHandle = null;
- /*
- * Note: Acquiring locks for both fRxCommands and fTxCommands collections.
- */
- synchronized(fTxCommands) {
try {
commandHandle = fTxCommands.take();
} catch (InterruptedException e) {
@@ -632,7 +630,12 @@ public abstract class AbstractMIControl extends AbstractDsfService
}
if (commandHandle == fTerminatorHandle) {
-
+ // There is a small possibility that a new command was inserted
+ // in the fRxCommands map after we cleared that map.
+ // Just to be safe, clear it again.
+ // We do this to avoid synchronizing the handling of fRxCommands
+ // because this is more efficient, as it happens only once at shutdown.
+ cancelRxCommands();
break; // Null command is an indicator that we're shutting down.
}
@@ -643,7 +646,6 @@ public abstract class AbstractMIControl extends AbstractDsfService
// RawCommands will not get an answer, so we cannot put them in the receive queue.
fRxCommands.put(commandHandle.getTokenId(), commandHandle);
}
- }
/*
* Construct the new command and push this command out the pipeline.

Back to the top