mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Fix test changes in CDI
This commit is contained in:
parent
03f49cac54
commit
277bec9a0d
3 changed files with 110 additions and 90 deletions
|
@ -14,7 +14,9 @@ import junit.framework.TestSuite;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
|
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
|
import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDILineLocation;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDILocator;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
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.ICDIBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
|
||||||
|
@ -166,7 +168,7 @@ public class BreakpointTests extends TestCase {
|
||||||
public void testFunctionBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException {
|
public void testFunctionBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException {
|
||||||
ICDISession session;
|
ICDISession session;
|
||||||
ICDITarget cdiTarget;
|
ICDITarget cdiTarget;
|
||||||
ICDILocation location;
|
ICDIFunctionLocation location;
|
||||||
boolean caught = false;
|
boolean caught = false;
|
||||||
session = CDebugHelper.createSession("main", testProject); //$NON-NLS-1$
|
session = CDebugHelper.createSession("main", testProject); //$NON-NLS-1$
|
||||||
assertNotNull(session);
|
assertNotNull(session);
|
||||||
|
@ -180,17 +182,17 @@ public class BreakpointTests extends TestCase {
|
||||||
* Create a break point on a generic function
|
* Create a break point on a generic function
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location = cdiTarget.createLocation(null, "func1", 0); //$NON-NLS-1$
|
location = cdiTarget.createFunctionLocation(null, "func1"); //$NON-NLS-1$
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setFunctionBreakpoint(0, location, null, false);
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on main
|
* Create a break point on main
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location = cdiTarget.createLocation(null, "main", 0); //$NON-NLS-1$
|
location = cdiTarget.createFunctionLocation(null, "main"); //$NON-NLS-1$
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setFunctionBreakpoint(0, location, null, false);
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Try to create a break point on a function name that does not exist We
|
* Try to create a break point on a function name that does not exist We
|
||||||
|
@ -198,10 +200,10 @@ public class BreakpointTests extends TestCase {
|
||||||
* CDIException
|
* CDIException
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location = cdiTarget.createLocation(null, "badname", 0); //$NON-NLS-1$
|
location = cdiTarget.createFunctionLocation(null, "badname"); //$NON-NLS-1$
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
try {
|
try {
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setFunctionBreakpoint(0, location, null, false);
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
caught = true;
|
caught = true;
|
||||||
}
|
}
|
||||||
|
@ -214,9 +216,9 @@ public class BreakpointTests extends TestCase {
|
||||||
* and stop program execution.
|
* and stop program execution.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location = cdiTarget.createLocation(null, "func1", 0); //$NON-NLS-1$
|
location = cdiTarget.createFunctionLocation(null, "func1"); //$NON-NLS-1$
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setFunctionBreakpoint(0, location, null, false);
|
||||||
targets = session.getTargets();
|
targets = session.getTargets();
|
||||||
/*
|
/*
|
||||||
* We better only have one target connected to this session or something
|
* We better only have one target connected to this session or something
|
||||||
|
@ -239,10 +241,10 @@ public class BreakpointTests extends TestCase {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
assertTrue(targets[0].isSuspended());
|
assertTrue(targets[0].isSuspended());
|
||||||
location = targets[0].getCurrentThread().getStackFrames()[0].getLocation();
|
ICDILocator locator = targets[0].getCurrentThread().getStackFrames()[0].getLocator();
|
||||||
assertTrue(location.getLineNumber() == 6);
|
assertTrue(locator.getLineNumber() == 6);
|
||||||
assertTrue(location.getFunction().equals("func1")); //$NON-NLS-1$
|
assertTrue(locator.getFunction().equals("func1")); //$NON-NLS-1$
|
||||||
assertTrue(location.getFile().equals("main.c")); //$NON-NLS-1$
|
assertTrue(locator.getFile().equals("main.c")); //$NON-NLS-1$
|
||||||
|
|
||||||
/* clean up the session */
|
/* clean up the session */
|
||||||
targets[0].terminate();
|
targets[0].terminate();
|
||||||
|
@ -264,7 +266,7 @@ public class BreakpointTests extends TestCase {
|
||||||
*/
|
*/
|
||||||
public void testLineBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException {
|
public void testLineBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException {
|
||||||
ICDITarget cdiTarget;
|
ICDITarget cdiTarget;
|
||||||
ICDILocation location;
|
ICDILineLocation location;
|
||||||
boolean caught = false;
|
boolean caught = false;
|
||||||
session = CDebugHelper.createSession("main", testProject);
|
session = CDebugHelper.createSession("main", testProject);
|
||||||
assertNotNull(session);
|
assertNotNull(session);
|
||||||
|
@ -277,16 +279,16 @@ public class BreakpointTests extends TestCase {
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point in a generic function
|
* Create a break point in a generic function
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
location = cdiTarget.createLocation("main.c", null, 7);
|
location = cdiTarget.createLineLocation("main.c", 7);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setLineBreakpoint(0, location, null, false);
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point in main
|
* Create a break point in main
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
location = cdiTarget.createLocation("main.c", null, 18);
|
location = cdiTarget.createLineLocation("main.c", 18);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setLineBreakpoint(0, location, null, false);
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Try to create a break point on a line that does not exist We expect
|
* Try to create a break point on a line that does not exist We expect
|
||||||
|
@ -294,10 +296,10 @@ public class BreakpointTests extends TestCase {
|
||||||
* CDIException
|
* CDIException
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location = cdiTarget.createLocation("main.c", null, 30);
|
location = cdiTarget.createLineLocation("main.c", 30);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
try {
|
try {
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setLineBreakpoint(0, location, null, false);
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
caught = true;
|
caught = true;
|
||||||
}
|
}
|
||||||
|
@ -308,9 +310,9 @@ public class BreakpointTests extends TestCase {
|
||||||
* Try to create a break point on a line that does not have code on it
|
* Try to create a break point on a line that does not have code on it
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location = cdiTarget.createLocation("main.c", null, 11);
|
location = cdiTarget.createLineLocation("main.c", 11);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setLineBreakpoint(0, location, null, false);
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point in a generic function without passing the source
|
* Create a break point in a generic function without passing the source
|
||||||
|
@ -319,14 +321,14 @@ public class BreakpointTests extends TestCase {
|
||||||
* and once with an invalid line number, and the first should always
|
* and once with an invalid line number, and the first should always
|
||||||
* succeed and the second should always throw an exception.
|
* succeed and the second should always throw an exception.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
location = cdiTarget.createLocation(null, null, 7);
|
location = cdiTarget.createLineLocation(null, 7);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setLineBreakpoint(0, location, null, false);
|
||||||
caught = false;
|
caught = false;
|
||||||
location = cdiTarget.createLocation(null, null, 30);
|
location = cdiTarget.createLineLocation(null, 30);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
try {
|
try {
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setLineBreakpoint(0, location, null, false);
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
caught = true;
|
caught = true;
|
||||||
}
|
}
|
||||||
|
@ -339,9 +341,9 @@ public class BreakpointTests extends TestCase {
|
||||||
* stop program execution.
|
* stop program execution.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location = cdiTarget.createLocation(null, null, 7);
|
location = cdiTarget.createLineLocation(null, 7);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setLineBreakpoint(0, location, null, false);
|
||||||
targets = session.getTargets();
|
targets = session.getTargets();
|
||||||
/*
|
/*
|
||||||
* We better only have one target connected to this session or something
|
* We better only have one target connected to this session or something
|
||||||
|
@ -365,10 +367,10 @@ public class BreakpointTests extends TestCase {
|
||||||
}
|
}
|
||||||
assertTrue("Suspended: " + targets[0].isSuspended() + " Termiunated: " + targets[0].isTerminated(), targets[0]
|
assertTrue("Suspended: " + targets[0].isSuspended() + " Termiunated: " + targets[0].isTerminated(), targets[0]
|
||||||
.isSuspended());
|
.isSuspended());
|
||||||
location = targets[0].getCurrentThread().getStackFrames()[0].getLocation();
|
ICDILocator locator = targets[0].getCurrentThread().getStackFrames()[0].getLocator();
|
||||||
assertTrue(location.getLineNumber() == 7);
|
assertTrue(locator.getLineNumber() == 7);
|
||||||
assertTrue(location.getFunction().equals("func1"));
|
assertTrue(locator.getFunction().equals("func1"));
|
||||||
assertTrue(location.getFile().equals("main.c"));
|
assertTrue(locator.getFile().equals("main.c"));
|
||||||
|
|
||||||
/* clean up the session */
|
/* clean up the session */
|
||||||
session.terminate();
|
session.terminate();
|
||||||
|
@ -382,7 +384,7 @@ public class BreakpointTests extends TestCase {
|
||||||
*/
|
*/
|
||||||
public void testGetBreak() throws CoreException, MIException, IOException, CDIException {
|
public void testGetBreak() throws CoreException, MIException, IOException, CDIException {
|
||||||
ICDITarget cdiTarget;
|
ICDITarget cdiTarget;
|
||||||
ICDILocation location;
|
ICDIFunctionLocation location;
|
||||||
ICDIBreakpoint[] breakpoints;
|
ICDIBreakpoint[] breakpoints;
|
||||||
ICDILocationBreakpoint curbreak;
|
ICDILocationBreakpoint curbreak;
|
||||||
session = CDebugHelper.createSession("main", testProject);
|
session = CDebugHelper.createSession("main", testProject);
|
||||||
|
@ -405,9 +407,9 @@ public class BreakpointTests extends TestCase {
|
||||||
* from the system
|
* from the system
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/* Create a break point on a generic function */
|
/* Create a break point on a generic function */
|
||||||
location = cdiTarget.createLocation("main.c", "func1", 0);
|
location = cdiTarget.createFunctionLocation("main.c", "func1");
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setFunctionBreakpoint(0, location, null, false);
|
||||||
|
|
||||||
breakpoints = cdiTarget.getBreakpoints();
|
breakpoints = cdiTarget.getBreakpoints();
|
||||||
assertNotNull(breakpoints);
|
assertNotNull(breakpoints);
|
||||||
|
@ -418,16 +420,23 @@ public class BreakpointTests extends TestCase {
|
||||||
curbreak = null;
|
curbreak = null;
|
||||||
assertNotNull(curbreak);
|
assertNotNull(curbreak);
|
||||||
|
|
||||||
assertTrue(curbreak.getLocation().equals(location));
|
//assertTrue(curbreak.getLocator().equals(location));
|
||||||
|
{
|
||||||
|
ICDILocator locator = curbreak.getLocator();
|
||||||
|
String file = locator.getFile();
|
||||||
|
String function = locator.getFunction();
|
||||||
|
assertTrue("main.c".equals(file));
|
||||||
|
assertTrue("func1".equals(function));
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Make sure if we create multiple break points that we can still get
|
* Make sure if we create multiple break points that we can still get
|
||||||
* them all back from the system,
|
* them all back from the system,
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/* Create another break point on main */
|
/* Create another break point on main */
|
||||||
location = cdiTarget.createLocation("main.c", "main", 0);
|
location = cdiTarget.createFunctionLocation("main.c", "main");
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setFunctionBreakpoint(0, location, null, false);
|
||||||
|
|
||||||
breakpoints = cdiTarget.getBreakpoints();
|
breakpoints = cdiTarget.getBreakpoints();
|
||||||
assertNotNull(breakpoints);
|
assertNotNull(breakpoints);
|
||||||
|
@ -440,7 +449,14 @@ public class BreakpointTests extends TestCase {
|
||||||
/*
|
/*
|
||||||
* Make sure the location still looks like we expect it to.. .
|
* Make sure the location still looks like we expect it to.. .
|
||||||
*/
|
*/
|
||||||
assertTrue(curbreak.getLocation().equals(location));
|
//assertTrue(curbreak.getLocation().equals(location));
|
||||||
|
{
|
||||||
|
ICDILocator locator = curbreak.getLocator();
|
||||||
|
String file = locator.getFile();
|
||||||
|
String function = locator.getFunction();
|
||||||
|
assertTrue("main.c".equals(file));
|
||||||
|
assertTrue("main".equals(function));
|
||||||
|
}
|
||||||
|
|
||||||
cdiTarget.deleteAllBreakpoints();
|
cdiTarget.deleteAllBreakpoints();
|
||||||
|
|
||||||
|
@ -455,7 +471,8 @@ public class BreakpointTests extends TestCase {
|
||||||
*/
|
*/
|
||||||
public void testDelBreak() throws CoreException, MIException, IOException, CDIException {
|
public void testDelBreak() throws CoreException, MIException, IOException, CDIException {
|
||||||
ICDITarget cdiTarget;
|
ICDITarget cdiTarget;
|
||||||
ICDILocation location, savedLocation;
|
ICDIFunctionLocation location;
|
||||||
|
ICDILocator savedLocation;
|
||||||
ICDIBreakpoint[] breakpoints, savedbreakpoints;
|
ICDIBreakpoint[] breakpoints, savedbreakpoints;
|
||||||
ICDILocationBreakpoint curbreak;
|
ICDILocationBreakpoint curbreak;
|
||||||
|
|
||||||
|
@ -480,9 +497,9 @@ public class BreakpointTests extends TestCase {
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
/* Create a break point on a generic function */
|
/* Create a break point on a generic function */
|
||||||
location = cdiTarget.createLocation("main.c", "func1", 0);
|
location = cdiTarget.createFunctionLocation("main.c", "func1");
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
curbreak = cdiTarget.setLocationBreakpoint(0, location, null, false);
|
curbreak = cdiTarget.setFunctionBreakpoint(0, location, null, false);
|
||||||
cdiTarget.deleteBreakpoints( new ICDIBreakpoint[] { curbreak } );
|
cdiTarget.deleteBreakpoints( new ICDIBreakpoint[] { curbreak } );
|
||||||
pause();
|
pause();
|
||||||
/**
|
/**
|
||||||
|
@ -499,14 +516,14 @@ public class BreakpointTests extends TestCase {
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
/* Create a break point on a generic function */
|
/* Create a break point on a generic function */
|
||||||
location = cdiTarget.createLocation("main.c", "func1", 0);
|
location = cdiTarget.createFunctionLocation("main.c", "func1");
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
curbreak = cdiTarget.setLocationBreakpoint(0, location, null, false);
|
curbreak = cdiTarget.setFunctionBreakpoint(0, location, null, false);
|
||||||
savedLocation = curbreak.getLocation();
|
savedLocation = curbreak.getLocator();
|
||||||
|
|
||||||
location = cdiTarget.createLocation("main.c", "main", 0);
|
location = cdiTarget.createFunctionLocation("main.c", "main");
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
curbreak = cdiTarget.setLocationBreakpoint(0, location, null, false);
|
curbreak = cdiTarget.setFunctionBreakpoint(0, location, null, false);
|
||||||
cdiTarget.deleteBreakpoints( new ICDIBreakpoint[] { curbreak } );
|
cdiTarget.deleteBreakpoints( new ICDIBreakpoint[] { curbreak } );
|
||||||
pause();
|
pause();
|
||||||
breakpoints = cdiTarget.getBreakpoints();
|
breakpoints = cdiTarget.getBreakpoints();
|
||||||
|
@ -516,7 +533,7 @@ public class BreakpointTests extends TestCase {
|
||||||
assertTrue(breakpoints.length == 1);
|
assertTrue(breakpoints.length == 1);
|
||||||
curbreak = (ICDILocationBreakpoint) breakpoints[0];
|
curbreak = (ICDILocationBreakpoint) breakpoints[0];
|
||||||
assertNotNull(curbreak);
|
assertNotNull(curbreak);
|
||||||
assertTrue(curbreak.getLocation().equals(savedLocation));
|
assertTrue(curbreak.getLocator().equals(savedLocation));
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Then delete the other breakpoint.
|
* Then delete the other breakpoint.
|
||||||
*/
|
*/
|
||||||
|
@ -530,8 +547,8 @@ public class BreakpointTests extends TestCase {
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
savedbreakpoints = new ICDIBreakpoint[1];
|
savedbreakpoints = new ICDIBreakpoint[1];
|
||||||
for (int x = 0; x < 10; x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
location = cdiTarget.createLocation("main.c", null, x + 1);
|
ICDILineLocation lineLocation = cdiTarget.createLineLocation("main.c", x + 1);
|
||||||
savedbreakpoints[0] = cdiTarget.setLocationBreakpoint(0, location, null, false);
|
savedbreakpoints[0] = cdiTarget.setLineBreakpoint(0, lineLocation, null, false);
|
||||||
assertNotNull(savedbreakpoints[0]);
|
assertNotNull(savedbreakpoints[0]);
|
||||||
}
|
}
|
||||||
cdiTarget.deleteBreakpoints(savedbreakpoints);
|
cdiTarget.deleteBreakpoints(savedbreakpoints);
|
||||||
|
@ -542,7 +559,7 @@ public class BreakpointTests extends TestCase {
|
||||||
/* Make sure we have the correct 9 breakpoints left */
|
/* Make sure we have the correct 9 breakpoints left */
|
||||||
for (int x = 0; x < breakpoints.length; x++) {
|
for (int x = 0; x < breakpoints.length; x++) {
|
||||||
curbreak = (ICDILocationBreakpoint) breakpoints[x];
|
curbreak = (ICDILocationBreakpoint) breakpoints[x];
|
||||||
assertTrue(curbreak.getLocation().getLineNumber() == x + 1);
|
assertTrue(curbreak.getLocator().getLineNumber() == x + 1);
|
||||||
}
|
}
|
||||||
cdiTarget.deleteAllBreakpoints();
|
cdiTarget.deleteAllBreakpoints();
|
||||||
pause();
|
pause();
|
||||||
|
@ -554,8 +571,8 @@ public class BreakpointTests extends TestCase {
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
savedbreakpoints = new ICDIBreakpoint[4];
|
savedbreakpoints = new ICDIBreakpoint[4];
|
||||||
for (int x = 0; x < 10; x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
location = cdiTarget.createLocation("main.c", null, x + 1);
|
ICDILineLocation lineLocation = cdiTarget.createLineLocation("main.c", x + 1);
|
||||||
savedbreakpoints[x % 4] = cdiTarget.setLocationBreakpoint(0, location, null, false);
|
savedbreakpoints[x % 4] = cdiTarget.setLineBreakpoint(0, lineLocation, null, false);
|
||||||
assertNotNull(savedbreakpoints[x % 4]);
|
assertNotNull(savedbreakpoints[x % 4]);
|
||||||
}
|
}
|
||||||
cdiTarget.deleteBreakpoints(savedbreakpoints);
|
cdiTarget.deleteBreakpoints(savedbreakpoints);
|
||||||
|
@ -567,7 +584,7 @@ public class BreakpointTests extends TestCase {
|
||||||
/* Make sure we have the correct 6 breakpoints left */
|
/* Make sure we have the correct 6 breakpoints left */
|
||||||
for (int x = 0; x < breakpoints.length; x++) {
|
for (int x = 0; x < breakpoints.length; x++) {
|
||||||
curbreak = (ICDILocationBreakpoint) breakpoints[x];
|
curbreak = (ICDILocationBreakpoint) breakpoints[x];
|
||||||
assertTrue(curbreak.getLocation().getLineNumber() == x + 1);
|
assertTrue(curbreak.getLocator().getLineNumber() == x + 1);
|
||||||
}
|
}
|
||||||
cdiTarget.deleteAllBreakpoints();
|
cdiTarget.deleteAllBreakpoints();
|
||||||
pause();
|
pause();
|
||||||
|
@ -578,8 +595,8 @@ public class BreakpointTests extends TestCase {
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
savedbreakpoints = new ICDIBreakpoint[10];
|
savedbreakpoints = new ICDIBreakpoint[10];
|
||||||
for (int x = 0; x < 10; x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
location = cdiTarget.createLocation("main.c", null, x + 1);
|
ICDILineLocation lineLocation = cdiTarget.createLineLocation("main.c", x + 1);
|
||||||
savedbreakpoints[x] = cdiTarget.setLocationBreakpoint(0, location, null, false);
|
savedbreakpoints[x] = cdiTarget.setLineBreakpoint(0, lineLocation, null, false);
|
||||||
assertNotNull(savedbreakpoints[x]);
|
assertNotNull(savedbreakpoints[x]);
|
||||||
}
|
}
|
||||||
cdiTarget.deleteBreakpoints(savedbreakpoints);
|
cdiTarget.deleteBreakpoints(savedbreakpoints);
|
||||||
|
@ -593,8 +610,8 @@ public class BreakpointTests extends TestCase {
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
for (int x = 0; x < 10; x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
location = cdiTarget.createLocation("main.c", null, x + 1);
|
ICDILineLocation lineLocation = cdiTarget.createLineLocation("main.c", x + 1);
|
||||||
curbreak = cdiTarget.setLocationBreakpoint(0, location, null, false);
|
curbreak = cdiTarget.setLineBreakpoint(0, lineLocation, null, false);
|
||||||
assertNotNull(curbreak);
|
assertNotNull(curbreak);
|
||||||
}
|
}
|
||||||
cdiTarget.deleteAllBreakpoints();
|
cdiTarget.deleteAllBreakpoints();
|
||||||
|
@ -627,27 +644,27 @@ public class BreakpointTests extends TestCase {
|
||||||
* Create a break point on a generic function with an empty condition
|
* Create a break point on a generic function with an empty condition
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
ICDICondition cond = cdiTarget.createCondition(0, "");
|
ICDICondition cond = cdiTarget.createCondition(0, "");
|
||||||
ICDILocation location = cdiTarget.createLocation(null, "func1", 0);
|
ICDIFunctionLocation location = cdiTarget.createFunctionLocation(null, "func1");
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, cond, false);
|
cdiTarget.setFunctionBreakpoint(0, location, cond, false);
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on a generic function with an valid condition
|
* Create a break point on a generic function with an valid condition
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
cond = cdiTarget.createCondition(0, "x<10");
|
cond = cdiTarget.createCondition(0, "x<10");
|
||||||
location = cdiTarget.createLocation(null, "func1", 0);
|
location = cdiTarget.createFunctionLocation(null, "func1");
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, cond, false);
|
cdiTarget.setFunctionBreakpoint(0, location, cond, false);
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on a generic function with an invalid condition
|
* 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.
|
* We expect to get a CDIException when we try to set the breakpoint.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
cond = cdiTarget.createCondition(0, "nonexist<10");
|
cond = cdiTarget.createCondition(0, "nonexist<10");
|
||||||
location = cdiTarget.createLocation(null, "func1", 0);
|
location = cdiTarget.createFunctionLocation(null, "func1");
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
try {
|
try {
|
||||||
cdiTarget.setLocationBreakpoint(0, location, cond, false);
|
cdiTarget.setFunctionBreakpoint(0, location, cond, false);
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
caught = true;
|
caught = true;
|
||||||
}
|
}
|
||||||
|
@ -659,11 +676,11 @@ public class BreakpointTests extends TestCase {
|
||||||
* is true
|
* is true
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
cdiTarget.deleteAllBreakpoints();
|
cdiTarget.deleteAllBreakpoints();
|
||||||
location = cdiTarget.createLocation(null, null, 23);
|
ICDILineLocation lineLocation = cdiTarget.createLineLocation(null, 23);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cond = cdiTarget.createCondition(0, "a>10");
|
cond = cdiTarget.createCondition(0, "a>10");
|
||||||
|
|
||||||
cdiTarget.setLocationBreakpoint(0, location, cond, false);
|
cdiTarget.setLineBreakpoint(0, lineLocation, cond, false);
|
||||||
targets = session.getTargets();
|
targets = session.getTargets();
|
||||||
/*
|
/*
|
||||||
* We better only have one target connected to this session or something
|
* We better only have one target connected to this session or something
|
||||||
|
@ -688,10 +705,10 @@ public class BreakpointTests extends TestCase {
|
||||||
assertTrue("Suspended: " + targets[0].isSuspended() + " Termiunated: " + targets[0].isTerminated(), targets[0]
|
assertTrue("Suspended: " + targets[0].isSuspended() + " Termiunated: " + targets[0].isTerminated(), targets[0]
|
||||||
.isSuspended());
|
.isSuspended());
|
||||||
ICDIStackFrame frame = targets[0].getCurrentThread().getStackFrames()[0];
|
ICDIStackFrame frame = targets[0].getCurrentThread().getStackFrames()[0];
|
||||||
location = frame.getLocation();
|
ICDILocator locator = frame.getLocator();
|
||||||
assertTrue(location.getLineNumber() == 23);
|
assertTrue(locator.getLineNumber() == 23);
|
||||||
assertTrue(location.getFunction().equals("main"));
|
assertTrue(locator.getFunction().equals("main"));
|
||||||
assertTrue(location.getFile().equals("main.c"));
|
assertTrue(locator.getFile().equals("main.c"));
|
||||||
/* Get the value of a and and make sure it is 11 */
|
/* Get the value of a and and make sure it is 11 */
|
||||||
assertTrue(targets[0].evaluateExpressionToString(frame, "a"), targets[0].evaluateExpressionToString(frame, "a").equals("11"));
|
assertTrue(targets[0].evaluateExpressionToString(frame, "a"), targets[0].evaluateExpressionToString(frame, "a").equals("11"));
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
|
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||||
|
@ -116,7 +117,7 @@ public class DebugTests extends TestCase {
|
||||||
*/
|
*/
|
||||||
public void testDebug() throws CoreException, MIException, IOException, CDIException {
|
public void testDebug() throws CoreException, MIException, IOException, CDIException {
|
||||||
ICDITarget cdiTarget;
|
ICDITarget cdiTarget;
|
||||||
ICDILocation location;
|
ICDIFunctionLocation location;
|
||||||
|
|
||||||
session=CDebugHelper.createSession("main",testProject);
|
session=CDebugHelper.createSession("main",testProject);
|
||||||
assertNotNull(session);
|
assertNotNull(session);
|
||||||
|
@ -125,9 +126,9 @@ public class DebugTests extends TestCase {
|
||||||
assertTrue(targets.length > 0);
|
assertTrue(targets.length > 0);
|
||||||
cdiTarget = targets[0];
|
cdiTarget = targets[0];
|
||||||
assertNotNull(cdiTarget);
|
assertNotNull(cdiTarget);
|
||||||
location=cdiTarget.createLocation(null, "func1", 0);
|
location=cdiTarget.createFunctionLocation(null, "func1");
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setFunctionBreakpoint(0, location, null, false);
|
||||||
cdiTarget.resume();
|
cdiTarget.resume();
|
||||||
session.terminate();
|
session.terminate();
|
||||||
session=null;
|
session=null;
|
||||||
|
|
|
@ -12,7 +12,8 @@ import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
|
import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDILineLocation;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
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.ICDIBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
|
||||||
|
@ -115,7 +116,8 @@ public class LocationTests extends TestCase {
|
||||||
*/
|
*/
|
||||||
public void testIsEquals() throws CoreException, MIException, IOException, CDIException {
|
public void testIsEquals() throws CoreException, MIException, IOException, CDIException {
|
||||||
ICDITarget cdiTarget;
|
ICDITarget cdiTarget;
|
||||||
ICDILocation location, location2;
|
ICDILineLocation lineLocation, lineLocation2;
|
||||||
|
ICDIFunctionLocation functionLocation, functionLocation2;
|
||||||
ICDIBreakpoint[] breakpoints;
|
ICDIBreakpoint[] breakpoints;
|
||||||
ICDILocationBreakpoint curbreak;
|
ICDILocationBreakpoint curbreak;
|
||||||
session=CDebugHelper.createSession("main",testProject);
|
session=CDebugHelper.createSession("main",testProject);
|
||||||
|
@ -129,15 +131,15 @@ public class LocationTests extends TestCase {
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Simple test.. this should work.
|
* Simple test.. this should work.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
location=cdiTarget.createLocation("main.c", "func1", 0);
|
functionLocation=cdiTarget.createFunctionLocation("main.c", "func1");
|
||||||
location2=cdiTarget.createLocation("main.c", "func1", 0);
|
functionLocation2=cdiTarget.createFunctionLocation("main.c", "func1");
|
||||||
assertTrue(location.equals(location2));
|
assertTrue(functionLocation.equals(functionLocation2));
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Simple test.. this should work.
|
* Simple test.. this should work.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
location=cdiTarget.createLocation("main.c", null, 10);
|
lineLocation=cdiTarget.createLineLocation("main.c", 10);
|
||||||
location2=cdiTarget.createLocation("main.c", null, 10);
|
lineLocation2=cdiTarget.createLineLocation("main.c", 10);
|
||||||
assertTrue(location.equals(location2));
|
assertTrue(lineLocation.equals(lineLocation2));
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* make sure that the location returned from getLocation on the
|
* make sure that the location returned from getLocation on the
|
||||||
|
@ -145,9 +147,9 @@ public class LocationTests extends TestCase {
|
||||||
* setLocationBreakpoint is the same as the breakpoint returned from
|
* setLocationBreakpoint is the same as the breakpoint returned from
|
||||||
* BreakpointManager.getBreakpoints.getLocation()
|
* BreakpointManager.getBreakpoints.getLocation()
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
location=cdiTarget.createLocation("main.c", "func1", 0);
|
functionLocation=cdiTarget.createFunctionLocation("main.c", "func1");
|
||||||
assertNotNull(location);
|
assertNotNull(functionLocation);
|
||||||
location2=cdiTarget.setLocationBreakpoint(0, location, null, false).getLocation();
|
functionLocation2=cdiTarget.setFunctionBreakpoint(0, functionLocation, null, false).getLocator();
|
||||||
|
|
||||||
breakpoints=cdiTarget.getBreakpoints();
|
breakpoints=cdiTarget.getBreakpoints();
|
||||||
assertNotNull(breakpoints);
|
assertNotNull(breakpoints);
|
||||||
|
@ -158,15 +160,15 @@ public class LocationTests extends TestCase {
|
||||||
curbreak=null;
|
curbreak=null;
|
||||||
assertNotNull(curbreak);
|
assertNotNull(curbreak);
|
||||||
|
|
||||||
assertTrue(curbreak.getLocation().equals(location2));
|
assertTrue(curbreak.getLocator().equals(functionLocation2));
|
||||||
cdiTarget.deleteAllBreakpoints();
|
cdiTarget.deleteAllBreakpoints();
|
||||||
/* Create a break point on a generic function with a file name that
|
/* 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
|
* 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.
|
* should work, but at the time of writing (Sept 25, 2002) does not.
|
||||||
*/
|
*/
|
||||||
location=cdiTarget.createLocation("main.c", "func1", 0);
|
functionLocation=cdiTarget.createFunctionLocation("main.c", "func1");
|
||||||
assertNotNull(location);
|
assertNotNull(functionLocation);
|
||||||
cdiTarget.setLocationBreakpoint(0, location, null, false);
|
cdiTarget.setFunctionBreakpoint(0, functionLocation, null, false);
|
||||||
|
|
||||||
breakpoints=cdiTarget.getBreakpoints();
|
breakpoints=cdiTarget.getBreakpoints();
|
||||||
assertNotNull(breakpoints);
|
assertNotNull(breakpoints);
|
||||||
|
@ -177,7 +179,7 @@ public class LocationTests extends TestCase {
|
||||||
curbreak=null;
|
curbreak=null;
|
||||||
assertNotNull(curbreak);
|
assertNotNull(curbreak);
|
||||||
|
|
||||||
assertTrue("PR:23879",curbreak.getLocation().equals(location));
|
assertTrue("PR:23879",curbreak.getLocator().equals(functionLocation));
|
||||||
|
|
||||||
|
|
||||||
/* clean up the session */
|
/* clean up the session */
|
||||||
|
|
Loading…
Add table
Reference in a new issue