diff options
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_7.java')
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_7.java | 194 |
1 files changed, 96 insertions, 98 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_7.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_7.java index 0d7039084f5..02761b5b580 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_7.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_7.java @@ -41,11 +41,11 @@ import org.eclipse.core.runtime.Status; /** * Breakpoints service for GDB 7.7. * This version supports dynamic printf - * + * * @since 4.4 */ public class GDBBreakpoints_7_7 extends GDBBreakpoints_7_6 { - + private IMICommandControl fConnection; private IMIRunControl fRunControl; private CommandFactory fCommandFactory; @@ -71,18 +71,15 @@ public class GDBBreakpoints_7_7 extends GDBBreakpoints_7_6 { rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, "Service is not available")); //$NON-NLS-1$ return; } - + fCommandFactory = fConnection.getCommandFactory(); - + // Register this service - register(new String[] { IBreakpoints.class.getName(), - IBreakpointsExtension.class.getName(), - MIBreakpoints.class.getName(), - GDBBreakpoints_7_0.class.getName(), - GDBBreakpoints_7_2.class.getName(), - GDBBreakpoints_7_4.class.getName(), - GDBBreakpoints_7_6.class.getName(), - GDBBreakpoints_7_7.class.getName() }, + register( + new String[] { IBreakpoints.class.getName(), IBreakpointsExtension.class.getName(), + MIBreakpoints.class.getName(), GDBBreakpoints_7_0.class.getName(), + GDBBreakpoints_7_2.class.getName(), GDBBreakpoints_7_4.class.getName(), + GDBBreakpoints_7_6.class.getName(), GDBBreakpoints_7_7.class.getName() }, new Hashtable<String, String>()); rm.done(); @@ -90,44 +87,37 @@ public class GDBBreakpoints_7_7 extends GDBBreakpoints_7_6 { @Override public void shutdown(RequestMonitor requestMonitor) { - unregister(); + unregister(); super.shutdown(requestMonitor); } @Override - protected void addDynamicPrintf( - final IBreakpointsTargetDMContext context, - final Map<String, Object> attributes, + protected void addDynamicPrintf(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm) { final MIBreakpointsSynchronizer bs = getServicesTracker().getService(MIBreakpointsSynchronizer.class); if (bs != null) { - // Skip the dprintf set from the console or from outside of Eclipse + // Skip the dprintf set from the console or from outside of Eclipse // because they are already installed on the target. - bs.getTargetBreakpoint( - context, - attributes, - new DataRequestMonitor<MIBreakpoint>(getExecutor(), drm) { - @Override - @ConfinedToDsfExecutor( "fExecutor" ) - protected void handleSuccess() { - MIBreakpoint miBpt = getData(); - if (miBpt != null) { - bs.removeCreatedTargetBreakpoint(context, miBpt); - MIBreakpointDMData newBreakpoint = createMIBreakpointDMData(miBpt); - getBreakpointMap(context).put(newBreakpoint.getNumber(), newBreakpoint); - IBreakpointDMContext dmc = - new MIBreakpointDMContext(GDBBreakpoints_7_7.this, new IDMContext[] { context }, newBreakpoint.getNumber()); - drm.setData(dmc); - getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties()); - drm.done(); - } - else { - doAddDynamicPrintf(context, attributes, drm); - } - } - }); - } - else { + bs.getTargetBreakpoint(context, attributes, new DataRequestMonitor<MIBreakpoint>(getExecutor(), drm) { + @Override + @ConfinedToDsfExecutor("fExecutor") + protected void handleSuccess() { + MIBreakpoint miBpt = getData(); + if (miBpt != null) { + bs.removeCreatedTargetBreakpoint(context, miBpt); + MIBreakpointDMData newBreakpoint = createMIBreakpointDMData(miBpt); + getBreakpointMap(context).put(newBreakpoint.getNumber(), newBreakpoint); + IBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_7.this, + new IDMContext[] { context }, newBreakpoint.getNumber()); + drm.setData(dmc); + getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties()); + drm.done(); + } else { + doAddDynamicPrintf(context, attributes, drm); + } + } + }); + } else { doAddDynamicPrintf(context, attributes, drm); } } @@ -135,73 +125,81 @@ public class GDBBreakpoints_7_7 extends GDBBreakpoints_7_6 { /** * Add a Dynamic Printf. */ - protected void doAddDynamicPrintf(final IBreakpointsTargetDMContext context, Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> finalRm) - { + protected void doAddDynamicPrintf(final IBreakpointsTargetDMContext context, Map<String, Object> attributes, + final DataRequestMonitor<IBreakpointDMContext> finalRm) { // Select the context breakpoints map final Map<String, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context); if (contextBreakpoints == null) { - finalRm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null)); + finalRm.done( + new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null)); return; } // Extract the relevant parameters (providing default values to avoid potential NPEs) final String location = formatLocation(attributes); if (location.equals(NULL_STRING)) { - finalRm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null)); + finalRm.done( + new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null)); return; } - final String printfStr = (String) getProperty(attributes, MIBreakpoints.PRINTF_STRING, ""); //$NON-NLS-1$ - final Boolean enabled = (Boolean) getProperty(attributes, MIBreakpoints.IS_ENABLED, true); - final Boolean isTemporary = (Boolean) getProperty(attributes, MIBreakpointDMData.IS_TEMPORARY, false); - final String condition = (String) getProperty(attributes, MIBreakpoints.CONDITION, NULL_STRING); - final Integer ignoreCount = (Integer) getProperty(attributes, MIBreakpoints.IGNORE_COUNT, 0); - String threadId = (String) getProperty(attributes, MIBreakpointDMData.THREAD_ID, "0"); //$NON-NLS-1$ - final int tid = Integer.parseInt(threadId); - - final Step insertDPrintf = new Step() { - @Override - public void execute(final RequestMonitor rm) { - // Execute the command - fConnection.queueCommand( - fCommandFactory.createMIDPrintfInsert(context, isTemporary, condition, ignoreCount, tid, !enabled, location, printfStr), - new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), rm) { - @Override - protected void handleSuccess() { - - // With MI, an invalid location won't generate an error - if (getData().getMIBreakpoints().length == 0) { - rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, DYNAMIC_PRINTF_INSERTION_FAILURE, null)); - return; - } - - // Create a breakpoint object and store it in the map - final MIBreakpointDMData newBreakpoint = createMIBreakpointDMData(getData().getMIBreakpoints()[0]); - String reference = newBreakpoint.getNumber(); - if (reference.isEmpty()) { - rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, DYNAMIC_PRINTF_INSERTION_FAILURE, null)); - return; - } - contextBreakpoints.put(reference, newBreakpoint); - - // Format the return value - MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_7.this, new IDMContext[] { context }, reference); - finalRm.setData(dmc); - - // Flag the event - getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties()); - - rm.done(); - } - - @Override - protected void handleError() { - rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, DYNAMIC_PRINTF_INSERTION_FAILURE, getStatus().getException())); - } - }); - } - }; - - fRunControl.executeWithTargetAvailable(context, new Step[] { insertDPrintf }, finalRm); + final String printfStr = (String) getProperty(attributes, MIBreakpoints.PRINTF_STRING, ""); //$NON-NLS-1$ + final Boolean enabled = (Boolean) getProperty(attributes, MIBreakpoints.IS_ENABLED, true); + final Boolean isTemporary = (Boolean) getProperty(attributes, MIBreakpointDMData.IS_TEMPORARY, false); + final String condition = (String) getProperty(attributes, MIBreakpoints.CONDITION, NULL_STRING); + final Integer ignoreCount = (Integer) getProperty(attributes, MIBreakpoints.IGNORE_COUNT, 0); + String threadId = (String) getProperty(attributes, MIBreakpointDMData.THREAD_ID, "0"); //$NON-NLS-1$ + final int tid = Integer.parseInt(threadId); + + final Step insertDPrintf = new Step() { + @Override + public void execute(final RequestMonitor rm) { + // Execute the command + fConnection.queueCommand( + fCommandFactory.createMIDPrintfInsert(context, isTemporary, condition, ignoreCount, tid, + !enabled, location, printfStr), + new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), rm) { + @Override + protected void handleSuccess() { + + // With MI, an invalid location won't generate an error + if (getData().getMIBreakpoints().length == 0) { + rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, + DYNAMIC_PRINTF_INSERTION_FAILURE, null)); + return; + } + + // Create a breakpoint object and store it in the map + final MIBreakpointDMData newBreakpoint = createMIBreakpointDMData( + getData().getMIBreakpoints()[0]); + String reference = newBreakpoint.getNumber(); + if (reference.isEmpty()) { + rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, + DYNAMIC_PRINTF_INSERTION_FAILURE, null)); + return; + } + contextBreakpoints.put(reference, newBreakpoint); + + // Format the return value + MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_7.this, + new IDMContext[] { context }, reference); + finalRm.setData(dmc); + + // Flag the event + getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties()); + + rm.done(); + } + + @Override + protected void handleError() { + rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, + DYNAMIC_PRINTF_INSERTION_FAILURE, getStatus().getException())); + } + }); + } + }; + + fRunControl.executeWithTargetAvailable(context, new Step[] { insertDPrintf }, finalRm); } } |