com.oracle.truffle.api.debug.Debugger Maven / Gradle / Ivy
Show all versions of truffle-api Show documentation
/*
* Copyright (c) 2015, 2016, 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.
*/
package com.oracle.truffle.api.debug;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.debug.impl.DebuggerInstrument;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.impl.Accessor;
import com.oracle.truffle.api.instrumentation.EventBinding;
import com.oracle.truffle.api.instrumentation.Instrumenter;
import com.oracle.truffle.api.instrumentation.LoadSourceEvent;
import com.oracle.truffle.api.instrumentation.LoadSourceListener;
import com.oracle.truffle.api.instrumentation.SourceSectionFilter;
import com.oracle.truffle.api.instrumentation.TruffleInstrument.Env;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.vm.PolyglotEngine;
/**
* Represents debugging related state of a {@link PolyglotEngine}.
*
* Access to the (singleton) instance in an engine, is available via:
*
* - {@link Debugger#find(PolyglotEngine)}
* - {@link Debugger#find(TruffleLanguage.Env)}
* - {@link DebuggerSession#getDebugger()}
*
*
* To start new debugger session use {@link #startSession(SuspendedCallback)}. Please see
* {@link DebuggerSession} for a usage example.
*
* The debugger supports diagnostic tracing that can be enabled using the
* -Dtruffle.debug.trace=true
Java property. The output of this tracing is not
* guaranteed and will change without notice.
*
* @see Debugger#startSession(SuspendedCallback)
* @see DebuggerSession
* @see Breakpoint
*
* @since 0.9
*/
public final class Debugger {
static final boolean TRACE = Boolean.getBoolean("truffle.debug.trace");
/*
* The engine with this debugger was created.
*/
private final PolyglotEngine sourceVM;
private final Env env;
private final ObjectStructures.MessageNodes msgNodes;
Debugger(PolyglotEngine sourceVM, Env env) {
this.env = env;
this.sourceVM = sourceVM;
this.msgNodes = new ObjectStructures.MessageNodes();
}
/**
* Starts a new {@link DebuggerSession session} provided with a callback that gets notified
* whenever the execution is suspended.
*
* @param callback the callback to notify
* @see DebuggerSession
* @see SuspendedEvent
* @since 0.17
*/
public DebuggerSession startSession(SuspendedCallback callback) {
return new DebuggerSession(this, callback);
}
/**
* Returns a list of all loaded sources. The sources are returned in the order as they have been
* loaded by the languages.
*
* @return an unmodifiable list of sources
* @since 0.17
*/
public List