From 1802824b5f2cd34541dbf750d4bce2fb3cdb8060 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 23 Apr 2004 00:14:53 +0000 Subject: [PATCH] Additional fix for bug 58711: Breakpoint race condition. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 4 +++ .../internal/core/CBreakpointManager.java | 36 ++++++++++++------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 93f2f6afaf0..9af3280828d 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,7 @@ +2004-04-15 Mikhail Khodjaiants + Additional fix for bug 58711: Breakpoint race condition. + * CBreakpointManager.java + 2004-04-21 Mikhail Khodjaiants Disassembly should provide an adapter for IExecFialeInfo. * Disassembly.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java index 444302928e4..a56bbd57eca 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java @@ -449,40 +449,52 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable { } } - private synchronized ICDIBreakpoint setFunctionBreakpoint( ICFunctionBreakpoint breakpoint ) throws CDIException, CoreException { + private ICDIBreakpoint setFunctionBreakpoint( ICFunctionBreakpoint breakpoint ) throws CDIException, CoreException { ICDIBreakpointManager bm = getCDIBreakpointManager(); String function = breakpoint.getFunction(); String fileName = (function != null && function.indexOf( "::" ) == -1) ? breakpoint.getFileName() : null; //$NON-NLS-1$ ICDILocation location = bm.createLocation( fileName, function, -1 ); - ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); - getBreakpointMap().put( breakpoint, cdiBreakpoint ); + ICDIBreakpoint cdiBreakpoint = null; + synchronized ( getBreakpointMap() ) { + cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); + getBreakpointMap().put( breakpoint, cdiBreakpoint ); + } return cdiBreakpoint; } - private synchronized ICDIBreakpoint setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException, NumberFormatException { + private ICDIBreakpoint setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException, NumberFormatException { ICDIBreakpointManager bm = getCDIBreakpointManager(); ICDILocation location = bm.createLocation( Long.parseLong( breakpoint.getAddress() ) ); - ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); - getBreakpointMap().put( breakpoint, cdiBreakpoint ); + ICDIBreakpoint cdiBreakpoint = null; + synchronized ( getBreakpointMap() ) { + cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); + getBreakpointMap().put( breakpoint, cdiBreakpoint ); + } return cdiBreakpoint; } - private synchronized ICDIBreakpoint setLineBreakpoint( ICLineBreakpoint breakpoint ) throws CDIException, CoreException { + private ICDIBreakpoint setLineBreakpoint( ICLineBreakpoint breakpoint ) throws CDIException, CoreException { ICDIBreakpointManager bm = getCDIBreakpointManager(); ICDILocation location = bm.createLocation( breakpoint.getMarker().getResource().getLocation().lastSegment(), null, breakpoint.getLineNumber() ); - ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); - getBreakpointMap().put( breakpoint, cdiBreakpoint ); + ICDIBreakpoint cdiBreakpoint = null; + synchronized ( getBreakpointMap() ) { + cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); + getBreakpointMap().put( breakpoint, cdiBreakpoint ); + } return cdiBreakpoint; } - private synchronized ICDIBreakpoint setWatchpoint( ICWatchpoint watchpoint ) throws CDIException, CoreException { + private ICDIBreakpoint setWatchpoint( ICWatchpoint watchpoint ) throws CDIException, CoreException { ICDIBreakpointManager bm = getCDIBreakpointManager(); int accessType = 0; accessType |= (watchpoint.isWriteType()) ? ICDIWatchpoint.WRITE : 0; accessType |= (watchpoint.isReadType()) ? ICDIWatchpoint.READ : 0; String expression = watchpoint.getExpression(); - ICDIWatchpoint cdiWatchpoint = bm.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, null ); - getBreakpointMap().put( watchpoint, cdiWatchpoint ); + ICDIWatchpoint cdiWatchpoint = null; + synchronized ( getBreakpointMap() ) { + cdiWatchpoint = bm.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, null ); + getBreakpointMap().put( watchpoint, cdiWatchpoint ); + } return cdiWatchpoint; }