Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/REPLServer.java @ 22003:5bc7f7b867ab
Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Sat, 18 Jul 2015 18:03:36 +0200 |
parents | 9c8c0937da41 |
children | dc83cc1f94f2 |
comparison
equal
deleted
inserted
replaced
22002:324997830dc9 | 22003:5bc7f7b867ab |
---|---|
22 * or visit www.oracle.com if you need additional information or have any | 22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. | 23 * questions. |
24 */ | 24 */ |
25 package com.oracle.truffle.tools.debug.shell; | 25 package com.oracle.truffle.tools.debug.shell; |
26 | 26 |
27 import com.oracle.truffle.api.debug.Breakpoint; | |
28 import java.util.*; | |
29 | |
27 /** | 30 /** |
28 * The server side of a simple message-based protocol for a possibly remote language | 31 * The server side of a simple message-based protocol for a possibly remote language |
29 * Read-Eval-Print-Loop. | 32 * Read-Eval-Print-Loop. |
30 */ | 33 */ |
31 public interface REPLServer { | 34 public abstract class REPLServer { |
32 | 35 |
33 /** | 36 /** |
34 * Starts up a server; status returned in a message. | 37 * Starts up a server; status returned in a message. |
35 */ | 38 */ |
36 REPLMessage start(); | 39 public abstract REPLMessage start(); |
37 | 40 |
38 /** | 41 /** |
39 * Ask the server to handle a request. Return a non-empty array of messages to simulate remote | 42 * Ask the server to handle a request. Return a non-empty array of messages to simulate remote |
40 * operation where the protocol has possibly multiple messages being returned asynchronously in | 43 * operation where the protocol has possibly multiple messages being returned asynchronously in |
41 * response to each request. | 44 * response to each request. |
42 */ | 45 */ |
43 REPLMessage[] receive(REPLMessage request); | 46 public abstract REPLMessage[] receive(REPLMessage request); |
47 | |
48 private int breakpointCounter; | |
49 private Map<Breakpoint, Integer> breakpoints = new WeakHashMap<>(); | |
50 | |
51 protected final synchronized void registerBreakpoint(Breakpoint breakpoint) { | |
52 breakpoints.put(breakpoint, breakpointCounter++); | |
53 } | |
54 | |
55 protected final synchronized Breakpoint findBreakpoint(int id) { | |
56 for (Map.Entry<Breakpoint, Integer> entrySet : breakpoints.entrySet()) { | |
57 if (id == entrySet.getValue()) { | |
58 return entrySet.getKey(); | |
59 } | |
60 } | |
61 return null; | |
62 } | |
63 | |
64 protected final synchronized int getBreakpointID(Breakpoint breakpoint) { | |
65 final Integer id = breakpoints.get(breakpoint); | |
66 return id == null ? -1 : id; | |
67 } | |
44 | 68 |
45 } | 69 } |