use of com.sun.jdi.request.MethodEntryRequest in project HotswapAgent by HotswapProjects.
the class HotSwapperJpda method methodEntryRequests.
private static MethodEntryRequest methodEntryRequests(EventRequestManager manager, String classpattern) {
MethodEntryRequest mereq = manager.createMethodEntryRequest();
mereq.addClassFilter(classpattern);
mereq.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
return mereq;
}
use of com.sun.jdi.request.MethodEntryRequest in project warn-report by saaavsaaa.
the class debugger method rTest.
@Test
public void rTest() throws Exception {
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
List<AttachingConnector> connectors = vmm.attachingConnectors();
SocketAttachingConnector sac = null;
for (AttachingConnector ac : connectors) {
if (ac instanceof SocketAttachingConnector) {
sac = (SocketAttachingConnector) ac;
break;
}
}
if (sac == null) {
System.out.println("JDI error");
return;
}
Map arguments = sac.defaultArguments();
Connector.Argument hostArg = (Connector.Argument) arguments.get(HOST);
Connector.Argument portArg = (Connector.Argument) arguments.get(PORT);
hostArg.setValue("127.0.0.1");
portArg.setValue(String.valueOf(9999));
vm = sac.attach(arguments);
List<ReferenceType> classesByName = vm.classesByName("cn.tellwhy.DailyTest");
if (classesByName == null || classesByName.size() == 0) {
System.out.println("No class found");
return;
}
ReferenceType rt = classesByName.get(0);
List<Method> methodsByName = rt.methodsByName("daily");
if (methodsByName == null || methodsByName.size() == 0) {
System.out.println("No method found");
return;
}
Method method = methodsByName.get(0);
vm.setDebugTraceMode(VirtualMachine.TRACE_EVENTS);
vm.resume();
EventRequestManager erm = vm.eventRequestManager();
MethodEntryRequest methodEntryRequest = erm.createMethodEntryRequest();
methodEntryRequest.addClassFilter(rt);
methodEntryRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
methodEntryRequest.enable();
BreakpointRequest breakpointRequest = erm.createBreakpointRequest(method.location());
breakpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
breakpointRequest.enable();
eventLoop();
}
use of com.sun.jdi.request.MethodEntryRequest in project intellij-community by JetBrains.
the class MethodBreakpoint method createRequestForPreparedClassOriginal.
private void createRequestForPreparedClassOriginal(@NotNull DebugProcessImpl debugProcess, @NotNull ReferenceType classType) {
try {
boolean hasMethod = false;
for (Method method : classType.allMethods()) {
String signature = method.signature();
String name = method.name();
if (getMethodName().equals(name) && mySignature.getName(debugProcess).equals(signature)) {
hasMethod = true;
break;
}
}
if (!hasMethod) {
debugProcess.getRequestsManager().setInvalid(this, DebuggerBundle.message("error.invalid.breakpoint.method.not.found", classType.name()));
return;
}
RequestManagerImpl requestManager = debugProcess.getRequestsManager();
if (isWatchEntry()) {
MethodEntryRequest entryRequest = findRequest(debugProcess, MethodEntryRequest.class, this);
if (entryRequest == null) {
entryRequest = requestManager.createMethodEntryRequest(this);
} else {
entryRequest.disable();
}
//entryRequest.addClassFilter(myClassQualifiedName);
// use addClassFilter(ReferenceType) in order to stop on subclasses also!
entryRequest.addClassFilter(classType);
debugProcess.getRequestsManager().enableRequest(entryRequest);
}
if (isWatchExit()) {
MethodExitRequest exitRequest = findRequest(debugProcess, MethodExitRequest.class, this);
if (exitRequest == null) {
exitRequest = requestManager.createMethodExitRequest(this);
} else {
exitRequest.disable();
}
//exitRequest.addClassFilter(myClassQualifiedName);
exitRequest.addClassFilter(classType);
debugProcess.getRequestsManager().enableRequest(exitRequest);
}
} catch (Exception e) {
LOG.debug(e);
}
}
use of com.sun.jdi.request.MethodEntryRequest in project intellij-community by JetBrains.
the class WildcardMethodBreakpoint method createRequest.
public void createRequest(DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
if (!shouldCreateRequest(debugProcess)) {
return;
}
if (isEmulated()) {
createOrWaitPrepare(debugProcess, getClassPattern());
} else {
try {
RequestManagerImpl requestManager = debugProcess.getRequestsManager();
if (isWatchEntry()) {
MethodEntryRequest entryRequest = MethodBreakpoint.findRequest(debugProcess, MethodEntryRequest.class, this);
if (entryRequest == null) {
entryRequest = requestManager.createMethodEntryRequest(this);
} else {
entryRequest.disable();
}
entryRequest.addClassFilter(getClassPattern());
debugProcess.getRequestsManager().enableRequest(entryRequest);
}
if (isWatchExit()) {
MethodExitRequest exitRequest = MethodBreakpoint.findRequest(debugProcess, MethodExitRequest.class, this);
if (exitRequest == null) {
exitRequest = requestManager.createMethodExitRequest(this);
} else {
exitRequest.disable();
}
exitRequest.addClassFilter(getClassPattern());
debugProcess.getRequestsManager().enableRequest(exitRequest);
}
} catch (Exception e) {
LOG.debug(e);
}
}
}
Aggregations