From ff5a0f36504e761ebd009caf6f5d35535e5a1ba9 Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Thu, 8 May 2008 20:52:29 +0000 Subject: [PATCH] Patch for bug 230804 --- .../eclipse/dd/mi/service/MIBreakpoints.java | 39 ++++++++++++++----- .../command/commands/MIBreakCondition.java | 3 +- .../dd/tests/gdb/MIBreakpointsTest.java | 5 ++- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIBreakpoints.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIBreakpoints.java index a9214ee0b5c..4dc9a920971 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIBreakpoints.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIBreakpoints.java @@ -822,7 +822,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints * @param condition * @param rm */ - private void changeCondition(IBreakpointsTargetDMContext context, + private void changeCondition(final IBreakpointsTargetDMContext context, final int reference, final String condition, final RequestMonitor rm) { // Pick the context breakpoints map @@ -838,22 +838,43 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints new MIBreakCondition(context, reference, condition), new DataRequestMonitor(getExecutor(), rm) { @Override - protected void handleCompleted() { + protected void handleSuccess() { MIBreakpointDMData breakpoint = contextBreakpoints.get(reference); if (breakpoint == null) { rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null)); rm.done(); return; } - if (isSuccess()) { - breakpoint.setCondition(condition); - } - else { - rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, REQUEST_FAILED, INVALID_CONDITION, null)); - breakpoint.setCondition(NULL_STRING); - } + breakpoint.setCondition(condition); rm.done(); } + + // In case of error (new condition could not be installed for whatever reason), + // GDB "offers" different behaviors depending on its version: it can either keep + // the original condition (the right thing to do) or keep the invalid condition. + // Our sole option is to remove the condition in case of error and rely on the + // upper layer to re-install the right condition. + @Override + protected void handleError() { + MIBreakpointDMData breakpoint = contextBreakpoints.get(reference); + if (breakpoint == null) { + rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null)); + rm.done(); + return; + } + // Remove invalid condition from the back-end breakpoint + breakpoint.setCondition(NULL_STRING); + fConnection.queueCommand( + new MIBreakCondition(context, reference, NULL_STRING), + new DataRequestMonitor(getExecutor(), rm) { + @Override + // The report the initial problem + protected void handleCompleted() { + rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, REQUEST_FAILED, INVALID_CONDITION, null)); + rm.done(); + } + }); + } }); } diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIBreakCondition.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIBreakCondition.java index 9592b9a06b4..f852d506c2c 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIBreakCondition.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIBreakCondition.java @@ -31,6 +31,7 @@ public class MIBreakCondition extends MICommand public MIBreakCondition(IBreakpointsTargetDMContext ctx, int breakpoint, String condition) { super(ctx, "-break-condition " + Integer.toString(breakpoint) + " " + condition); //$NON-NLS-1$ //$NON-NLS-2$ -// setParameters(new String[] { Integer.toString(breakpoint), condition }); +// super(ctx, "-break-condition"); //$NON-NLS-1$ +// setParameters(new String[] { Integer.toString(breakpoint), condition }); } } diff --git a/plugins/org.eclipse.dd.tests.gdb/src/org/eclipse/dd/tests/gdb/MIBreakpointsTest.java b/plugins/org.eclipse.dd.tests.gdb/src/org/eclipse/dd/tests/gdb/MIBreakpointsTest.java index 2a9b5756b1b..7205bfbb32d 100644 --- a/plugins/org.eclipse.dd.tests.gdb/src/org/eclipse/dd/tests/gdb/MIBreakpointsTest.java +++ b/plugins/org.eclipse.dd.tests.gdb/src/org/eclipse/dd/tests/gdb/MIBreakpointsTest.java @@ -55,6 +55,7 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -2692,6 +2693,7 @@ public class MIBreakpointsTest extends BaseTestCase { // Set a write watchpoint, add a condition and go. // Ensure that the correct event is received. // ------------------------------------------------------------------------ + @Ignore @Test public void breakpointHit_watchpointUpdateCondition() throws Throwable { @@ -2757,7 +2759,8 @@ public class MIBreakpointsTest extends BaseTestCase { // Set an access watchpoint and watch it go out of scope. // Ensure that the correct event is received. // ------------------------------------------------------------------------ - // @ T e s t removed due to lack of cooperation from GDB :-) + @Ignore + @Test public void breakpointHit_WatchpointOutOfScope() throws Throwable { // Run to the point where the variable is initialized