Mercurial > hg > truffle
diff truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/package-info.java @ 22008:02e4cf046653
Providing a bit more meaningful documentation to our recent debugging improvements
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 22 Jul 2015 14:25:03 +0200 |
parents | |
children | 7a5b874b8d12 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/package-info.java Wed Jul 22 14:25:03 2015 +0200 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Control over {@link com.oracle.truffle.api.debug.Debugger debugging} of your {@link com.oracle.truffle.api.vm.TruffleVM}. Each {@link com.oracle.truffle.api.vm.TruffleVM} + * is inherently capable to run in debugging mode - there is just one thing + * to do - the {@link com.oracle.truffle.api.vm.TruffleVM.Builder creator of the virtual machine} + * needs to turn debugging on when constructing its Truffle virtual machine: + * <pre> + * vm = {@link com.oracle.truffle.api.vm.TruffleVM#newVM()}. + * {@link com.oracle.truffle.api.vm.TruffleVM.Builder#onEvent(com.oracle.truffle.api.vm.EventConsumer) onEvent}(<b>new</b> {@link com.oracle.truffle.api.vm.EventConsumer EventConsumer}{@code <}{@link com.oracle.truffle.api.debug.ExecutionEvent}{@code >}() { + * <b>public void</b> handle({@link com.oracle.truffle.api.debug.ExecutionEvent} ev) { + * <em>// configure the virtual machine as {@link com.oracle.truffle.api.vm.TruffleVM#eval(java.net.URI) new execution} is starting</em> + * } + * }). + * {@link com.oracle.truffle.api.vm.TruffleVM.Builder#onEvent(com.oracle.truffle.api.vm.EventConsumer) onEvent}(<b>new</b> {@link com.oracle.truffle.api.vm.EventConsumer EventConsumer}{@code <}{@link com.oracle.truffle.api.debug.SuspendedEvent}{@code >}() { + * <b>public void</b> handle({@link com.oracle.truffle.api.debug.SuspendedEvent} ev) { + * <em>// execution is suspended on a breakpoint or on a step - decide what next</em> + * } + * }).{@link com.oracle.truffle.api.vm.TruffleVM.Builder#build() build()}; + * </pre> + * The debugging is controlled by events emitted by the Truffle virtual machine + * at important moments. The {@link com.oracle.truffle.api.debug.ExecutionEvent} + * is sent when a call to {@link com.oracle.truffle.api.vm.TruffleVM#eval(java.net.URI) eval(...)} + * is made and allows one to configure {@link com.oracle.truffle.api.debug.Breakpoint breakpoints} and/or decide whether the + * program should {@link com.oracle.truffle.api.debug.ExecutionEvent#prepareStepInto() step-into} or + * {@link com.oracle.truffle.api.debug.ExecutionEvent#prepareContinue() just run}. Once the execution is suspended a + * {@link com.oracle.truffle.api.debug.SuspendedEvent} is generated which + * allows one to inspect the stack and choose the further execution mode + * ({@link com.oracle.truffle.api.debug.SuspendedEvent#prepareStepInto(int) step-into}, {@link com.oracle.truffle.api.debug.SuspendedEvent#prepareStepOver(int) step-over}, {@link com.oracle.truffle.api.debug.SuspendedEvent#prepareStepOut() step-out}, {@link com.oracle.truffle.api.debug.SuspendedEvent#prepareContinue() continue}). + * <p> + * The events methods are only available when the event is being delivered and + * shouldn't be used anytime later. Both events however provide access to + * {@link com.oracle.truffle.api.debug.Debugger} which can be kept and used + * during whole existence of the {@link com.oracle.truffle.api.vm.TruffleVM}. + * {@link com.oracle.truffle.api.debug.Debugger} is the central class that + * keeps information about {@link com.oracle.truffle.api.debug.Debugger#getBreakpoints() registered breakpoints} + * and allows one create new {@link com.oracle.truffle.api.debug.Breakpoint ones}. + * + * <h4>Turning on Stepping Mode</h4> + * + * In case you want your execution to pause on first statement, register for + * {@link com.oracle.truffle.api.debug.ExecutionEvent} and once delivered + * call {@link com.oracle.truffle.api.debug.ExecutionEvent#prepareStepInto()}. + * + * <h4>Register a {@link com.oracle.truffle.api.debug.Breakpoint}</h4> + * + * Wait for execution to be started - which generates an + * {@link com.oracle.truffle.api.debug.ExecutionEvent}. Use its + * {@link com.oracle.truffle.api.debug.Debugger ev.getDebugger}() + * methods to submit breakpoints. + */ +package com.oracle.truffle.api.debug; +