comparison truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/LineToProbesMapTest.java @ 22214:3aad794eec0e

Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework - introduce the Instrumenter class, held by the TruffleVM to support instrumentation services - reimplement Probe-realated services (formerly statics in Probe.java) to be provided by the Instrumenter- add new Accessors - change the TruffleVM startup sequence - change the APIs of the Debugger and many other classes
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Mon, 14 Sep 2015 22:59:51 -0700
parents 9c8c0937da41
children 1c0f490984d5
comparison
equal deleted inserted replaced
22136:1d804d691dc7 22214:3aad794eec0e
35 import com.oracle.truffle.tools.*; 35 import com.oracle.truffle.tools.*;
36 36
37 public class LineToProbesMapTest { 37 public class LineToProbesMapTest {
38 38
39 @Test 39 @Test
40 public void testToolCreatedTooLate() { 40 public void testToolCreatedTooLate() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
41 final RootNode expr13rootNode = createExpr13TestRootNode(); 41 final Instrumenter instrumenter = TestNodes.createInstrumenter();
42 final RootNode expr13rootNode = createExpr13TestRootNode(instrumenter);
42 final Node addNode = expr13rootNode.getChildren().iterator().next(); 43 final Node addNode = expr13rootNode.getChildren().iterator().next();
43 final Probe probe = addNode.probe(); 44 final Probe probe = instrumenter.probe(addNode);
44 final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation(); 45 final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation();
45 assertEquals(lineLocation, expr13Line2); 46 assertEquals(lineLocation, expr13Line2);
46 47
47 final LineToProbesMap tool = new LineToProbesMap(); 48 final LineToProbesMap tool = new LineToProbesMap();
48 tool.install(); 49 tool.install(instrumenter);
49 50
50 assertNull(tool.findFirstProbe(expr13Line1)); 51 assertNull(tool.findFirstProbe(expr13Line1));
51 assertNull(tool.findFirstProbe(expr13Line2)); 52 assertNull(tool.findFirstProbe(expr13Line2));
52 tool.dispose(); 53 tool.dispose();
53 } 54 }
54 55
55 @Test 56 @Test
56 public void testToolInstalledTooLate() { 57 public void testToolInstalledTooLate() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
58 final Instrumenter instrumenter = TestNodes.createInstrumenter();
57 final LineToProbesMap tool = new LineToProbesMap(); 59 final LineToProbesMap tool = new LineToProbesMap();
58 60
59 final RootNode expr13rootNode = createExpr13TestRootNode(); 61 final RootNode expr13rootNode = createExpr13TestRootNode(instrumenter);
60 final Node addNode = expr13rootNode.getChildren().iterator().next(); 62 final Node addNode = expr13rootNode.getChildren().iterator().next();
61 final Probe probe = addNode.probe(); 63 final Probe probe = instrumenter.probe(addNode);
62 final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation(); 64 final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation();
63 assertEquals(lineLocation, expr13Line2); 65 assertEquals(lineLocation, expr13Line2);
64 66
65 tool.install(); 67 tool.install(instrumenter);
66 68
67 assertNull(tool.findFirstProbe(expr13Line1)); 69 assertNull(tool.findFirstProbe(expr13Line1));
68 assertNull(tool.findFirstProbe(expr13Line2)); 70 assertNull(tool.findFirstProbe(expr13Line2));
69 tool.dispose(); 71 tool.dispose();
70 } 72 }
71 73
72 @Test 74 @Test
73 public void testMapping() { 75 public void testMapping() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
76 final Instrumenter instrumenter = TestNodes.createInstrumenter();
74 final LineToProbesMap tool = new LineToProbesMap(); 77 final LineToProbesMap tool = new LineToProbesMap();
75 tool.install(); 78 tool.install(instrumenter);
76 79
77 final RootNode expr13rootNode = createExpr13TestRootNode(); 80 final RootNode expr13rootNode = createExpr13TestRootNode(instrumenter);
78 final Node addNode = expr13rootNode.getChildren().iterator().next(); 81 final Node addNode = expr13rootNode.getChildren().iterator().next();
79 final Probe probe = addNode.probe(); 82 final Probe probe = instrumenter.probe(addNode);
80 final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation(); 83 final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation();
81 assertEquals(lineLocation, expr13Line2); 84 assertEquals(lineLocation, expr13Line2);
82 85
83 assertNull(tool.findFirstProbe(expr13Line1)); 86 assertNull(tool.findFirstProbe(expr13Line1));
84 assertEquals(tool.findFirstProbe(expr13Line2), probe); 87 assertEquals(tool.findFirstProbe(expr13Line2), probe);