author | wenzelm |
Tue, 14 Mar 2017 10:49:07 +0100 | |
changeset 65222 | fb8253564483 |
parent 65219 | ed4b47b8c7dc |
child 65223 | 844c067bc3d4 |
permissions | -rw-r--r-- |
60749 | 1 |
/* Title: Pure/Tools/debugger.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Interactive debugger for Isabelle/ML. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
61016 | 10 |
import scala.collection.immutable.SortedMap |
11 |
||
12 |
||
60749 | 13 |
object Debugger |
14 |
{ |
|
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
15 |
/* thread context */ |
60834 | 16 |
|
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
17 |
case object Update |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
18 |
|
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
19 |
sealed case class Debug_State(pos: Position.T, function: String) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
20 |
type Threads = SortedMap[String, List[Debug_State]] |
60842 | 21 |
|
61010 | 22 |
sealed case class Context(thread_name: String, debug_states: List[Debug_State], index: Int = 0) |
23 |
{ |
|
24 |
def size: Int = debug_states.length + 1 |
|
25 |
def reset: Context = copy(index = 0) |
|
26 |
def select(i: Int) = copy(index = i + 1) |
|
27 |
||
28 |
def thread_state: Option[Debug_State] = debug_states.headOption |
|
29 |
||
30 |
def stack_state: Option[Debug_State] = |
|
31 |
if (1 <= index && index <= debug_states.length) |
|
32 |
Some(debug_states(index - 1)) |
|
33 |
else None |
|
34 |
||
61014 | 35 |
def debug_index: Option[Int] = |
61010 | 36 |
if (stack_state.isDefined) Some(index - 1) |
37 |
else if (debug_states.nonEmpty) Some(0) |
|
38 |
else None |
|
39 |
||
40 |
def debug_state: Option[Debug_State] = stack_state orElse thread_state |
|
61014 | 41 |
def debug_position: Option[Position.T] = debug_state.map(_.pos) |
61010 | 42 |
|
43 |
override def toString: String = |
|
44 |
stack_state match { |
|
45 |
case None => thread_name |
|
46 |
case Some(d) => d.function |
|
47 |
} |
|
48 |
} |
|
49 |
||
50 |
||
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
51 |
/* debugger state */ |
61016 | 52 |
|
60835 | 53 |
sealed case class State( |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
54 |
session: Session, |
60932
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
55 |
active: Int = 0, // active views |
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
56 |
break: Boolean = false, // break at next possible breakpoint |
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
57 |
active_breakpoints: Set[Long] = Set.empty, // explicit breakpoint state |
61016 | 58 |
threads: Threads = SortedMap.empty, // thread name ~> stack of debug states |
61014 | 59 |
focus: Map[String, Context] = Map.empty, // thread name ~> focus |
60834 | 60 |
output: Map[String, Command.Results] = Map.empty) // thread name ~> output messages |
61 |
{ |
|
60932
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
62 |
def set_break(b: Boolean): State = copy(break = b) |
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
63 |
|
60910 | 64 |
def is_active: Boolean = active > 0 && session.is_ready |
60898 | 65 |
def inc_active: State = copy(active = active + 1) |
66 |
def dec_active: State = copy(active = active - 1) |
|
60876 | 67 |
|
60880
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
68 |
def toggle_breakpoint(breakpoint: Long): (Boolean, State) = |
60876 | 69 |
{ |
70 |
val active_breakpoints1 = |
|
60880
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
71 |
if (active_breakpoints(breakpoint)) active_breakpoints - breakpoint |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
72 |
else active_breakpoints + breakpoint |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
73 |
(active_breakpoints1(breakpoint), copy(active_breakpoints = active_breakpoints1)) |
60876 | 74 |
} |
75 |
||
60842 | 76 |
def get_thread(thread_name: String): List[Debug_State] = |
77 |
threads.getOrElse(thread_name, Nil) |
|
78 |
||
79 |
def update_thread(thread_name: String, debug_states: List[Debug_State]): State = |
|
61019
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
80 |
{ |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
81 |
val threads1 = |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
82 |
if (debug_states.nonEmpty) threads + (thread_name -> debug_states) |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
83 |
else threads - thread_name |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
84 |
val focus1 = |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
85 |
focus.get(thread_name) match { |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
86 |
case Some(c) if debug_states.nonEmpty => |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
87 |
focus + (thread_name -> Context(thread_name, debug_states)) |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
88 |
case _ => focus - thread_name |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
89 |
} |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
90 |
copy(threads = threads1, focus = focus1) |
7ce030f14aa9
reset focus after thread update (with new debug_states);
wenzelm
parents:
61018
diff
changeset
|
91 |
} |
60842 | 92 |
|
61014 | 93 |
def set_focus(c: Context): State = copy(focus = focus + (c.thread_name -> c)) |
94 |
||
60842 | 95 |
def get_output(thread_name: String): Command.Results = |
96 |
output.getOrElse(thread_name, Command.Results.empty) |
|
97 |
||
98 |
def add_output(thread_name: String, entry: Command.Results.Entry): State = |
|
99 |
copy(output = output + (thread_name -> (get_output(thread_name) + entry))) |
|
100 |
||
101 |
def clear_output(thread_name: String): State = |
|
102 |
copy(output = output - thread_name) |
|
60834 | 103 |
} |
104 |
||
60902 | 105 |
|
106 |
/* protocol handler */ |
|
107 |
||
65222
fb8253564483
more robust debugger initialization, e.g. required for GUI components before actual session startup;
wenzelm
parents:
65219
diff
changeset
|
108 |
class Handler(session: Session) extends Session.Protocol_Handler |
60749 | 109 |
{ |
65222
fb8253564483
more robust debugger initialization, e.g. required for GUI components before actual session startup;
wenzelm
parents:
65219
diff
changeset
|
110 |
val debugger: Debugger = new Debugger(session) |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
111 |
|
65219 | 112 |
private def debugger_state(msg: Prover.Protocol_Output): Boolean = |
60842 | 113 |
{ |
114 |
msg.properties match { |
|
115 |
case Markup.Debugger_State(thread_name) => |
|
60863 | 116 |
val msg_body = |
117 |
YXML.parse_body_failsafe(Symbol.decode(UTF8.decode_permissive(msg.bytes))) |
|
60842 | 118 |
val debug_states = |
119 |
{ |
|
120 |
import XML.Decode._ |
|
121 |
list(pair(properties, Symbol.decode_string))(msg_body).map({ |
|
122 |
case (pos, function) => Debug_State(pos, function) |
|
123 |
}) |
|
124 |
} |
|
65222
fb8253564483
more robust debugger initialization, e.g. required for GUI components before actual session startup;
wenzelm
parents:
65219
diff
changeset
|
125 |
debugger.update_thread(thread_name, debug_states) |
60842 | 126 |
true |
127 |
case _ => false |
|
128 |
} |
|
129 |
} |
|
130 |
||
65219 | 131 |
private def debugger_output(msg: Prover.Protocol_Output): Boolean = |
60830 | 132 |
{ |
133 |
msg.properties match { |
|
60835 | 134 |
case Markup.Debugger_Output(thread_name) => |
65217 | 135 |
YXML.parse_body_failsafe(Symbol.decode(UTF8.decode_permissive(msg.bytes))) match { |
60834 | 136 |
case List(XML.Elem(Markup(name, props @ Markup.Serial(i)), body)) => |
65218 | 137 |
val message = XML.Elem(Markup(Markup.message(name), props), body) |
65222
fb8253564483
more robust debugger initialization, e.g. required for GUI components before actual session startup;
wenzelm
parents:
65219
diff
changeset
|
138 |
debugger.add_output(thread_name, i -> session.xml_cache.elem(message)) |
60834 | 139 |
true |
140 |
case _ => false |
|
141 |
} |
|
60830 | 142 |
case _ => false |
143 |
} |
|
144 |
} |
|
145 |
||
146 |
val functions = |
|
65219 | 147 |
List( |
60842 | 148 |
Markup.DEBUGGER_STATE -> debugger_state _, |
149 |
Markup.DEBUGGER_OUTPUT -> debugger_output _) |
|
60749 | 150 |
} |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
151 |
} |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
152 |
|
65222
fb8253564483
more robust debugger initialization, e.g. required for GUI components before actual session startup;
wenzelm
parents:
65219
diff
changeset
|
153 |
class Debugger private(session: Session) |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
154 |
{ |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
155 |
/* debugger state */ |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
156 |
|
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
157 |
private val state = Synchronized(Debugger.State(session)) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
158 |
|
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
159 |
private val delay_update = |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
160 |
Standard_Thread.delay_first(session.output_delay) { |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
161 |
session.debugger_updates.post(Debugger.Update) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
162 |
} |
60765 | 163 |
|
164 |
||
165 |
/* protocol commands */ |
|
166 |
||
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
167 |
def update_thread(thread_name: String, debug_states: List[Debugger.Debug_State]) |
60910 | 168 |
{ |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
169 |
state.change(_.update_thread(thread_name, debug_states)) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
170 |
delay_update.invoke() |
60910 | 171 |
} |
172 |
||
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
173 |
def add_output(thread_name: String, entry: Command.Results.Entry) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
174 |
{ |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
175 |
state.change(_.add_output(thread_name, entry)) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
176 |
delay_update.invoke() |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
177 |
} |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
178 |
|
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
179 |
def is_active(): Boolean = state.value.is_active |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
180 |
|
60910 | 181 |
def init(): Unit = |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
182 |
state.change(st => |
60889 | 183 |
{ |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
184 |
val st1 = st.inc_active |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
185 |
if (!st.is_active && st1.is_active) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
186 |
session.protocol_command("Debugger.init") |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
187 |
st1 |
60889 | 188 |
}) |
189 |
||
60910 | 190 |
def exit(): Unit = |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
191 |
state.change(st => |
60889 | 192 |
{ |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
193 |
val st1 = st.dec_active |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
194 |
if (st.is_active && !st1.is_active) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
195 |
session.protocol_command("Debugger.exit") |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
196 |
st1 |
60889 | 197 |
}) |
60876 | 198 |
|
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
199 |
def is_break(): Boolean = state.value.break |
60932
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
200 |
def set_break(b: Boolean) |
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
201 |
{ |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
202 |
state.change(st => { |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
203 |
val st1 = st.set_break(b) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
204 |
session.protocol_command("Debugger.break", b.toString) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
205 |
st1 |
60932
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
206 |
}) |
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
207 |
delay_update.invoke() |
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
208 |
} |
13ee73f57c85
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents:
60912
diff
changeset
|
209 |
|
60882 | 210 |
def active_breakpoint_state(breakpoint: Long): Option[Boolean] = |
60876 | 211 |
{ |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
212 |
val st = state.value |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
213 |
if (st.is_active) Some(st.active_breakpoints(breakpoint)) else None |
60876 | 214 |
} |
215 |
||
60882 | 216 |
def breakpoint_state(breakpoint: Long): Boolean = |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
217 |
state.value.active_breakpoints(breakpoint) |
60882 | 218 |
|
60880
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
219 |
def toggle_breakpoint(command: Command, breakpoint: Long) |
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
220 |
{ |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
221 |
state.change(st => |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
222 |
{ |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
223 |
val (breakpoint_state, st1) = st.toggle_breakpoint(breakpoint) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
224 |
session.protocol_command( |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
225 |
"Debugger.breakpoint", |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
226 |
Symbol.encode(command.node_name.node), |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
227 |
Document_ID(command.id), |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
228 |
Value.Long(breakpoint), |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
229 |
Value.Boolean(breakpoint_state)) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
230 |
st1 |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
231 |
}) |
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
232 |
} |
60876 | 233 |
|
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
234 |
def status(focus: Option[Debugger.Context]): (Debugger.Threads, List[XML.Tree]) = |
61018 | 235 |
{ |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
236 |
val st = state.value |
61018 | 237 |
val output = |
238 |
focus match { |
|
239 |
case None => Nil |
|
240 |
case Some(c) => |
|
241 |
(for { |
|
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
242 |
(thread_name, results) <- st.output |
61018 | 243 |
if thread_name == c.thread_name |
244 |
(_, tree) <- results.iterator |
|
245 |
} yield tree).toList |
|
246 |
} |
|
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
247 |
(st.threads, output) |
61018 | 248 |
} |
61011 | 249 |
|
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
250 |
def focus(): List[Debugger.Context] = state.value.focus.toList.map(_._2) |
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
251 |
def set_focus(c: Debugger.Context) |
61008 | 252 |
{ |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
253 |
state.change(_.set_focus(c)) |
61008 | 254 |
delay_update.invoke() |
255 |
} |
|
60875 | 256 |
|
60854 | 257 |
def input(thread_name: String, msg: String*): Unit = |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
258 |
session.protocol_command("Debugger.input", (thread_name :: msg.toList):_*) |
60854 | 259 |
|
60899 | 260 |
def continue(thread_name: String): Unit = input(thread_name, "continue") |
60869 | 261 |
def step(thread_name: String): Unit = input(thread_name, "step") |
262 |
def step_over(thread_name: String): Unit = input(thread_name, "step_over") |
|
263 |
def step_out(thread_name: String): Unit = input(thread_name, "step_out") |
|
60856 | 264 |
|
60901 | 265 |
def clear_output(thread_name: String) |
266 |
{ |
|
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
267 |
state.change(_.clear_output(thread_name)) |
60902 | 268 |
delay_update.invoke() |
60901 | 269 |
} |
270 |
||
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
271 |
def eval(c: Debugger.Context, SML: Boolean, context: String, expression: String) |
60856 | 272 |
{ |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
273 |
state.change(st => { |
61014 | 274 |
input(c.thread_name, "eval", c.debug_index.getOrElse(0).toString, |
61010 | 275 |
SML.toString, Symbol.encode(context), Symbol.encode(expression)) |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
276 |
st.clear_output(c.thread_name) |
60896 | 277 |
}) |
60902 | 278 |
delay_update.invoke() |
60856 | 279 |
} |
60897 | 280 |
|
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
281 |
def print_vals(c: Debugger.Context, SML: Boolean, context: String) |
60897 | 282 |
{ |
61014 | 283 |
require(c.debug_index.isDefined) |
61010 | 284 |
|
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
285 |
state.change(st => { |
61014 | 286 |
input(c.thread_name, "print_vals", c.debug_index.getOrElse(0).toString, |
61010 | 287 |
SML.toString, Symbol.encode(context)) |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
63805
diff
changeset
|
288 |
st.clear_output(c.thread_name) |
60897 | 289 |
}) |
60902 | 290 |
delay_update.invoke() |
60897 | 291 |
} |
60749 | 292 |
} |