Search in sources :

Example 1 with LaunchingConnector

use of com.sun.jdi.connect.LaunchingConnector in project jdk8u_jdk by JetBrains.

the class ChildSession method getVM.

private static VirtualMachine getVM(OutputListener diagnostics, String userVMArgs, String cmdLine) {
    VirtualMachineManager manager = Bootstrap.virtualMachineManager();
    LaunchingConnector connector = manager.defaultConnector();
    Map<String, Connector.Argument> arguments = connector.defaultArguments();
    arguments.get("options").setValue(userVMArgs);
    arguments.get("main").setValue(cmdLine);
    return generalGetVM(diagnostics, connector, arguments);
}
Also used : LaunchingConnector(com.sun.jdi.connect.LaunchingConnector)

Example 2 with LaunchingConnector

use of com.sun.jdi.connect.LaunchingConnector in project ceylon by eclipse.

the class TracerImpl method start.

public void start() throws Exception {
    VirtualMachineManager vmm = com.sun.jdi.Bootstrap.virtualMachineManager();
    LaunchingConnector conn = vmm.defaultConnector();
    Map<String, Argument> defaultArguments = conn.defaultArguments();
    defaultArguments.get("main").setValue(mainClass);
    defaultArguments.get("options").setValue("-cp " + classPath);
    System.out.println(defaultArguments);
    vm = conn.launch(defaultArguments);
    err = vm.process().getErrorStream();
    out = vm.process().getInputStream();
    eq = vm.eventQueue();
    rm = vm.eventRequestManager();
    outer: while (true) {
        echo(err, System.err);
        echo(out, System.out);
        events = eq.remove();
        for (Event event : events) {
            if (event instanceof VMStartEvent) {
                System.out.println(event);
                break outer;
            } else if (event instanceof VMDisconnectEvent || event instanceof VMDeathEvent) {
                System.out.println(event);
                vm = null;
                rm = null;
                eq = null;
                break outer;
            }
        }
        events.resume();
    }
    echo(err, System.err);
    echo(out, System.out);
}
Also used : VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) Argument(com.sun.jdi.connect.Connector.Argument) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) VMStartEvent(com.sun.jdi.event.VMStartEvent) MethodEntryEvent(com.sun.jdi.event.MethodEntryEvent) Event(com.sun.jdi.event.Event) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) StepEvent(com.sun.jdi.event.StepEvent) VMStartEvent(com.sun.jdi.event.VMStartEvent) MethodExitEvent(com.sun.jdi.event.MethodExitEvent) VirtualMachineManager(com.sun.jdi.VirtualMachineManager)

Example 3 with LaunchingConnector

use of com.sun.jdi.connect.LaunchingConnector in project warn-report by saaavsaaa.

the class debugger method test.

@Test
public void test() throws VMStartException, IllegalConnectorArgumentsException, IOException {
    // Debugger 通过 Bootstrap 获取唯一的虚拟机管理器
    VirtualMachineManager virtualMachineManager = Bootstrap.virtualMachineManager();
    // 虚拟机管理器将在第一次被调用时初始化可用的链接器
    LaunchingConnector defaultConnector = virtualMachineManager.defaultConnector();
    // 启动目标程序,连接调试器(Debugger)与目标虚拟机(VirtualMachine)
    Map<String, Connector.Argument> arguments = defaultConnector.defaultArguments();
    Connector.Argument arg = arguments.get("main");
    arg.setValue("cn.tellwhy.DailyTest");
    VirtualMachine targetVM = defaultConnector.launch(arguments);
    // 获取 Mirror 对象实例的虚拟机
    VirtualMachine virtualMachine = targetVM.virtualMachine();
    virtualMachine.allClasses().forEach(a -> System.out.println("===============:" + a.name()));
}
Also used : SocketAttachingConnector(com.sun.tools.jdi.SocketAttachingConnector) AttachingConnector(com.sun.jdi.connect.AttachingConnector) Connector(com.sun.jdi.connect.Connector) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) VirtualMachineManager(com.sun.jdi.VirtualMachineManager) VirtualMachine(com.sun.jdi.VirtualMachine) Test(org.junit.Test)

Example 4 with LaunchingConnector

use of com.sun.jdi.connect.LaunchingConnector in project warn-report by saaavsaaa.

the class debugger method main.

