Lines 52-57
Link Here
|
52 |
import com.sun.jdi.ThreadReference; |
52 |
import com.sun.jdi.ThreadReference; |
53 |
import com.sun.jdi.VMDisconnectedException; |
53 |
import com.sun.jdi.VMDisconnectedException; |
54 |
import com.sun.jdi.VirtualMachine; |
54 |
import com.sun.jdi.VirtualMachine; |
|
|
55 |
import com.sun.jdi.connect.Connector; |
55 |
import com.sun.jdi.event.BreakpointEvent; |
56 |
import com.sun.jdi.event.BreakpointEvent; |
56 |
import com.sun.jdi.event.Event; |
57 |
import com.sun.jdi.event.Event; |
57 |
import com.sun.jdi.request.BreakpointRequest; |
58 |
import com.sun.jdi.request.BreakpointRequest; |
Lines 59-83
Link Here
|
59 |
import java.beans.PropertyChangeEvent; |
60 |
import java.beans.PropertyChangeEvent; |
60 |
import java.beans.PropertyChangeListener; |
61 |
import java.beans.PropertyChangeListener; |
61 |
import java.lang.reflect.InvocationTargetException; |
62 |
import java.lang.reflect.InvocationTargetException; |
62 |
|
|
|
63 |
import java.util.Collections; |
63 |
import java.util.Collections; |
|
|
64 |
import java.util.HashMap; |
64 |
import java.util.List; |
65 |
import java.util.List; |
|
|
66 |
import java.util.Map; |
65 |
import java.util.Set; |
67 |
import java.util.Set; |
|
|
68 |
import java.util.concurrent.locks.Lock; |
66 |
import java.util.logging.Level; |
69 |
import java.util.logging.Level; |
67 |
import java.util.logging.Logger; |
70 |
import java.util.logging.Logger; |
68 |
import javax.swing.SwingUtilities; |
71 |
import javax.swing.SwingUtilities; |
69 |
import org.netbeans.api.debugger.ActionsManager; |
72 |
import org.netbeans.api.debugger.ActionsManager; |
70 |
import org.netbeans.api.debugger.ActionsManagerListener; |
73 |
import org.netbeans.api.debugger.ActionsManagerListener; |
71 |
import org.netbeans.api.debugger.DebuggerManager; |
74 |
import org.netbeans.api.debugger.DebuggerManager; |
72 |
import org.netbeans.spi.debugger.ContextProvider; |
|
|
73 |
import org.netbeans.api.debugger.Session; |
75 |
import org.netbeans.api.debugger.Session; |
|
|
76 |
import org.netbeans.api.debugger.SessionBridge; |
77 |
import org.netbeans.api.debugger.jpda.AttachingDICookie; |
74 |
import org.netbeans.api.debugger.jpda.CallStackFrame; |
78 |
import org.netbeans.api.debugger.jpda.CallStackFrame; |
75 |
import org.netbeans.api.debugger.jpda.ClassLoadUnloadBreakpoint; |
79 |
import org.netbeans.api.debugger.jpda.ClassLoadUnloadBreakpoint; |
76 |
import org.netbeans.api.debugger.jpda.JPDADebugger; |
80 |
import org.netbeans.api.debugger.jpda.JPDADebugger; |
77 |
import org.netbeans.api.debugger.jpda.event.JPDABreakpointListener; |
|
|
78 |
import org.netbeans.api.debugger.jpda.event.JPDABreakpointEvent; |
79 |
import org.netbeans.api.debugger.jpda.JPDAStep; |
81 |
import org.netbeans.api.debugger.jpda.JPDAStep; |
80 |
import org.netbeans.api.debugger.jpda.JPDAThread; |
82 |
import org.netbeans.api.debugger.jpda.JPDAThread; |
|
|
83 |
import org.netbeans.api.debugger.jpda.ListeningDICookie; |
84 |
import org.netbeans.api.debugger.jpda.event.JPDABreakpointEvent; |
85 |
import org.netbeans.api.debugger.jpda.event.JPDABreakpointListener; |
81 |
import org.netbeans.modules.debugger.jpda.EditorContextBridge; |
86 |
import org.netbeans.modules.debugger.jpda.EditorContextBridge; |
82 |
import org.netbeans.modules.debugger.jpda.ExpressionPool.Expression; |
87 |
import org.netbeans.modules.debugger.jpda.ExpressionPool.Expression; |
83 |
import org.netbeans.modules.debugger.jpda.ExpressionPool.Interval; |
88 |
import org.netbeans.modules.debugger.jpda.ExpressionPool.Interval; |
Lines 97-114
Link Here
|
97 |
import org.netbeans.modules.debugger.jpda.jdi.VirtualMachineWrapper; |
102 |
import org.netbeans.modules.debugger.jpda.jdi.VirtualMachineWrapper; |
98 |
import org.netbeans.modules.debugger.jpda.jdi.request.EventRequestManagerWrapper; |
103 |
import org.netbeans.modules.debugger.jpda.jdi.request.EventRequestManagerWrapper; |
99 |
import org.netbeans.modules.debugger.jpda.jdi.request.EventRequestWrapper; |
104 |
import org.netbeans.modules.debugger.jpda.jdi.request.EventRequestWrapper; |
100 |
import org.netbeans.spi.debugger.ActionsProviderSupport; |
|
|
101 |
import org.openide.DialogDisplayer; |
102 |
import org.openide.NotifyDescriptor; |
103 |
|
104 |
import org.netbeans.modules.debugger.jpda.models.CallStackFrameImpl; |
105 |
import org.netbeans.modules.debugger.jpda.models.CallStackFrameImpl; |
105 |
import org.netbeans.modules.debugger.jpda.models.JPDAThreadImpl; |
106 |
import org.netbeans.modules.debugger.jpda.models.JPDAThreadImpl; |
106 |
import org.netbeans.modules.debugger.jpda.util.Executor; |
107 |
import org.netbeans.modules.debugger.jpda.util.Executor; |
107 |
import org.netbeans.spi.debugger.ActionsProvider; |
108 |
import org.netbeans.spi.debugger.ActionsProvider; |
|
|
109 |
import org.netbeans.spi.debugger.ActionsProviderSupport; |
110 |
import org.netbeans.spi.debugger.ContextProvider; |
108 |
import org.netbeans.spi.debugger.jpda.EditorContext; |
111 |
import org.netbeans.spi.debugger.jpda.EditorContext; |
109 |
import org.netbeans.spi.debugger.jpda.EditorContext.Operation; |
112 |
import org.netbeans.spi.debugger.jpda.EditorContext.Operation; |
|
|
113 |
import org.openide.DialogDisplayer; |
110 |
import org.openide.ErrorManager; |
114 |
import org.openide.ErrorManager; |
111 |
|
115 |
import org.openide.NotifyDescriptor; |
112 |
import org.openide.util.Exceptions; |
116 |
import org.openide.util.Exceptions; |
113 |
import org.openide.util.NbBundle; |
117 |
import org.openide.util.NbBundle; |
114 |
|
118 |
|
Lines 321-326
Link Here
|
321 |
Expression expr = debugger.getExpressionPool().getExpressionAt(locations.get(0), url); |
325 |
Expression expr = debugger.getExpressionPool().getExpressionAt(locations.get(0), url); |
322 |
Location bpLocation = null; |
326 |
Location bpLocation = null; |
323 |
Interval expressionLines = null; |
327 |
Interval expressionLines = null; |
|
|
328 |
String methodClassType = null; |
329 |
boolean isNative = false; |
324 |
if (expr != null) { |
330 |
if (expr != null) { |
325 |
Operation[] ops = expr.getOperations(); |
331 |
Operation[] ops = expr.getOperations(); |
326 |
for (int i = 0; i < ops.length; i++) { |
332 |
for (int i = 0; i < ops.length; i++) { |
Lines 329-334
Link Here
|
329 |
methodOffset <= op.getMethodEndPosition().getOffset()) { |
335 |
methodOffset <= op.getMethodEndPosition().getOffset()) { |
330 |
|
336 |
|
331 |
bpLocation = expr.getLocations()[i]; |
337 |
bpLocation = expr.getLocations()[i]; |
|
|
338 |
methodClassType = op.getMethodClassType(); |
339 |
isNative = op.isNative(); |
332 |
break; |
340 |
break; |
333 |
} |
341 |
} |
334 |
} |
342 |
} |
Lines 337-359
Link Here
|
337 |
if (bpLocation == null) { |
345 |
if (bpLocation == null) { |
338 |
bpLocation = locations.get(0); |
346 |
bpLocation = locations.get(0); |
339 |
} |
347 |
} |
340 |
doAction(debugger, methodName, bpLocation, expressionLines, false, doResume, |
348 |
doAction(debugger, methodName, methodClassType, isNative, bpLocation, |
341 |
MethodChooserSupport.MethodEntry.SELECTED); |
349 |
expressionLines, false, doResume, |
|
|
350 |
MethodChooserSupport.MethodEntry.SELECTED); |
342 |
} |
351 |
} |
343 |
|
352 |
|
344 |
static boolean doAction(final JPDADebuggerImpl debugger, |
353 |
static boolean doAction(final JPDADebuggerImpl debugger, |
345 |
final String methodName, |
354 |
final String methodName, |
|
|
355 |
final String methodClassType, |
356 |
final boolean isNative, |
346 |
Location bpLocation, |
357 |
Location bpLocation, |
347 |
Interval expressionLines, |
358 |
Interval expressionLines, |
348 |
// If it's important not to run far from the expression |
359 |
// If it's important not to run far from the expression |
349 |
boolean setBoundaryStep, |
360 |
boolean setBoundaryStep, |
350 |
MethodChooserSupport.MethodEntry methodEntry) { |
361 |
MethodChooserSupport.MethodEntry methodEntry) { |
351 |
|
362 |
|
352 |
return doAction(debugger, methodName, bpLocation, expressionLines, setBoundaryStep, true, methodEntry); |
363 |
return doAction(debugger, methodName, methodClassType, isNative, bpLocation, expressionLines, setBoundaryStep, true, methodEntry); |
353 |
} |
364 |
} |
354 |
|
365 |
|
355 |
private static boolean doAction(final JPDADebuggerImpl debugger, |
366 |
private static boolean doAction(final JPDADebuggerImpl debugger, |
356 |
final String methodName, |
367 |
final String methodName, |
|
|
368 |
final String methodClassType, |
369 |
final boolean isNative, |
357 |
Location bpLocation, |
370 |
Location bpLocation, |
358 |
// If it's important not to run far from the expression |
371 |
// If it's important not to run far from the expression |
359 |
Interval expressionLines, |
372 |
Interval expressionLines, |
Lines 395-402
Link Here
|
395 |
logger.log(Level.FINE, "doAction() areWeOnTheLocation = {0}, methodName = {1}", new Object[]{areWeOnTheLocation, methodName}); |
408 |
logger.log(Level.FINE, "doAction() areWeOnTheLocation = {0}, methodName = {1}", new Object[]{areWeOnTheLocation, methodName}); |
396 |
if (areWeOnTheLocation) { |
409 |
if (areWeOnTheLocation) { |
397 |
// We're on the line from which the method is called |
410 |
// We're on the line from which the method is called |
398 |
traceLineForMethod(debugger, ct.getThreadReference(), methodName, |
411 |
traceLineForMethod(debugger, ct, methodName, |
399 |
line, doFinishWhenMethodNotFound, methodEntry); |
412 |
methodClassType, isNative, line, |
|
|
413 |
doFinishWhenMethodNotFound, methodEntry); |
400 |
} else { |
414 |
} else { |
401 |
final JPDAStep[] boundaryStepPtr = new JPDAStep[] { null }; |
415 |
final JPDAStep[] boundaryStepPtr = new JPDAStep[] { null }; |
402 |
// Submit the breakpoint to get to the point from which the method is called |
416 |
// Submit the breakpoint to get to the point from which the method is called |
Lines 465-472
Link Here
|
465 |
} catch (VMDisconnectedExceptionWrapper e) { |
479 |
} catch (VMDisconnectedExceptionWrapper e) { |
466 |
return false; |
480 |
return false; |
467 |
} |
481 |
} |
468 |
traceLineForMethod(debugger, tr, methodName, line, |
482 |
traceLineForMethod(debugger, t, methodName, methodClassType, |
469 |
doFinishWhenMethodNotFound, methodEntry); |
483 |
isNative, line, doFinishWhenMethodNotFound, |
|
|
484 |
methodEntry); |
470 |
return true; |
485 |
return true; |
471 |
} |
486 |
} |
472 |
|
487 |
|
Lines 545-557
Link Here
|
545 |
} |
560 |
} |
546 |
|
561 |
|
547 |
private static void traceLineForMethod(final JPDADebuggerImpl debugger, |
562 |
private static void traceLineForMethod(final JPDADebuggerImpl debugger, |
548 |
final ThreadReference tr, |
563 |
final JPDAThreadImpl jtr, |
549 |
final String method, |
564 |
final String method, |
|
|
565 |
final String methodClassType, |
566 |
final boolean isNative, |
550 |
final int methodLine, |
567 |
final int methodLine, |
551 |
final boolean finishWhenNotFound, |
568 |
final boolean finishWhenNotFound, |
552 |
final MethodChooserSupport.MethodEntry methodEntry) { |
569 |
final MethodChooserSupport.MethodEntry methodEntry) { |
553 |
final JPDAThread jtr = debugger.getThread(tr); |
570 |
//ThreadReference tr = jtr.getThreadReference(); |
554 |
final int depth = jtr.getStackDepth(); |
571 |
final int depth = jtr.getStackDepth(); |
|
|
572 |
//System.err.println("traceLineForMethod: stepping into native method "+methodClassType+"."+method+" = "+isNative); |
573 |
if (isNative) { |
574 |
Map<Object, Object> properties = new HashMap<Object, Object>(); |
575 |
properties.put("javaClass", methodClassType); |
576 |
properties.put("javaMethod", method); |
577 |
Session session = debugger.getSession(); |
578 |
putConnectionProperties(session, properties); |
579 |
final Lock writeLock = jtr.accessLock.writeLock(); |
580 |
writeLock.lock(); |
581 |
boolean changed = SessionBridge.getDefault().suggestChange( |
582 |
session, |
583 |
(String) ActionsManager.ACTION_STEP_INTO, |
584 |
properties); |
585 |
if (changed) { |
586 |
writeLock.unlock(); |
587 |
jtr.resume(); |
588 |
return ; |
589 |
} else { |
590 |
writeLock.unlock(); |
591 |
} |
592 |
} |
555 |
final JPDAStep step = debugger.createJPDAStep(JPDAStep.STEP_LINE, JPDAStep.STEP_INTO); |
593 |
final JPDAStep step = debugger.createJPDAStep(JPDAStep.STEP_LINE, JPDAStep.STEP_INTO); |
556 |
step.setHidden(true); |
594 |
step.setHidden(true); |
557 |
logger.log(Level.FINE, "Will traceLineForMethod({0}, {1}, {2})", |
595 |
logger.log(Level.FINE, "Will traceLineForMethod({0}, {1}, {2})", |
Lines 628-633
Link Here
|
628 |
}); |
666 |
}); |
629 |
step.addStep(jtr); |
667 |
step.addStep(jtr); |
630 |
} |
668 |
} |
|
|
669 |
|
670 |
private static void putConnectionProperties(Session session, Map properties) { |
671 |
ListeningDICookie lc = session.lookupFirst(null, ListeningDICookie.class); |
672 |
Map<String, ? extends Connector.Argument> args = null; |
673 |
if (lc != null) { |
674 |
args = lc.getArgs(); |
675 |
properties.put("conn_port", lc.getPortNumber()); |
676 |
properties.put("conn_shmem", lc.getSharedMemoryName()); |
677 |
} else { |
678 |
AttachingDICookie ac = session.lookupFirst(null, AttachingDICookie.class); |
679 |
if (ac != null) { |
680 |
args = ac.getArgs(); |
681 |
properties.put("conn_host", ac.getHostName()); |
682 |
properties.put("conn_port", ac.getPortNumber()); |
683 |
properties.put("conn_shmem", ac.getSharedMemoryName()); |
684 |
properties.put("conn_pid", ac.getProcessID()); |
685 |
} |
686 |
} |
687 |
} |
631 |
|
688 |
|
632 |
@Override |
689 |
@Override |
633 |
public void actionPerformed(Object action) { |
690 |
public void actionPerformed(Object action) { |