mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 12:25:35 +02:00
Bug 444636- Make CBreakpointGdbThreadsFilterExtension thread-safe
Change-Id: Ied036bba57e3f2c2eca00e791735212b3dc107e5 Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/33727 Tested-by: Hudson CI Reviewed-by: Alvaro Sanchez-Leon <alvsan09@gmail.com>
This commit is contained in:
parent
0c0b6ef6ff
commit
db67b263b9
1 changed files with 17 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2011 Wind River Systems and others.
|
* Copyright (c) 2007, 2014 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,10 +7,13 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
|
* Ericsson - Make the class thread-safe as it can be accessed by multiple
|
||||||
|
* DSF debug sessions at the same time (bug 444636)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.breakpoints;
|
package org.eclipse.cdt.dsf.gdb.breakpoints;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -28,8 +31,8 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExtension {
|
public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExtension {
|
||||||
|
|
||||||
private Map<IContainerDMContext,Set<IExecutionDMContext>> fFilteredThreadsByTarget =
|
private final Map<IContainerDMContext,Set<IExecutionDMContext>> fFilteredThreadsByTarget =
|
||||||
new HashMap<IContainerDMContext,Set<IExecutionDMContext>>(1);
|
Collections.synchronizedMap(new HashMap<IContainerDMContext,Set<IExecutionDMContext>>(1));
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.core.model.ICBreakpointExtension#initialize(org.eclipse.cdt.debug.core.model.ICBreakpoint)
|
* @see org.eclipse.cdt.debug.core.model.ICBreakpointExtension#initialize(org.eclipse.cdt.debug.core.model.ICBreakpoint)
|
||||||
|
@ -43,8 +46,10 @@ public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExten
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IContainerDMContext[] getTargetFilters() throws CoreException {
|
public IContainerDMContext[] getTargetFilters() throws CoreException {
|
||||||
Set<IContainerDMContext> set = fFilteredThreadsByTarget.keySet();
|
Set<IContainerDMContext> set = fFilteredThreadsByTarget.keySet();
|
||||||
return set.toArray( new IContainerDMContext[set.size()] );
|
synchronized (fFilteredThreadsByTarget) {
|
||||||
|
return set.toArray(new IContainerDMContext[set.size()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -61,9 +66,7 @@ public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExten
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeTargetFilter( IContainerDMContext target ) throws CoreException {
|
public void removeTargetFilter( IContainerDMContext target ) throws CoreException {
|
||||||
if ( fFilteredThreadsByTarget.containsKey( target ) ) {
|
fFilteredThreadsByTarget.remove(target);
|
||||||
fFilteredThreadsByTarget.remove( target );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -73,14 +76,12 @@ public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExten
|
||||||
public void removeThreadFilters( IExecutionDMContext[] threads ) throws CoreException {
|
public void removeThreadFilters( IExecutionDMContext[] threads ) throws CoreException {
|
||||||
if ( threads != null && threads.length > 0 ) {
|
if ( threads != null && threads.length > 0 ) {
|
||||||
IContainerDMContext target = DMContexts.getAncestorOfType(threads[0], IContainerDMContext.class);
|
IContainerDMContext target = DMContexts.getAncestorOfType(threads[0], IContainerDMContext.class);
|
||||||
if ( fFilteredThreadsByTarget.containsKey( target ) ) {
|
Set<IExecutionDMContext> set = fFilteredThreadsByTarget.get( target );
|
||||||
Set<IExecutionDMContext> set = fFilteredThreadsByTarget.get( target );
|
if ( set != null ) {
|
||||||
if ( set != null ) {
|
set.removeAll( Arrays.asList( threads ) );
|
||||||
set.removeAll( Arrays.asList( threads ) );
|
if ( set.isEmpty() ) {
|
||||||
if ( set.isEmpty() ) {
|
fFilteredThreadsByTarget.remove( target );
|
||||||
fFilteredThreadsByTarget.remove( target );
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue