use of com.sun.jdi.request.ClassPrepareRequest in project che by eclipse.
the class JavaDebugger method deferBreakpoint.
private void deferBreakpoint(Breakpoint breakpoint) throws DebuggerException {
final String className = breakpoint.getLocation().getTarget();
List<Breakpoint> newList = new ArrayList<>();
List<Breakpoint> list = deferredBreakpoints.putIfAbsent(className, newList);
if (list == null) {
list = newList;
}
list.add(breakpoint);
// start listening for the load of the type
if (!classPrepareRequests.containsKey(className)) {
ClassPrepareRequest request = getEventManager().createClassPrepareRequest();
// set class filter in order to reduce the amount of event traffic sent from the target VM to the debugger VM
request.addClassFilter(className);
request.enable();
classPrepareRequests.put(className, request);
}
LOG.debug("Deferred breakpoint: {}", breakpoint.getLocation().toString());
}
use of com.sun.jdi.request.ClassPrepareRequest in project jdk8u_jdk by JetBrains.
the class PatternReferenceTypeSpec method createPrepareRequest.
@Override
public ClassPrepareRequest createPrepareRequest() {
ClassPrepareRequest request = Env.vm().eventRequestManager().createClassPrepareRequest();
request.addClassFilter(classId);
request.addCountFilter(1);
return request;
}
use of com.sun.jdi.request.ClassPrepareRequest in project che by eclipse.
the class JavaDebugger method processClassPrepareEvent.
private boolean processClassPrepareEvent(com.sun.jdi.event.ClassPrepareEvent event) throws DebuggerException {
setCurrentThread(event.thread());
final String className = event.referenceType().name();
// add deferred breakpoints
List<Breakpoint> breakpointsToAdd = deferredBreakpoints.get(className);
if (breakpointsToAdd != null) {
for (Breakpoint b : breakpointsToAdd) {
addBreakpoint(b);
}
deferredBreakpoints.remove(className);
// All deferred breakpoints for className have been already added,
// so no need to listen for an appropriate ClassPrepareRequests any more.
ClassPrepareRequest request = classPrepareRequests.remove(className);
if (request != null) {
getEventManager().deleteEventRequest(request);
}
}
return true;
}
use of com.sun.jdi.request.ClassPrepareRequest in project gravel by gravel-st.
the class VMTargetStarter method createJVM.
public VMRemoteTarget createJVM() throws IOException, InterruptedException, IncompatibleThreadStateException {
Process process = startSecondJVM(VMLocalTarget.class);
sleep(90);
// connect
VirtualMachine vm = new VMAcquirer().connect(debugPort);
ClassPrepareRequest createClassPrepareRequest = vm.eventRequestManager().createClassPrepareRequest();
createClassPrepareRequest.addClassFilter(VMLocalTarget.class.getName());
createClassPrepareRequest.enable();
vm.resume();
List<ThreadReference> allThreads = vm.allThreads();
for (ThreadReference threadReference : allThreads) {
System.out.println(threadReference + " isSuspended: " + threadReference.isSuspended() + " suspendCount: " + threadReference.suspendCount());
}
// process events
EventQueue eventQueue = vm.eventQueue();
while (true) {
EventSet eventSet = eventQueue.remove();
for (Event event : eventSet) {
if (event instanceof ClassPrepareEvent) {
event.request().disable();
installHaltPoint(vm);
}
if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
return null;
}
if (event instanceof BreakpointEvent) {
event.request().disable();
ThreadReference thread = ((BreakpointEvent) event).thread();
return new VMRemoteTarget(process, vm, thread, debugPort);
}
}
eventSet.resume();
}
}
use of com.sun.jdi.request.ClassPrepareRequest in project intellij-community by JetBrains.
the class MethodBreakpoint method createRequestForSubClasses.
private static void createRequestForSubClasses(@NotNull MethodBreakpointBase breakpoint, @NotNull DebugProcessImpl debugProcess, @NotNull ReferenceType baseType) {
DebuggerManagerThreadImpl.assertIsManagerThread();
RequestManagerImpl requestsManager = debugProcess.getRequestsManager();
ClassPrepareRequest request = requestsManager.createClassPrepareRequest((debuggerProcess, referenceType) -> {
if (instanceOf(referenceType, baseType)) {
createRequestForPreparedClassEmulated(breakpoint, debugProcess, referenceType, false);
}
}, null);
if (request != null) {
requestsManager.registerRequest(breakpoint, request);
request.enable();
// to force reload classes available so far
debugProcess.getVirtualMachineProxy().clearCaches();
}
AtomicReference<ProgressIndicator> indicatorRef = new AtomicReference<>();
ApplicationManager.getApplication().invokeAndWait(() -> indicatorRef.set(new ProgressWindowWithNotification(true, false, debugProcess.getProject(), "Cancel emulation")));
ProgressIndicator indicator = indicatorRef.get();
ProgressManager.getInstance().executeProcessUnderProgress(() -> processPreparedSubTypes(baseType, subType -> createRequestForPreparedClassEmulated(breakpoint, debugProcess, subType, false), indicator), indicator);
if (indicator.isCanceled()) {
breakpoint.disableEmulation();
}
}
Aggregations