本文整理汇总了Java中com.sun.jdi.request.EventRequestManager类的典型用法代码示例。如果您正苦于以下问题:Java EventRequestManager类的具体用法?Java EventRequestManager怎么用?Java EventRequestManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventRequestManager类属于com.sun.jdi.request包,在下文中一共展示了EventRequestManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setEventRequests
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
private void setEventRequests(VirtualMachine vm) {
EventRequestManager erm = vm.eventRequestManager();
// Normally, we want all uncaught exceptions. We request them
// via the same mechanism as Commands.commandCatchException()
// so the user can ignore them later if they are not
// interested.
// FIXME: this works but generates spurious messages on stdout
// during startup:
// Set uncaught java.lang.Throwable
// Set deferred uncaught java.lang.Throwable
Commands evaluator = new Commands();
evaluator.commandCatchException
(new StringTokenizer("uncaught java.lang.Throwable"));
ThreadStartRequest tsr = erm.createThreadStartRequest();
tsr.enable();
ThreadDeathRequest tdr = erm.createThreadDeathRequest();
tdr.enable();
}
示例2: addBreakpoint
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
private static void addBreakpoint(VirtualMachine vm, ReferenceType refType) {
Location breakpointLocation = null;
List<Location> locs;
try {
locs = refType.allLineLocations();
for (Location loc: locs) {
if (loc.method().name().equals(METHOD_NAME)) {
breakpointLocation = loc;
break;
}
}
} catch (AbsentInformationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (breakpointLocation != null) {
EventRequestManager evtReqMgr = vm.eventRequestManager();
BreakpointRequest bReq = evtReqMgr.createBreakpointRequest(breakpointLocation);
bReq.setSuspendPolicy(BreakpointRequest.SUSPEND_ALL);
bReq.enable();
}
}
示例3: stopOnEntry
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
/**
* Suspend the main thread when the program enters the main method of the specified main class.
* @param debugSession
* the debug session.
* @param mainClass
* the fully qualified name of the main class.
* @return
* a {@link CompletableFuture} that contains the suspended main thread id.
*/
public static CompletableFuture<Long> stopOnEntry(IDebugSession debugSession, String mainClass) {
CompletableFuture<Long> future = new CompletableFuture<>();
EventRequestManager manager = debugSession.getVM().eventRequestManager();
MethodEntryRequest request = manager.createMethodEntryRequest();
request.addClassFilter(mainClass);
request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
debugSession.getEventHub().events().filter(debugEvent -> {
return debugEvent.event instanceof MethodEntryEvent && request.equals(debugEvent.event.request());
}).subscribe(debugEvent -> {
Method method = ((MethodEntryEvent) debugEvent.event).method();
if (method.isPublic() && method.isStatic() && method.name().equals("main")
&& method.signature().equals("([Ljava/lang/String;)V")) {
deleteEventRequestSafely(debugSession.getVM().eventRequestManager(), request);
debugEvent.shouldResume = false;
ThreadReference bpThread = ((MethodEntryEvent) debugEvent.event).thread();
future.complete(bpThread.uniqueID());
}
});
request.enable();
return future;
}
示例4: perform
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
@Override
public void perform(String[] argv, Context ctx) {
EventRequestManager manager = ctx.getVm().eventRequestManager();
MethodEntryRequest mer = manager.createMethodEntryRequest();
mer.setSuspendPolicy(EventRequest.SUSPEND_NONE);
mer.enable();
ctx.register(mer, new EventCallback() {
@Override
public void handleEvent(Event event) {
MethodEntryEvent mee = (MethodEntryEvent) event;
Method method = mee.method();
System.out.println("--" + method.name());
// mee.thread().resume();
}
});
}
示例5: deleteStepRequests
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
void deleteStepRequests(@Nullable final ThreadReference stepThread) {
EventRequestManager requestManager = getVirtualMachineProxy().eventRequestManager();
List<StepRequest> stepRequests = requestManager.stepRequests();
if (!stepRequests.isEmpty()) {
final List<StepRequest> toDelete = new ArrayList<StepRequest>(stepRequests.size());
for (final StepRequest request : stepRequests) {
ThreadReference threadReference = request.thread();
// [jeka] on attempt to delete a request assigned to a thread with unknown status, a JDWP error occurs
try {
if (threadReference.status() != ThreadReference.THREAD_STATUS_UNKNOWN && (stepThread == null || stepThread.equals(threadReference))) {
toDelete.add(request);
}
}
catch (IllegalThreadStateException e) {
LOG.info(e); // undocumented by JDI: may be thrown when querying thread status
}
catch (ObjectCollectedException ignored) {
}
}
requestManager.deleteEventRequests(toDelete);
}
}
示例6: deleteBreakpoint
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
@Override
public void deleteBreakpoint(Location location) throws DebuggerException {
final String className = debuggerUtil.findFqnByPosition(location);
final int lineNumber = location.getLineNumber();
EventRequestManager requestManager = getEventManager();
List<BreakpointRequest> snapshot = new ArrayList<>(requestManager.breakpointRequests());
for (BreakpointRequest breakpointRequest : snapshot) {
com.sun.jdi.Location jdiLocation = breakpointRequest.location();
if (jdiLocation.declaringType().name().equals(className)
&& jdiLocation.lineNumber() == lineNumber) {
requestManager.deleteEventRequest(breakpointRequest);
LOG.debug("Delete breakpoint: {}", location);
}
}
List<Breakpoint> defferedByClass = deferredBreakpoints.get(className);
if (defferedByClass != null) {
defferedByClass.removeIf(
breakpoint -> {
Location l = breakpoint.getLocation();
return l.getLineNumber() == location.getLineNumber()
&& l.getTarget().equals(location.getTarget());
});
}
}
示例7: setEventRequests
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
private void setEventRequests(VirtualMachine vm) {
EventRequestManager erm = vm.eventRequestManager();
// Normally, we want all uncaught exceptions. We request them
// via the same mechanism as Commands.commandCatchException()
// so the user can ignore them later if they are not
// interested.
// FIXME: this works but generates spurious messages on stdout
// during startup:
// Set uncaught java.lang.Throwable
// Set deferred uncaught java.lang.Throwable
Commands evaluator = new Commands(env);
evaluator.commandCatchException
(new StringTokenizer("uncaught java.lang.Throwable"));
ThreadStartRequest tsr = erm.createThreadStartRequest();
tsr.enable();
ThreadDeathRequest tdr = erm.createThreadDeathRequest();
tdr.enable();
}
示例8: createRequest
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected void createRequest()
{
final EventRequestManager manager = owner.getEventRequestManager();
if (manager != null)
{
try
{
final ClassPrepareRequest request = manager.createClassPrepareRequest();
owner.jdiManager().modelFilter().filter(request);
request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
request.enable();
owner.addJDIEventListener(this, request);
}
catch (final RuntimeException e)
{
JiveDebugPlugin.log(e);
}
}
}
示例9: removeFieldRequests
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected void removeFieldRequests(final JDIDebugTarget target)
{
final EventRequestManager manager = target.getEventRequestManager();
if (manager != null && !fieldRequests.isEmpty())
{
try
{
manager.deleteEventRequests(fieldRequests);
for (final EventRequest request : fieldRequests)
{
target.removeJDIEventListener(
request instanceof AccessWatchpointRequest ? fieldReadHandler : fieldWriteHandler,
request);
}
}
catch (final RuntimeException e)
{
JiveDebugPlugin.log(e);
}
}
}
示例10: removeRequest
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected void removeRequest()
{
final EventRequestManager manager = owner.getEventRequestManager();
if (manager != null && request != null)
{
try
{
owner.removeJDIEventListener(this, request);
manager.deleteEventRequest(request);
request = null;
}
catch (final RuntimeException e)
{
JiveDebugPlugin.log(e);
}
}
}
示例11: createRequest
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected void createRequest()
{
final EventRequestManager manager = getEventRequestManager();
if (manager != null)
{
try
{
if (stepRequest != null)
{
removeRequest();
}
stepRequest = manager.createStepRequest(getUnderlyingThread(), StepRequest.STEP_LINE,
StepRequest.STEP_INTO);
final JiveDebugTarget target = (JiveDebugTarget) getDebugTarget();
final IModelFilter requestFilter = target.jdiManager().modelFilter();
requestFilter.filter(stepRequest);
stepRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
stepRequest.enable();
addJDIEventListener(this, stepRequest);
}
catch (final RuntimeException e)
{
logError(e);
}
}
}
示例12: removeRequest
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected void removeRequest()
{
final EventRequestManager manager = getEventRequestManager();
if (manager != null && stepRequest != null)
{
try
{
removeJDIEventListener(this, stepRequest);
manager.deleteEventRequest(stepRequest);
stepRequest = null;
}
catch (final RuntimeException e)
{
logError(e);
}
}
}
示例13: createRequest
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
@Override
protected void createRequest()
{
final EventRequestManager manager = getEventRequestManager();
if (manager != null)
{
try
{
final EventRequest request = manager.createThreadDeathRequest();
request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
request.enable();
addJDIEventListener(this, request);
}
catch (final RuntimeException e)
{
logError(e);
}
}
}
示例14: HotSwapperJpda
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
/**
* Connects to the JVM.
*
* @param port the port number used for the connection to the JVM.
*/
public HotSwapperJpda(String port)
throws IOException, IllegalConnectorArgumentsException {
jvm = null;
request = null;
newClassFiles = null;
trigger = new Trigger();
AttachingConnector connector
= (AttachingConnector) findConnector("com.sun.jdi.SocketAttach");
Map arguments = connector.defaultArguments();
((Connector.Argument) arguments.get("hostname")).setValue(HOST_NAME);
((Connector.Argument) arguments.get("port")).setValue(port);
jvm = connector.attach(arguments);
EventRequestManager manager = jvm.eventRequestManager();
request = methodEntryRequests(manager, TRIGGER_NAME);
}
示例15: getEventRequestManager
import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected EventRequestManager getEventRequestManager () throws VMDisconnectedExceptionWrapper, InternalExceptionWrapper {
VirtualMachine vm = getVirtualMachine();
if (vm == null) {
// Already disconnected
throw new VMDisconnectedExceptionWrapper(new VMDisconnectedException());
}
return VirtualMachineWrapper.eventRequestManager (vm);
}