public static void main(String[] args) throws Exception {
    LaunchingConnector launchingConnector = Bootstrap.virtualMachineManager().defaultConnector();
    // Get arguments of the launching connector
    Map<String, Connector.Argument> defaultArguments = launchingConnector.defaultArguments();
    Connector.Argument mainArg = defaultArguments.get("main");
    Connector.Argument suspendArg = defaultArguments.get("suspend");
    // Set class of main method
    mainArg.setValue("cn.tellwhy.DailyTest");
    suspendArg.setValue("true");
    vm = launchingConnector.launch(defaultArguments);
    process = vm.process();
    // Register ClassPrepareRequest
    eventRequestManager = vm.eventRequestManager();
    ClassPrepareRequest classPrepareRequest = eventRequestManager.createClassPrepareRequest();
    // classPrepareRequest.addClassFilter("cn.tellwhy.DailyTest");
    // classPrepareRequest.addCountFilter(1);
    // classPrepareRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
    classPrepareRequest.enable();
    // Enter event loop
    eventLoop();
    process.destroy();
}
Also used : SocketAttachingConnector(com.sun.tools.jdi.SocketAttachingConnector) AttachingConnector(com.sun.jdi.connect.AttachingConnector) Connector(com.sun.jdi.connect.Connector) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest)

Example 5 with LaunchingConnector

use of com.sun.jdi.connect.LaunchingConnector in project ceylon-compiler by ceylon.

the class TracerImpl method start.

public void start() throws Exception {
    VirtualMachineManager vmm = com.sun.jdi.Bootstrap.virtualMachineManager();
    LaunchingConnector conn = vmm.defaultConnector();
    Map<String, Argument> defaultArguments = conn.defaultArguments();
    defaultArguments.get("main").setValue(mainClass);
    defaultArguments.get("options").setValue("-cp " + classPath);
    System.out.println(defaultArguments);
    vm = conn.launch(defaultArguments);
    err = vm.process().getErrorStream();
    out = vm.process().getInputStream();
    eq = vm.eventQueue();
    rm = vm.eventRequestManager();
    outer: while (true) {
        echo(err, System.err);
        echo(out, System.out);
        events = eq.remove();
        for (Event event : events) {
            if (event instanceof VMStartEvent) {
                System.out.println(event);
                break outer;
            } else if (event instanceof VMDisconnectEvent || event instanceof VMDeathEvent) {
                System.out.println(event);
                vm = null;
                rm = null;
                eq = null;
                break outer;
            }
        }
        events.resume();
    }
    echo(err, System.err);
    echo(out, System.out);
}
Also used : VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) Argument(com.sun.jdi.connect.Connector.Argument) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) VMStartEvent(com.sun.jdi.event.VMStartEvent) MethodEntryEvent(com.sun.jdi.event.MethodEntryEvent) Event(com.sun.jdi.event.Event) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) StepEvent(com.sun.jdi.event.StepEvent) VMStartEvent(com.sun.jdi.event.VMStartEvent) MethodExitEvent(com.sun.jdi.event.MethodExitEvent) VirtualMachineManager(com.sun.jdi.VirtualMachineManager)

Aggregations

LaunchingConnector (com.sun.jdi.connect.LaunchingConnector)5 VirtualMachineManager (com.sun.jdi.VirtualMachineManager)3 AttachingConnector (com.sun.jdi.connect.AttachingConnector)2 Connector (com.sun.jdi.connect.Connector)2 Argument (com.sun.jdi.connect.Connector.Argument)2 Event (com.sun.jdi.event.Event)2 MethodEntryEvent (com.sun.jdi.event.MethodEntryEvent)2 MethodExitEvent (com.sun.jdi.event.MethodExitEvent)2 StepEvent (com.sun.jdi.event.StepEvent)2 VMDeathEvent (com.sun.jdi.event.VMDeathEvent)2 VMDisconnectEvent (com.sun.jdi.event.VMDisconnectEvent)2 VMStartEvent (com.sun.jdi.event.VMStartEvent)2 SocketAttachingConnector (com.sun.tools.jdi.SocketAttachingConnector)2 VirtualMachine (com.sun.jdi.VirtualMachine)1 ClassPrepareRequest (com.sun.jdi.request.ClassPrepareRequest)1 Test (org.junit.Test)1