1 /* 2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package org.graalvm.compiler.nodes; 24 25 import org.graalvm.compiler.core.common.type.StampFactory; 26 import org.graalvm.compiler.graph.NodeClass; 27 import org.graalvm.compiler.graph.NodeInputList; 28 import org.graalvm.compiler.nodeinfo.NodeInfo; 29 import org.graalvm.compiler.nodes.spi.LIRLowerable; 30 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool; 31 32 /** 33 * A node that results in a platform dependent breakpoint instruction being emitted. A number of 34 * arguments can be associated with such a node for placing values of interest in the Java ABI 35 * specified parameter locations corresponding to the kinds of the values. That is, the arguments 36 * are set up as if the breakpoint instruction was a call to a compiled Java method. 37 * <p> 38 * A breakpoint is usually place by defining a node intrinsic method as follows: 39 * 40 * <pre> 41 * {@literal @}NodeIntrinsic(BreakpointNode.class) 42 * static void breakpoint(Object object, Word mark, Word value) { 43 * throw new GraalError(""); 44 * } 45 * </pre> 46 * 47 * Note that the signature is arbitrary. It's sole purpose is to capture values you may want to 48 * inspect in the native debugger when the breakpoint is hit. 49 */ 50 @NodeInfo 51 public final class BreakpointNode extends FixedWithNextNode implements LIRLowerable { 52 53 public static final NodeClass<BreakpointNode> TYPE = NodeClass.create(BreakpointNode.class); 54 @Input NodeInputList<ValueNode> arguments; 55 56 public BreakpointNode(ValueNode... arguments) { 57 super(TYPE, StampFactory.forVoid()); 58 this.arguments = new NodeInputList<>(this, arguments); 59 } 60 61 @Override 62 public void generate(NodeLIRBuilderTool gen) { 63 gen.visitBreakpointNode(this); 64 } 65 66 public NodeInputList<ValueNode> arguments() { 67 return arguments; 68 } 69 70 @NodeIntrinsic 71 public static native void breakpoint(); 72 }