[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
|
Re: [jdt-debug-dev] Common Questions about functionality in jdt.debug.core
|
Darin Wright wrote:
Below is the code I use to set the MethodEntryBreakpoint.
IResource resource = unit.getResource();
String typeName = unit.findPrimaryType().getFullyQualifiedName();
String methodName = "stateChanged";
String methodSig = "";
IMethod[] meths = unit.findPrimaryType().getMethods();
for(int i=0;i < meths.length;i++){
if(meths[i].getElementName().equalsIgnoreCase(methodName)){
methodName = meths[i].getElementName();
methodSig = meths[i].getSignature();
}
}
int line = 111;
This code looks reasonable - are you positive that a matching method is
found in the for loop? (you could add a "break" statement to avoid
searching all methods when the first match is found).
I am pretty confident that it chooses the correct method. When invoking
the run action on my plugin from a run-time workbench, the breakpoints
show up in the Debug Perspective - Breakpoints View for the type I
create them in, the marker's also show up in the Ruler.
Map attributes = new HashMap(3);
attributes.put("PATTINFO","This is just a marker explanation");;
attributes.put(IMarker.LINE_NUMBER,"111");
You don't need to specify the LINE_NUMBER attribute, it will be set by the
breakpoint via the line number you specify in the creation call.
attributes.put(IMarker.MESSAGE,"This is a message for the hover");
BreakpointUtils.addJavaBreakpointAttributes(attributes, unit);
IJavaMethodEntryBreakpoint br =
JDIDebugModel.createMethodEntryBreakpoint(resource,typeName, methodName,
methodSig, line, -1, -1,0,true,null);
Although you created an extra attributes map, you did not pass it into the
contructor (i.e. the last argument is "null").
Is there something I need to do after this to install the breakpoint?
Even if I call
Since you have specified "true" for the "register" breakpoint argument in
the creation call (second last argument), you do not need to add the
breakpoint to the breakpoint manager manually - this will be done for you.
When the breakpoint is added to the manager, debug targets will be
notified and install the breakpoint. If you were to specify "false" for
registering the breakpoint, you would need to add the breakpoint to the
debug target manually via its IBreakpointListener inteface.
Thanks for the tips. Perhaps I am not launching the code properly?
After I have used .create*Breakpoint I call a method to launch using the
code taken from help/topic/org.eclipse.jdt.doc.isv/guide/jdt_api_run.htm
ILaunch launch = new Launch(null, ILaunchManager.DEBUG_MODE, null);
vmRunner.run(vmConfig, launch, null);
I've tried using launch.getDebugTarget(), casting it to a
IJavaDebugTarget then passing this to my
IJavaBreakpointListener.installingBreakpoint(..) method to install the
breakpoint, but I get Class cast exceptions.
Sorry to be taking up your time like this. Is there something more I am
missing?
Thanks again.
Joe
Darin
_______________________________________________
jdt-debug-dev mailing list
jdt-debug-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/jdt-debug-dev