Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 54994 Details for
Bug 166660
[breakpoints] Debugger stops at breakpoint which is disabled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for 3.1 branch
patchForBreakpointsProblem.txt (text/plain), 32.16 KB, created by
Elena Laskavaia
on 2006-12-04 15:21:55 EST
(
hide
)
Description:
Patch for 3.1 branch
Filename:
MIME Type:
Creator:
Elena Laskavaia
Created:
2006-12-04 15:21:55 EST
Size:
32.16 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.debug.core >Index: cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIBreakpointManagement.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIBreakpointManagement.java,v >retrieving revision 1.5 >diff -u -r1.5 ICDIBreakpointManagement.java >--- cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIBreakpointManagement.java 23 Jun 2005 16:01:15 -0000 1.5 >+++ cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIBreakpointManagement.java 1 Dec 2006 20:45:26 -0000 >@@ -107,5 +107,13 @@ > */ > void deleteAllBreakpoints() throws CDIException; > >- >+ /** >+ * Massive breakpoint update >+ * @param breakpoints >+ * @param enable - enable[i] is enabled flag for breakpoints[i], if null - no change is required >+ * @param condition - condition[i] is condition for breakpoint[i], if null - no change is required >+ * @throws CDIException >+ */ >+ void updateBreakpoints(ICDIBreakpoint[] breakpoints, Boolean[] enable, ICDICondition condition[]) throws CDIException; >+ > } >Index: src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java,v >retrieving revision 1.59.2.3 >diff -u -r1.59.2.3 CBreakpointManager.java >--- src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java 26 Aug 2006 19:03:32 -0000 1.59.2.3 >+++ src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java 1 Dec 2006 20:45:26 -0000 >@@ -18,12 +18,14 @@ > import java.util.Arrays; > import java.util.HashMap; > import java.util.Iterator; >+import java.util.LinkedHashMap; > import java.util.List; > import java.util.Map; > import java.util.Set; > import org.eclipse.cdt.core.IAddress; > import org.eclipse.cdt.core.IAddressFactory; > import org.eclipse.cdt.debug.core.CDIDebugModel; >+import org.eclipse.cdt.debug.core.CDebugCorePlugin; > import org.eclipse.cdt.debug.core.CDebugUtils; > import org.eclipse.cdt.debug.core.cdi.CDIException; > import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation; >@@ -285,6 +287,7 @@ > cdiTarget.deleteBreakpoints( cdiBreakpoints ); > } > catch( CDIException e ) { >+ CDebugCorePlugin.log(e); > } > } > } ); >@@ -296,6 +299,7 @@ > public void breakpointsChanged( IBreakpoint[] breakpoints, IMarkerDelta[] deltas ) { > ArrayList removeList = new ArrayList( breakpoints.length ); > ArrayList installList = new ArrayList( breakpoints.length ); >+ LinkedHashMap changeList = new LinkedHashMap( breakpoints.length ); > synchronized ( getBreakpointMap() ) { > for ( int i = 0; i < breakpoints.length; ++i ) { > if ( !(breakpoints[i] instanceof ICBreakpoint) || !isTargetAvailable() ) >@@ -316,17 +320,68 @@ > if ( !registered && install ) { > installList.add( b ); > } >- } >- } >- breakpointsRemoved( (ICBreakpoint[])removeList.toArray( new ICBreakpoint[removeList.size()] ), new IMarkerDelta[0] ); >- breakpointsAdded( (ICBreakpoint[])installList.toArray( new ICBreakpoint[removeList.size()] ) ); >- for ( int i = 0; i < breakpoints.length; ++i ) { >- if ( breakpoints[i] instanceof ICBreakpoint && isTargetAvailable() ) >- changeBreakpointProperties( (ICBreakpoint)breakpoints[i], deltas[i] ); >- } >- } >+ Object res[] = new Object[2]; >+ if (getChangedBreakpointPropertiesFromDelta(b, deltas[i], res)) { >+ changeList.put(b,res); >+ } >+ } >+ } >+ if (isTargetAvailable()) { >+ breakpointsRemoved((ICBreakpoint[]) removeList.toArray(new ICBreakpoint[removeList >+ .size()]), new IMarkerDelta[0]); >+ breakpointsAdded((ICBreakpoint[]) installList.toArray(new ICBreakpoint[installList >+ .size()])); >+ breakpointsUpdate(changeList); >+ } >+ } >+ >+ private void breakpointsUpdate(Map changedMap) { >+ if (changedMap.size() == 0) >+ return; >+ if (!isTargetAvailable()) >+ return; >+ LinkedHashMap cdiMap = new LinkedHashMap(); >+ BreakpointMap breakpointMap = getBreakpointMap(); >+ synchronized (breakpointMap) { >+ for (Iterator iter = changedMap.keySet().iterator(); iter.hasNext();) { >+ ICBreakpoint cb = (ICBreakpoint) iter.next(); >+ Object obj = breakpointMap.get(cb); >+ ICDIBreakpoint b = null; >+ if (obj instanceof ICDIBreakpoint) { >+ b = (ICDIBreakpoint) obj; >+ } else if (obj instanceof BreakpointInProgess) { >+ b = ((BreakpointInProgess) obj).getCDIBreakpoint(); >+ } >+ if (b != null) { >+ cdiMap.put(b, changedMap.get(cb)); >+ } >+ } >+ } >+ if (cdiMap.isEmpty()) >+ return; >+ final ICDIBreakpoint[] cdiBreakpoints = (ICDIBreakpoint[]) cdiMap.keySet().toArray( >+ new ICDIBreakpoint[cdiMap.size()]); >+ final Boolean[] enableFlags = new Boolean[cdiBreakpoints.length]; >+ final ICDICondition[] conditions = new ICDICondition[cdiBreakpoints.length]; >+ for (int i = 0; i < cdiBreakpoints.length; i++) { >+ ICDIBreakpoint cdiB = cdiBreakpoints[i]; >+ Object changed[] = (Object[]) cdiMap.get(cdiB); >+ enableFlags[i] = (Boolean) changed[0]; >+ conditions[i] = (ICDICondition) changed[1]; >+ } >+ final ICDITarget cdiTarget = getCDITarget(); >+ DebugPlugin.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ try { >+ cdiTarget.updateBreakpoints(cdiBreakpoints, enableFlags, conditions); >+ } catch (CDIException e) { >+ CDebugCorePlugin.log(e); >+ } >+ } >+ }); >+ } > >- public void breakpointManagerEnablementChanged( boolean enabled ) { >+ public void breakpointManagerEnablementChanged( boolean enabled ) { > doSkipBreakpoints( !enabled ); > } > >@@ -553,6 +608,7 @@ > cdiTarget.deleteBreakpoints( cdiBreakpoints ); > } > catch( CDIException e ) { >+ CDebugCorePlugin.log(e); > } > } > } ); >@@ -629,10 +685,13 @@ > } > } > catch( CoreException e ) { >+ CDebugCorePlugin.log(e); > } > catch( NumberFormatException e ) { >+ CDebugCorePlugin.log(e); > } > catch( CDIException e ) { >+ CDebugCorePlugin.log(e); > } > } > } >@@ -765,44 +824,64 @@ > false ); > return watchpoint; > } >- >- private void changeBreakpointProperties( ICBreakpoint breakpoint, IMarkerDelta delta ) { >- ICDIBreakpoint cdiBreakpoint = null; >- synchronized( getBreakpointMap() ) { >- if ( !getBreakpointMap().isInProgress( breakpoint ) ) >- cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint ); >- } >- if ( cdiBreakpoint == null ) >- return; >- ICDITarget cdiTarget = getCDITarget(); >- try { >- boolean enabled = breakpoint.isEnabled(); >- boolean oldEnabled = ( delta != null ) ? delta.getAttribute( IBreakpoint.ENABLED, true ) : enabled; >- int ignoreCount = breakpoint.getIgnoreCount(); >- int oldIgnoreCount = ( delta != null ) ? delta.getAttribute( ICBreakpoint.IGNORE_COUNT, 0 ) : ignoreCount; >- String condition = breakpoint.getCondition(); >- String oldCondition = ( delta != null ) ? delta.getAttribute( ICBreakpoint.CONDITION, "" ) : condition; //$NON-NLS-1$ >- String[] newThreadIs = getThreadNames( breakpoint ); >- Boolean enabled0 = null; >- ICDICondition condition0 = null; >- if ( enabled != oldEnabled && enabled != cdiBreakpoint.isEnabled() ) { >- enabled0 = Boolean.valueOf( enabled ); >- } >- if ( ignoreCount != oldIgnoreCount || condition.compareTo( oldCondition ) != 0 || areThreadFiltersChanged( newThreadIs, cdiBreakpoint ) ) { >- ICDICondition cdiCondition = cdiTarget.createCondition( ignoreCount, condition, newThreadIs ); >- if ( !cdiCondition.equals( cdiBreakpoint.getCondition() ) ) { >- condition0 = cdiCondition; >- } >- } >- if ( enabled0 != null || condition0 != null ) { >- changeBreakpointPropertiesOnTarget( cdiBreakpoint, enabled0, condition0 ); >- } >- } >- catch( CoreException e ) { >- } >- catch( CDIException e ) { >- } >- } >+ /** >+ * @param breakpoint >+ * @param delta >+ * @param res - output result >+ * res[0] - set Boolean enabled result, or null if not changed >+ * res[1] - set ICDICondition condition, or null of condition not changed >+ * @return true if any changes required on target >+ */ >+ private boolean getChangedBreakpointPropertiesFromDelta( >+ ICBreakpoint breakpoint, >+ IMarkerDelta delta, >+ Object res[]) { >+ if (res==null || res.length!=2) throw new IllegalArgumentException("Must provide Object res[2] array for result set"); >+ res[0]=null; >+ res[1]=null; >+ Boolean enabled0 = null; >+ ICDICondition condition0 = null; >+ >+ ICDIBreakpoint cdiBreakpoint = null; >+ BreakpointMap breakpointMap = getBreakpointMap(); >+ synchronized( breakpointMap ) { >+ if ( !breakpointMap.isInProgress( breakpoint ) ) >+ cdiBreakpoint = breakpointMap.getCDIBreakpoint( breakpoint ); >+ } >+ if ( cdiBreakpoint == null ) >+ return false; // throw exception?? >+ >+ ICDITarget cdiTarget = getCDITarget(); >+ try { >+ boolean enabled = breakpoint.isEnabled(); >+ boolean oldEnabled = ( delta != null ) ? delta.getAttribute( IBreakpoint.ENABLED, true ) : enabled; >+ int ignoreCount = breakpoint.getIgnoreCount(); >+ int oldIgnoreCount = ( delta != null ) ? delta.getAttribute( ICBreakpoint.IGNORE_COUNT, 0 ) : ignoreCount; >+ String condition = breakpoint.getCondition(); >+ String oldCondition = ( delta != null ) ? delta.getAttribute( ICBreakpoint.CONDITION, "" ) : condition; //$NON-NLS-1$ >+ String[] newThreadIs = getThreadNames( breakpoint ); >+ >+ if ( enabled != oldEnabled && enabled != cdiBreakpoint.isEnabled() ) { >+ enabled0 = Boolean.valueOf( enabled ); >+ } >+ if ( ignoreCount != oldIgnoreCount || condition.compareTo( oldCondition ) != 0 || areThreadFiltersChanged( newThreadIs, cdiBreakpoint ) ) { >+ ICDICondition cdiCondition = cdiTarget.createCondition( ignoreCount, condition, newThreadIs ); >+ if ( !cdiCondition.equals( cdiBreakpoint.getCondition() ) ) { >+ condition0 = cdiCondition; >+ } >+ } >+ if ( enabled0 != null || condition0 != null ) { >+ res[0]=enabled0; >+ res[1]=condition0; >+ return true; >+ } >+ } >+ catch( CoreException e ) { >+ } >+ catch( CDIException e ) { >+ } >+ return false; >+ } > > private void changeBreakpointProperties( ICBreakpoint breakpoint, ICDIBreakpoint cdiBreakpoint ) { > Boolean enabled = null; >@@ -836,6 +915,7 @@ > breakpoint.setEnabled( enabled.booleanValue() ); > } > catch( CDIException e ) { >+ CDebugCorePlugin.log(e); > } > } > if ( condition != null ) { >@@ -843,6 +923,7 @@ > breakpoint.setCondition( condition ); > } > catch( CDIException e ) { >+ CDebugCorePlugin.log(e); > } > } > } >#P org.eclipse.cdt.debug.mi.core >Index: cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java,v >retrieving revision 1.39 >diff -u -r1.39 BreakpointManager.java >--- cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java 23 Jun 2006 17:25:38 -0000 1.39 >+++ cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java 1 Dec 2006 20:45:26 -0000 >@@ -17,7 +17,6 @@ > import java.util.HashMap; > import java.util.List; > import java.util.Map; >- > import org.eclipse.cdt.debug.core.cdi.CDIException; > import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation; > import org.eclipse.cdt.debug.core.cdi.ICDICondition; >@@ -32,6 +31,7 @@ > import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint; > import org.eclipse.cdt.debug.mi.core.MIException; > import org.eclipse.cdt.debug.mi.core.MIFormat; >+import org.eclipse.cdt.debug.mi.core.MIPlugin; > import org.eclipse.cdt.debug.mi.core.MISession; > import org.eclipse.cdt.debug.mi.core.cdi.model.AddressBreakpoint; > import org.eclipse.cdt.debug.mi.core.cdi.model.AddressLocation; >@@ -48,10 +48,10 @@ > import org.eclipse.cdt.debug.mi.core.command.MIBreakCondition; > import org.eclipse.cdt.debug.mi.core.command.MIBreakDelete; > import org.eclipse.cdt.debug.mi.core.command.MIBreakDisable; >-import org.eclipse.cdt.debug.mi.core.command.MIBreakEnable; > import org.eclipse.cdt.debug.mi.core.command.MIBreakInsert; > import org.eclipse.cdt.debug.mi.core.command.MIBreakList; > import org.eclipse.cdt.debug.mi.core.command.MIBreakWatch; >+import org.eclipse.cdt.debug.mi.core.command.MICommand; > import org.eclipse.cdt.debug.mi.core.command.MIGDBSetBreakpointPending; > import org.eclipse.cdt.debug.mi.core.event.MIBreakpointChangedEvent; > import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent; >@@ -198,57 +198,7 @@ > * @throws CDIException > */ > public void enableBreakpoint(Breakpoint breakpoint) throws CDIException { >- Target target = (Target)breakpoint.getTarget(); >- >- // Check if the breakpoint is in the deffered list >- List dList = (List)deferredMap.get(target); >- if (dList != null) { >- if (dList.contains(breakpoint)) { >- breakpoint.setEnabled0(true); >- return; // bail out here, our work is done. >- } >- } >- >- List bList = (List)breakMap.get(target); >- if (bList == null) { >- throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >- } >- if (!bList.contains(breakpoint)) { >- throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >- } >- MIBreakpoint[] miBreakpoints = breakpoint.getMIBreakpoints(); >- if (miBreakpoints == null || miBreakpoints.length == 0) { >- throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >- } >- >- int[] numbers = new int[miBreakpoints.length]; >- for (int i = 0; i < miBreakpoints.length; i++) { >- numbers[i] = miBreakpoints[i].getNumber(); >- } >- >- boolean restart = false; >- MISession miSession = target.getMISession(); >- CommandFactory factory = miSession.getCommandFactory(); >- MIBreakEnable breakEnable = factory.createMIBreakEnable(numbers); >- try { >- restart = suspendInferior(target); >- miSession.postCommand(breakEnable); >- MIInfo info = breakEnable.getMIInfo(); >- if (info == null) { >- throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ >- } >- } catch (MIException e) { >- throw new MI2CDIException(e); >- } finally { >- // Resume the program and enable events. >- resumeInferior(target, restart); >- } >- for (int i = 0; i < miBreakpoints.length; i++) { >- miBreakpoints[i].setEnabled(true); >- } >- breakpoint.setEnabled0(true); >- // Fire a changed Event. >- miSession.fireEvent(new MIBreakpointChangedEvent(miSession, numbers[0])); >+ setEnabled(breakpoint, true); > } > > /** >@@ -258,17 +208,41 @@ > * @throws CDIException > */ > public void disableBreakpoint(Breakpoint breakpoint) throws CDIException { >- Target target = (Target)breakpoint.getTarget(); >- >- // Check if the breakpoint is in the deffered list >+ setEnabled(breakpoint, false); >+ } >+ >+ /** >+ * Set breakpoint enable status on target >+ * @param breakpoint >+ * @param enabled >+ * @throws CDIException >+ */ >+ public void setEnabled(Breakpoint breakpoint, boolean enabled) throws CDIException { >+ Target target = (Target)breakpoint.getTarget(); >+ // Check if the breakpoint is in the deferred list > List dList = (List)deferredMap.get(target); > if (dList != null) { > if (dList.contains(breakpoint)) { >- breakpoint.setEnabled0(false); >+ breakpoint.setEnabled0(enabled); > return; // bail out here, our work is done. > } > } >+ checkBreakpointSanity(breakpoint); >+ >+ MIBreakpoint[] miBreakpoints = breakpoint.getMIBreakpoints(); >+ try { >+ setEnabledMIBreakpoints(target, miBreakpoints, enabled); >+ breakpoint.setEnabled0(enabled); >+ } finally { >+ // fire a change event, even if we did not set breakpoint on target, in this case >+ // ui would reflect actual state of breakpoint (i.e. if disable failed, it would re-enabled it) >+ MISession miSession = target.getMISession(); >+ miSession.fireEvent(new MIBreakpointChangedEvent(miSession, miBreakpoints[0].getNumber())); >+ } >+ } > >+ private void checkBreakpointSanity(Breakpoint breakpoint) throws CDIException { >+ Target target = (Target)breakpoint.getTarget(); > List bList = (List)breakMap.get(target); > if (bList == null) { > throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >@@ -276,39 +250,11 @@ > if (!bList.contains(breakpoint)) { > throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ > } >- >- MIBreakpoint[] miBreakpoints = breakpoint.getMIBreakpoints(); >- if (miBreakpoints == null || miBreakpoints.length == 0) { >- throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >- } >- int[] numbers = new int[miBreakpoints.length]; >- for (int i = 0; i < miBreakpoints.length; i++) { >- numbers[i] = miBreakpoints[i].getNumber(); >- } >- >- boolean restart = false; >- MISession miSession = target.getMISession(); >- CommandFactory factory = miSession.getCommandFactory(); >- MIBreakDisable breakDisable = factory.createMIBreakDisable(numbers); >- try { >- restart = suspendInferior(target); >- miSession.postCommand(breakDisable); >- MIInfo info = breakDisable.getMIInfo(); >- if (info == null) { >- throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ >- } >- } catch (MIException e) { >- throw new MI2CDIException(e); >- } finally { >- resumeInferior(target, restart); >- } >- for (int i = 0; i < miBreakpoints.length; i++) { >- miBreakpoints[i].setEnabled(false); >- } >- breakpoint.setEnabled0(false); >- // Fire a changed Event. >- miSession.fireEvent(new MIBreakpointChangedEvent(miSession, numbers[0])); >- } >+ MIBreakpoint[] miBreakpoints = breakpoint.getMIBreakpoints(); >+ if (miBreakpoints == null || miBreakpoints.length == 0) { >+ throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >+ } >+ } > > /** > * Use by the Breakpoint class, Breakpoint.setCondition(Condition cond) >@@ -481,9 +427,6 @@ > miSession.fireEvents(events); > } > >- /** >- * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#allowProgramInterruption() >- */ > public void allowProgramInterruption(boolean e) { > allowInterrupt = e; > } >@@ -514,9 +457,7 @@ > deleteBreakpoints(target, bps); > } > } >- /** >- * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteBreakpoint(ICDIBreakpoint) >- */ >+ > public void deleteBreakpoint(ICDIBreakpoint breakpoint) throws CDIException { > deleteBreakpoints((Target)breakpoint.getTarget(), new ICDIBreakpoint[] { breakpoint }); > } >@@ -537,20 +478,35 @@ > > MISession miSession = target.getMISession(); > List eventList = new ArrayList(breakpoints.length); >- for (int i = 0; i < breakpoints.length; i++) { >- if (!(dList != null && dList.remove(breakpoints[i]))) { >- MIBreakpoint[] miBreakpoints = ((Breakpoint)breakpoints[i]).getMIBreakpoints(); >- if (miBreakpoints.length > 0) { >- deleteMIBreakpoints(target, miBreakpoints); >- eventList.add(new MIBreakpointDeletedEvent(miSession, miBreakpoints[0].getNumber())); >- } >- } >- } >- MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]); >- miSession.fireEvents(events); >+ boolean restart = false; >+ try { >+ // suspend only ones for all breakpoints. Otherwise it does not always work on slow targets >+ // if target if suspended it would not suspend it again (inside deleteMIBreakpoint call inside) >+ restart = suspendInferior(target); >+ for (int i = 0; i < breakpoints.length; i++) { >+ if (!(dList != null && dList.remove(breakpoints[i]))) { >+ MIBreakpoint[] miBreakpoints = ((Breakpoint) breakpoints[i]).getMIBreakpoints(); >+ if (miBreakpoints.length > 0) { >+ try { >+ deleteMIBreakpoints(target, miBreakpoints); >+ eventList.add(new MIBreakpointDeletedEvent(miSession, miBreakpoints[0] >+ .getNumber())); >+ } catch (CDIException e) { >+ // FIXME: if we cannot delete breakpoint we should add it back! >+ MIPlugin.log(e); >+ } >+ } >+ } >+ } >+ } finally { >+ MIEvent[] events = (MIEvent[]) eventList.toArray(new MIEvent[0]); >+ miSession.fireEvents(events); >+ resumeInferior(target, restart); >+ } > } > >- void deleteMIBreakpoints(Target target, MIBreakpoint[] miBreakpoints) throws CDIException { >+ >+ void deleteMIBreakpoints(Target target, MIBreakpoint[] miBreakpoints) throws CDIException { > MISession miSession = target.getMISession(); > int[] numbers = new int[miBreakpoints.length]; > for (int i = 0; i < miBreakpoints.length; ++i) { >@@ -565,7 +521,7 @@ > } > } > >- void deleteMIBreakpoints(MISession miSession, int[] numbers) throws CDIException { >+ private void deleteMIBreakpoints(MISession miSession, int[] numbers) throws CDIException { > CommandFactory factory = miSession.getCommandFactory(); > MIBreakDelete breakDelete = factory.createMIBreakDelete(numbers); > try { >@@ -994,6 +950,7 @@ > tid = Integer.parseInt(threadId); > list.add(factory.createMIBreakInsert(temporary, hardware, exprCond, ignoreCount, line.toString(), tid)); > } catch (NumberFormatException e) { >+ MIPlugin.log(e); > } > } > } >@@ -1001,4 +958,122 @@ > } > return miBreakInserts; > } >+ /** >+ * Massive breakpoint update >+ * @param target >+ * @param breakpoints >+ * @param enabled - enabled[i] is enabled flag for breakpoints[i], if null - no change is required >+ * @param condition - condition[i] is condition for breakpoint[i], if null - no change is required >+ * @throws CDIException >+ */ >+ >+ public void updateBreakpoints(Target target, ICDIBreakpoint[] breakpoints, Boolean[] enabled, >+ ICDICondition[] condition) throws CDIException { >+ List bList = (List) breakMap.get(target); >+ // Do the sanity check first, we will accept all or none >+ if (bList == null) { >+ throw new CDIException(CdiResources >+ .getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >+ } >+ List dList = (List) deferredMap.get(target); >+ for (int i = 0; i < breakpoints.length; i++) { >+ ICDIBreakpoint breakpoint = breakpoints[i]; >+ if (!(breakpoint instanceof Breakpoint)) { >+ throw new CDIException(CdiResources >+ .getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >+ } >+ if (!(bList.contains(breakpoint) || (dList != null && dList.contains(breakpoint)))) { >+ throw new CDIException(CdiResources >+ .getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >+ } >+ MIBreakpoint[] miBreakpoints = ((Breakpoint) breakpoint).getMIBreakpoints(); >+ if (miBreakpoints == null || miBreakpoints.length == 0) { >+ throw new CDIException(CdiResources >+ .getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >+ } >+ } >+ // sanity is done >+ >+ // make working copy of breakpoints array >+ ICDIBreakpoint[] working = (ICDIBreakpoint[]) breakpoints.clone(); >+ // do deferred changes and prepare breakpoint list >+ boolean commandOnTarget = false; >+ for (int i = 0; i < breakpoints.length; i++) { >+ Breakpoint breakpoint = (Breakpoint) breakpoints[i]; // was checked before >+ if (dList != null) { >+ if (dList.contains(breakpoint)) { >+ if (enabled[i]!=null) { >+ breakpoint.setEnabled0(enabled[i].booleanValue()); >+ } >+ if (condition[i]!=null) { >+ breakpoint.setCondition0(condition[i]); >+ } >+ working[i]=null; >+ continue; >+ } >+ } >+ commandOnTarget = true; >+ } >+ if (commandOnTarget) { // at leak one element in working list is not null >+ boolean restart = false; >+ try { >+ // idea is to suspend only ones for massive breakpoints change >+ restart = suspendInferior(target); >+ for (int i = 0; i < working.length; i++) { >+ Breakpoint breakpoint = (Breakpoint) working[i]; >+ if (breakpoint == null) >+ continue; // was process before >+ try { >+ if (enabled[i] != null) { >+ boolean enabledFlag = enabled[i].booleanValue(); >+ setEnabled(breakpoint, enabledFlag); >+ } >+ if (condition[i] != null) { >+ setCondition(breakpoint, condition[i]); >+ } >+ } catch (CDIException e) { >+ MIPlugin.log(e); >+ } >+ } >+ } finally { >+ resumeInferior(target, restart); >+ } >+ } >+ } >+ >+ private void setEnabledMIBreakpoints(Target target, MIBreakpoint[] miBreakpoints, >+ boolean enabled) throws CDIException { >+ if (miBreakpoints == null || miBreakpoints.length == 0) { >+ throw new CDIException(CdiResources >+ .getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ >+ } >+ int[] numbers = new int[miBreakpoints.length]; >+ for (int i = 0; i < miBreakpoints.length; i++) { >+ numbers[i] = miBreakpoints[i].getNumber(); >+ } >+ MISession miSession = target.getMISession(); >+ CommandFactory factory = miSession.getCommandFactory(); >+ MICommand command; >+ if (enabled) { >+ command = factory.createMIBreakEnable(numbers); >+ } else { >+ command = factory.createMIBreakDisable(numbers); >+ } >+ boolean restart = false; >+ try { >+ restart = suspendInferior(target); >+ miSession.postCommand(command); >+ MIInfo info = command.getMIInfo(); >+ if (info == null) { >+ throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ >+ } >+ for (int i = 0; i < miBreakpoints.length; i++) { >+ miBreakpoints[i].setEnabled(enabled); >+ } >+ } catch (MIException e) { >+ throw new MI2CDIException(e); >+ } finally { >+ resumeInferior(target, restart); >+ } >+ } > } >Index: src/org/eclipse/cdt/debug/mi/core/MIPlugin.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java,v >retrieving revision 1.78.2.1 >diff -u -r1.78.2.1 MIPlugin.java >--- src/org/eclipse/cdt/debug/mi/core/MIPlugin.java 29 Nov 2006 01:33:04 -0000 1.78.2.1 >+++ src/org/eclipse/cdt/debug/mi/core/MIPlugin.java 1 Dec 2006 20:45:26 -0000 >@@ -19,6 +19,7 @@ > import java.util.Arrays; > import java.util.MissingResourceException; > import java.util.ResourceBundle; >+import org.eclipse.cdt.debug.core.CDIDebugModel; > import org.eclipse.cdt.debug.core.CDebugCorePlugin; > import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; > import org.eclipse.cdt.debug.core.ICDebugConfiguration; >@@ -33,9 +34,12 @@ > import org.eclipse.cdt.utils.pty.PTY; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.core.runtime.Plugin; > import org.eclipse.core.runtime.Preferences; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.core.DebugException; > import org.eclipse.debug.core.ILaunchConfiguration; > import org.osgi.framework.BundleContext; > >@@ -596,4 +600,42 @@ > } > return fCommandFactoryManager; > } >+ >+ public static final int INTERNAL_ERROR = 1001; >+ /** >+ * Logs the specified throwable with this plug-in's log. >+ * >+ * @param t throwable to log >+ */ >+ public static void log( Throwable t ) { >+ Throwable top = t; >+ if ( t instanceof DebugException ) { >+ DebugException de = (DebugException)t; >+ IStatus status = de.getStatus(); >+ if ( status.getException() != null ) { >+ top = status.getException(); >+ } >+ } >+ // this message is intentionally not internationalized, as an exception may >+ // be due to the resource bundle itself >+ log( new Status( IStatus.ERROR, getUniqueIdentifier(), INTERNAL_ERROR, "Internal error logged from CDI Debug: ", top ) ); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Logs the specified status with this plug-in's log. >+ * >+ * @param status status to log >+ */ >+ public static void log( IStatus status ) { >+ getDefault().getLog().log( status ); >+ } >+ >+ /** >+ * Logs the specified message with this plug-in's log. >+ * >+ * @param status status to log >+ */ >+ public static void log( String message ) { >+ getDefault().getLog().log( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), INTERNAL_ERROR, message, null ) ); >+ } > } >Index: cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java,v >retrieving revision 1.42.2.4 >diff -u -r1.42.2.4 Target.java >--- cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java 31 Aug 2006 14:18:03 -0000 1.42.2.4 >+++ cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java 1 Dec 2006 20:45:26 -0000 >@@ -922,6 +922,11 @@ > BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); > bMgr.deleteBreakpoints(this, breakpoints); > } >+ >+ public void updateBreakpoints(ICDIBreakpoint[] breakpoints, Boolean[] enable, ICDICondition condition[]) throws CDIException { >+ BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); >+ bMgr.updateBreakpoints(this, breakpoints, enable, condition); >+ } > > /* (non-Javadoc) > * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#deleteAllBreakpoints()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
bjorn.freeman-benson
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 166660
:
54994
|
86035
|
87098