1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Moved to the new breakpoint management API.

This commit is contained in:
Mikhail Khodjaiants 2004-09-07 20:43:45 +00:00
parent e452d260ff
commit a315994318
6 changed files with 145 additions and 145 deletions

View file

@ -1,3 +1,7 @@
2004-09-07 Mikhail Khodjaiants
Moved to the new breakpoint management API.
* CBreakpointManager.java
2004-09-07 Alain Magloire
New interfaces to Target.
* ICDITarget.java

View file

@ -19,7 +19,6 @@ 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.ICDIBreakpointManager;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent;
@ -30,6 +29,7 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
@ -160,8 +160,8 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
fDebugTarget = target;
}
protected ICDIBreakpointManager getCDIBreakpointManager() {
return getDebugTarget().getCDISession().getBreakpointManager();
protected ICDITarget getCDITarget() {
return getDebugTarget().getCDITarget();
}
protected ICSourceLocator getCSourceLocator() {
@ -314,9 +314,9 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
protected void doRemoveBreakpoint( ICBreakpoint breakpoint ) throws DebugException {
ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
if ( cdiBreakpoint != null ) {
ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDITarget cdiTarget = getCDITarget();
try {
bm.deleteBreakpoints( new ICDIBreakpoint[]{ cdiBreakpoint } );
cdiTarget.deleteBreakpoints( new ICDIBreakpoint[]{ cdiBreakpoint } );
breakpoint.removeTargetFilter( getDebugTarget() );
}
catch( CDIException e ) {
@ -336,7 +336,7 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
if ( cdiBreakpoint == null )
return;
ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDITarget cdiTarget = getCDITarget();
try {
boolean enabled = breakpoint.isEnabled();
boolean oldEnabled = delta.getAttribute( IBreakpoint.ENABLED, true );
@ -348,7 +348,7 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
cdiBreakpoint.setEnabled( enabled );
}
if ( ignoreCount != oldIgnoreCount || !condition.equals( oldCondition ) ) {
ICDICondition cdiCondition = bm.createCondition( ignoreCount, condition );
ICDICondition cdiCondition = cdiTarget.createCondition( ignoreCount, condition );
cdiBreakpoint.setCondition( cdiCondition );
}
}
@ -452,10 +452,10 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
private void removeAllBreakpoints() {
ICDIBreakpoint[] cdiBreakpoints = getBreakpointMap().getAllCDIBreakpoints();
ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDITarget cdiTarget = getCDITarget();
if ( cdiBreakpoints.length > 0 ) {
try {
bm.deleteBreakpoints( cdiBreakpoints );
cdiTarget.deleteBreakpoints( cdiBreakpoints );
}
catch( CDIException e ) {
CDebugCorePlugin.log( e.getMessage() );
@ -473,49 +473,49 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
}
private ICDIBreakpoint setFunctionBreakpoint( ICFunctionBreakpoint breakpoint ) throws CDIException, CoreException {
ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDITarget cdiTarget = getCDITarget();
String function = breakpoint.getFunction();
String fileName = (function != null && function.indexOf( "::" ) == -1) ? breakpoint.getFileName() : null; //$NON-NLS-1$
ICDILocation location = bm.createLocation( fileName, function, -1 );
ICDILocation location = cdiTarget.createLocation( fileName, function, -1 );
ICDIBreakpoint cdiBreakpoint = null;
synchronized ( getBreakpointMap() ) {
cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
cdiBreakpoint = cdiTarget.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
getBreakpointMap().put( breakpoint, cdiBreakpoint );
}
return cdiBreakpoint;
}
private ICDIBreakpoint setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException, NumberFormatException {
ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDILocation location = bm.createLocation( Long.parseLong( breakpoint.getAddress() ) );
ICDITarget cdiTarget = getCDITarget();
ICDILocation location = cdiTarget.createLocation( Long.parseLong( breakpoint.getAddress() ) );
ICDIBreakpoint cdiBreakpoint = null;
synchronized ( getBreakpointMap() ) {
cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
cdiBreakpoint = cdiTarget.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
getBreakpointMap().put( breakpoint, cdiBreakpoint );
}
return cdiBreakpoint;
}
private ICDIBreakpoint setLineBreakpoint( ICLineBreakpoint breakpoint ) throws CDIException, CoreException {
ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDILocation location = bm.createLocation( breakpoint.getMarker().getResource().getLocation().lastSegment(), null, breakpoint.getLineNumber() );
ICDITarget cdiTarget = getCDITarget();
ICDILocation location = cdiTarget.createLocation( breakpoint.getMarker().getResource().getLocation().lastSegment(), null, breakpoint.getLineNumber() );
ICDIBreakpoint cdiBreakpoint = null;
synchronized ( getBreakpointMap() ) {
cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
cdiBreakpoint = cdiTarget.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
getBreakpointMap().put( breakpoint, cdiBreakpoint );
}
return cdiBreakpoint;
}
private ICDIBreakpoint setWatchpoint( ICWatchpoint watchpoint ) throws CDIException, CoreException {
ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDITarget cdiTarget = getCDITarget();
int accessType = 0;
accessType |= (watchpoint.isWriteType()) ? ICDIWatchpoint.WRITE : 0;
accessType |= (watchpoint.isReadType()) ? ICDIWatchpoint.READ : 0;
String expression = watchpoint.getExpression();
ICDIWatchpoint cdiWatchpoint = null;
synchronized ( getBreakpointMap() ) {
cdiWatchpoint = bm.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, null );
cdiWatchpoint = cdiTarget.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, null );
getBreakpointMap().put( watchpoint, cdiWatchpoint );
}
return cdiWatchpoint;
@ -523,8 +523,8 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
private void setBreakpointCondition( ICBreakpoint breakpoint ) throws CoreException, CDIException {
ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDICondition condition = bm.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() );
ICDITarget cdiTarget = getCDITarget();
ICDICondition condition = cdiTarget.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() );
cdiBreakpoint.setCondition( condition );
}

View file

@ -1,3 +1,9 @@
2004-09-07 Mikhail Khodjaiants
Moved to the new breakpoint management API.
* core/org/eclipse/cdt/debug/core/tests/BreakpointTests.java
* core/org/eclipse/cdt/debug/core/tests/DebugTests.java
* core/org/eclipse/cdt/debug/core/tests/LocationTests.java
2003-07-03 Peter Graves
Major cleanup. Pulled all resouces out of the source tree, and fixed the

View file

@ -7,15 +7,12 @@ package org.eclipse.cdt.debug.core.tests;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
@ -167,29 +164,29 @@ public class BreakpointTests extends TestCase {
*/
public void testFunctionBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException {
ICDISession session;
ICDIBreakpointManager breaks;
ICDITarget cdiTarget;
ICDILocation location;
boolean caught = false;
session = CDebugHelper.createSession("main", testProject);
assertNotNull(session);
breaks = session.getBreakpointManager();
assertNotNull(breaks);
cdiTarget = session.getCurrentTarget();
assertNotNull(cdiTarget);
/***********************************************************************
* Create a break point on a generic function
**********************************************************************/
location = breaks.createLocation(null, "func1", 0);
location = cdiTarget.createLocation(null, "func1", 0);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
/***********************************************************************
* Create a break point on main
**********************************************************************/
location = breaks.createLocation(null, "main", 0);
location = cdiTarget.createLocation(null, "main", 0);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
/***********************************************************************
* Try to create a break point on a function name that does not exist We
@ -197,25 +194,25 @@ public class BreakpointTests extends TestCase {
* CDIException
**********************************************************************/
location = breaks.createLocation(null, "badname", 0);
location = cdiTarget.createLocation(null, "badname", 0);
assertNotNull(location);
try {
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
} catch (CDIException e) {
caught = true;
}
assertTrue(caught);
breaks.deleteAllBreakpoints();
cdiTarget.deleteAllBreakpoints();
/***********************************************************************
* Create a break point on a generic function and see if it will get hit
* and stop program execution.
**********************************************************************/
location = breaks.createLocation(null, "func1", 0);
location = cdiTarget.createLocation(null, "func1", 0);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
targets = session.getTargets();
/*
* We better only have one target connected to this session or something
@ -262,27 +259,27 @@ public class BreakpointTests extends TestCase {
* expected.
*/
public void testLineBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException {
ICDIBreakpointManager breaks;
ICDITarget cdiTarget;
ICDILocation location;
boolean caught = false;
session = CDebugHelper.createSession("main", testProject);
assertNotNull(session);
breaks = session.getBreakpointManager();
assertNotNull(breaks);
cdiTarget = session.getCurrentTarget();
assertNotNull(cdiTarget);
/***********************************************************************
* Create a break point in a generic function
**********************************************************************/
location = breaks.createLocation("main.c", null, 7);
location = cdiTarget.createLocation("main.c", null, 7);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
/***********************************************************************
* Create a break point in main
**********************************************************************/
location = breaks.createLocation("main.c", null, 18);
location = cdiTarget.createLocation("main.c", null, 18);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
/***********************************************************************
* Try to create a break point on a line that does not exist We expect
@ -290,10 +287,10 @@ public class BreakpointTests extends TestCase {
* CDIException
**********************************************************************/
location = breaks.createLocation("main.c", null, 30);
location = cdiTarget.createLocation("main.c", null, 30);
assertNotNull(location);
try {
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
} catch (CDIException e) {
caught = true;
}
@ -304,9 +301,9 @@ public class BreakpointTests extends TestCase {
* Try to create a break point on a line that does not have code on it
**********************************************************************/
location = breaks.createLocation("main.c", null, 11);
location = cdiTarget.createLocation("main.c", null, 11);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
/***********************************************************************
* Create a break point in a generic function without passing the source
@ -315,29 +312,29 @@ public class BreakpointTests extends TestCase {
* and once with an invalid line number, and the first should always
* succeed and the second should always throw an exception.
**********************************************************************/
location = breaks.createLocation(null, null, 7);
location = cdiTarget.createLocation(null, null, 7);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
caught = false;
location = breaks.createLocation(null, null, 30);
location = cdiTarget.createLocation(null, null, 30);
assertNotNull(location);
try {
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
} catch (CDIException e) {
caught = true;
}
assertTrue("Ignoring line numbers with no file specified?", caught);
breaks.deleteAllBreakpoints();
cdiTarget.deleteAllBreakpoints();
/***********************************************************************
* Create a break point on a line number and see if it will get hit and
* stop program execution.
**********************************************************************/
location = breaks.createLocation(null, null, 7);
location = cdiTarget.createLocation(null, null, 7);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
targets = session.getTargets();
/*
* We better only have one target connected to this session or something
@ -377,19 +374,19 @@ public class BreakpointTests extends TestCase {
* A couple tests to make sure getting breakpoints works as expected
*/
public void testGetBreak() throws CoreException, MIException, IOException, CDIException {
ICDIBreakpointManager breaks;
ICDITarget cdiTarget;
ICDILocation location;
ICDIBreakpoint[] breakpoints;
ICDILocationBreakpoint curbreak;
session = CDebugHelper.createSession("main", testProject);
assertNotNull(session);
breaks = session.getBreakpointManager();
assertNotNull(breaks);
cdiTarget = session.getCurrentTarget();
assertNotNull(cdiTarget);
/***********************************************************************
* Make sure initially we don't have any breakpoints
**********************************************************************/
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
assertNotNull(breakpoints);
assertTrue(breakpoints.length == 0);
@ -398,11 +395,11 @@ public class BreakpointTests extends TestCase {
* from the system
**********************************************************************/
/* Create a break point on a generic function */
location = breaks.createLocation("main.c", "func1", 0);
location = cdiTarget.createLocation("main.c", "func1", 0);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
assertNotNull(breakpoints);
assertTrue(breakpoints.length == 1);
if (breakpoints[0] instanceof ICDILocationBreakpoint) {
@ -418,11 +415,11 @@ public class BreakpointTests extends TestCase {
* them all back from the system,
**********************************************************************/
/* Create another break point on main */
location = breaks.createLocation("main.c", "main", 0);
location = cdiTarget.createLocation("main.c", "main", 0);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
assertNotNull(breakpoints);
assertTrue(breakpoints.length == 2);
if (breakpoints[1] instanceof ICDILocationBreakpoint) {
@ -435,7 +432,7 @@ public class BreakpointTests extends TestCase {
*/
assertTrue(curbreak.getLocation().equals(location));
breaks.deleteAllBreakpoints();
cdiTarget.deleteAllBreakpoints();
/* clean up the session */
session.terminate();
@ -447,18 +444,18 @@ public class BreakpointTests extends TestCase {
* A couple tests to make sure deleting breakpoints works as expected
*/
public void testDelBreak() throws CoreException, MIException, IOException, CDIException {
ICDIBreakpointManager breaks;
ICDITarget cdiTarget;
ICDILocation location, savedLocation;
ICDIBreakpoint[] breakpoints, savedbreakpoints;
ICDILocationBreakpoint curbreak;
session = CDebugHelper.createSession("main", testProject);
assertNotNull(session);
breaks = session.getBreakpointManager();
assertNotNull(breaks);
cdiTarget = session.getCurrentTarget();
assertNotNull(cdiTarget);
/* Make sure initially we don't have any breakpoints */
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
assertNotNull(breakpoints);
assertTrue(breakpoints.length == 0);
@ -470,15 +467,15 @@ public class BreakpointTests extends TestCase {
**********************************************************************/
/* Create a break point on a generic function */
location = breaks.createLocation("main.c", "func1", 0);
location = cdiTarget.createLocation("main.c", "func1", 0);
assertNotNull(location);
curbreak = breaks.setLocationBreakpoint(0, location, null, null);
breaks.deleteBreakpoint(curbreak);
curbreak = cdiTarget.setLocationBreakpoint(0, location, null, null, false);
cdiTarget.deleteBreakpoints( new ICDIBreakpoint[] { curbreak } );
pause();
/**
* we should not have any breakpoints left.
*/
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
assertTrue(breakpoints.length == 0);
/***********************************************************************
@ -489,17 +486,17 @@ public class BreakpointTests extends TestCase {
**********************************************************************/
/* Create a break point on a generic function */
location = breaks.createLocation("main.c", "func1", 0);
location = cdiTarget.createLocation("main.c", "func1", 0);
assertNotNull(location);
curbreak = breaks.setLocationBreakpoint(0, location, null, null);
curbreak = cdiTarget.setLocationBreakpoint(0, location, null, null, false);
savedLocation = curbreak.getLocation();
location = breaks.createLocation("main.c", "main", 0);
location = cdiTarget.createLocation("main.c", "main", 0);
assertNotNull(location);
curbreak = breaks.setLocationBreakpoint(0, location, null, null);
breaks.deleteBreakpoint(curbreak);
curbreak = cdiTarget.setLocationBreakpoint(0, location, null, null, false);
cdiTarget.deleteBreakpoints( new ICDIBreakpoint[] { curbreak } );
pause();
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
/***********************************************************************
* Make sure there is only 1 breakpoint left, and it's the one we expect
*/
@ -510,9 +507,9 @@ public class BreakpointTests extends TestCase {
/***********************************************************************
* Then delete the other breakpoint.
*/
breaks.deleteBreakpoint(curbreak);
cdiTarget.deleteBreakpoints( new ICDIBreakpoint[] { curbreak } );
pause();
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
assertTrue(breakpoints.length == 0);
/***********************************************************************
@ -520,23 +517,23 @@ public class BreakpointTests extends TestCase {
**********************************************************************/
savedbreakpoints = new ICDIBreakpoint[1];
for (int x = 0; x < 10; x++) {
location = breaks.createLocation("main.c", null, x + 1);
savedbreakpoints[0] = breaks.setLocationBreakpoint(0, location, null, null);
location = cdiTarget.createLocation("main.c", null, x + 1);
savedbreakpoints[0] = cdiTarget.setLocationBreakpoint(0, location, null, null, false);
assertNotNull(savedbreakpoints[0]);
}
breaks.deleteBreakpoints(savedbreakpoints);
cdiTarget.deleteBreakpoints(savedbreakpoints);
pause();
/* We should now have 9 breakpoints left. */
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
assertTrue(breakpoints.length == 9);
/* Make sure we have the correct 9 breakpoints left */
for (int x = 0; x < breakpoints.length; x++) {
curbreak = (ICDILocationBreakpoint) breakpoints[x];
assertTrue(curbreak.getLocation().getLineNumber() == x + 1);
}
breaks.deleteAllBreakpoints();
cdiTarget.deleteAllBreakpoints();
pause();
assertTrue(breaks.getBreakpoints().length == 0);
assertTrue(cdiTarget.getBreakpoints().length == 0);
/***********************************************************************
* Make sure deleteBreakpoints works when given more then 1 but less
@ -544,38 +541,38 @@ public class BreakpointTests extends TestCase {
**********************************************************************/
savedbreakpoints = new ICDIBreakpoint[4];
for (int x = 0; x < 10; x++) {
location = breaks.createLocation("main.c", null, x + 1);
savedbreakpoints[x % 4] = breaks.setLocationBreakpoint(0, location, null, null);
location = cdiTarget.createLocation("main.c", null, x + 1);
savedbreakpoints[x % 4] = cdiTarget.setLocationBreakpoint(0, location, null, null, false);
assertNotNull(savedbreakpoints[x % 4]);
}
breaks.deleteBreakpoints(savedbreakpoints);
cdiTarget.deleteBreakpoints(savedbreakpoints);
pause();
/* We should now have 6 breakpoints left. */
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
assertTrue(breakpoints.length == 6);
/* Make sure we have the correct 6 breakpoints left */
for (int x = 0; x < breakpoints.length; x++) {
curbreak = (ICDILocationBreakpoint) breakpoints[x];
assertTrue(curbreak.getLocation().getLineNumber() == x + 1);
}
breaks.deleteAllBreakpoints();
cdiTarget.deleteAllBreakpoints();
pause();
assertTrue(breaks.getBreakpoints().length == 0);
assertTrue(cdiTarget.getBreakpoints().length == 0);
/***********************************************************************
* Make sure deleteBreakpoints works when given all the breakpoints
**********************************************************************/
savedbreakpoints = new ICDIBreakpoint[10];
for (int x = 0; x < 10; x++) {
location = breaks.createLocation("main.c", null, x + 1);
savedbreakpoints[x] = breaks.setLocationBreakpoint(0, location, null, null);
location = cdiTarget.createLocation("main.c", null, x + 1);
savedbreakpoints[x] = cdiTarget.setLocationBreakpoint(0, location, null, null, false);
assertNotNull(savedbreakpoints[x]);
}
breaks.deleteBreakpoints(savedbreakpoints);
cdiTarget.deleteBreakpoints(savedbreakpoints);
pause();
/* We should now have 0 breakpoints left. */
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
assertTrue(breakpoints.length == 0);
/***********************************************************************
@ -583,14 +580,14 @@ public class BreakpointTests extends TestCase {
**********************************************************************/
for (int x = 0; x < 10; x++) {
location = breaks.createLocation("main.c", null, x + 1);
curbreak = breaks.setLocationBreakpoint(0, location, null, null);
location = cdiTarget.createLocation("main.c", null, x + 1);
curbreak = cdiTarget.setLocationBreakpoint(0, location, null, null, false);
assertNotNull(curbreak);
}
breaks.deleteAllBreakpoints();
cdiTarget.deleteAllBreakpoints();
pause();
/* We should now have 0 breakpoints left. */
breakpoints = breaks.getBreakpoints();
breakpoints = cdiTarget.getBreakpoints();
assertTrue(breakpoints.length == 0);
/* clean up the session */
@ -604,40 +601,37 @@ public class BreakpointTests extends TestCase {
* work as expected.
*/
public void testCondBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException {
ICDIBreakpointManager breaks;
ICDILocation location;
ICDICondition cond;
boolean caught = false;
session = CDebugHelper.createSession("main", testProject);
assertNotNull(session);
breaks = session.getBreakpointManager();
assertNotNull(breaks);
ICDITarget cdiTarget = session.getCurrentTarget();
assertNotNull(cdiTarget);
/***********************************************************************
* Create a break point on a generic function with an empty condition
**********************************************************************/
cond = breaks.createCondition(0, "");
location = breaks.createLocation(null, "func1", 0);
ICDICondition cond = cdiTarget.createCondition(0, "");
ICDILocation location = cdiTarget.createLocation(null, "func1", 0);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, cond, null);
cdiTarget.setLocationBreakpoint(0, location, cond, null, false);
/***********************************************************************
* Create a break point on a generic function with an valid condition
**********************************************************************/
cond = breaks.createCondition(0, "x<10");
location = breaks.createLocation(null, "func1", 0);
cond = cdiTarget.createCondition(0, "x<10");
location = cdiTarget.createLocation(null, "func1", 0);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, cond, null);
cdiTarget.setLocationBreakpoint(0, location, cond, null, false);
/***********************************************************************
* Create a break point on a generic function with an invalid condition
* We expect to get a CDIException when we try to set the breakpoint.
**********************************************************************/
cond = breaks.createCondition(0, "nonexist<10");
location = breaks.createLocation(null, "func1", 0);
cond = cdiTarget.createCondition(0, "nonexist<10");
location = cdiTarget.createLocation(null, "func1", 0);
assertNotNull(location);
try {
breaks.setLocationBreakpoint(0, location, cond, null);
cdiTarget.setLocationBreakpoint(0, location, cond, null, false);
} catch (CDIException e) {
caught = true;
}
@ -648,12 +642,12 @@ public class BreakpointTests extends TestCase {
* it does not suspend execution of the application until the condition
* is true
**********************************************************************/
breaks.deleteAllBreakpoints();
location = breaks.createLocation(null, null, 23);
cdiTarget.deleteAllBreakpoints();
location = cdiTarget.createLocation(null, null, 23);
assertNotNull(location);
cond = breaks.createCondition(0, "a>10");
cond = cdiTarget.createCondition(0, "a>10");
breaks.setLocationBreakpoint(0, location, cond, null);
cdiTarget.setLocationBreakpoint(0, location, cond, null, false);
targets = session.getTargets();
/*
* We better only have one target connected to this session or something

View file

@ -8,16 +8,14 @@ package org.eclipse.cdt.debug.core.tests;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.ICDISourceManager;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.testplugin.CDebugHelper;
import org.eclipse.cdt.debug.testplugin.CProjectHelper;
@ -119,18 +117,18 @@ public class DebugTests extends TestCase {
*/
public void testDebug() throws CoreException, MIException, IOException, CDIException {
ICDISourceManager source;
ICDIBreakpointManager breaks;
ICDITarget cdiTarget;
ICDILocation location;
session=CDebugHelper.createSession("main",testProject);
assertNotNull(session);
source=session.getSourceManager();
assertNotNull(source);
breaks=session.getBreakpointManager();
assertNotNull(breaks);
location=breaks.createLocation(null, "func1", 0);
cdiTarget=session.getCurrentTarget();
assertNotNull(cdiTarget);
location=cdiTarget.createLocation(null, "func1", 0);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
session.getCurrentTarget().resume();
session.terminate();
session=null;

View file

@ -8,17 +8,15 @@ package org.eclipse.cdt.debug.core.tests;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.testplugin.CDebugHelper;
import org.eclipse.cdt.debug.testplugin.CProjectHelper;
@ -116,26 +114,26 @@ public class LocationTests extends TestCase {
* A couple tests to make sure comparing Locations works as expected.
*/
public void testIsEquals() throws CoreException, MIException, IOException, CDIException {
ICDIBreakpointManager breaks;
ICDITarget cdiTarget;
ICDILocation location, location2;
ICDIBreakpoint[] breakpoints;
ICDILocationBreakpoint curbreak;
session=CDebugHelper.createSession("main",testProject);
assertNotNull(session);
breaks=session.getBreakpointManager();
assertNotNull(breaks);
cdiTarget=session.getCurrentTarget();
assertNotNull(cdiTarget);
/**********************************************************************
* Simple test.. this should work.
**********************************************************************/
location=breaks.createLocation("main.c", "func1", 0);
location2=breaks.createLocation("main.c", "func1", 0);
location=cdiTarget.createLocation("main.c", "func1", 0);
location2=cdiTarget.createLocation("main.c", "func1", 0);
assertTrue(location.equals(location2));
/**********************************************************************
* Simple test.. this should work.
**********************************************************************/
location=breaks.createLocation("main.c", null, 10);
location2=breaks.createLocation("main.c", null, 10);
location=cdiTarget.createLocation("main.c", null, 10);
location2=cdiTarget.createLocation("main.c", null, 10);
assertTrue(location.equals(location2));
/**********************************************************************
@ -144,11 +142,11 @@ public class LocationTests extends TestCase {
* setLocationBreakpoint is the same as the breakpoint returned from
* BreakpointManager.getBreakpoints.getLocation()
**********************************************************************/
location=breaks.createLocation("main.c", "func1", 0);
location=cdiTarget.createLocation("main.c", "func1", 0);
assertNotNull(location);
location2=breaks.setLocationBreakpoint(0, location, null, null).getLocation();
location2=cdiTarget.setLocationBreakpoint(0, location, null, null, false).getLocation();
breakpoints=breaks.getBreakpoints();
breakpoints=cdiTarget.getBreakpoints();
assertNotNull(breakpoints);
assertTrue(breakpoints.length==1);
if (breakpoints[0] instanceof ICDILocationBreakpoint) {
@ -158,16 +156,16 @@ public class LocationTests extends TestCase {
assertNotNull(curbreak);
assertTrue(curbreak.getLocation().equals(location2));
breaks.deleteAllBreakpoints();
cdiTarget.deleteAllBreakpoints();
/* Create a break point on a generic function with a file name that
* gdb will change to the relitive path of the source file. This
* should work, but at the time of writing (Sept 25, 2002) does not.
*/
location=breaks.createLocation("main.c", "func1", 0);
location=cdiTarget.createLocation("main.c", "func1", 0);
assertNotNull(location);
breaks.setLocationBreakpoint(0, location, null, null);
cdiTarget.setLocationBreakpoint(0, location, null, null, false);
breakpoints=breaks.getBreakpoints();
breakpoints=cdiTarget.getBreakpoints();
assertNotNull(breakpoints);
assertTrue(breakpoints.length==1);
if (breakpoints[0] instanceof ICDILocationBreakpoint) {