author | Stefan Vogel <sv@exept.de> |
Wed, 27 Oct 1999 18:17:24 +0200 | |
changeset 4960 | a047d70c18f6 |
parent 4572 | 79f02c7c9b75 |
child 4961 | 5419c9a32316 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
720 | 13 |
Object subclass:#MiniDebugger |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
14 |
instanceVariableNames:'tracing stepping traceBlock command commandArg commandCount' |
976 | 15 |
classVariableNames:'TheOneAndOnlyDebugger' |
16 |
poolDictionaries:'' |
|
17 |
category:'System-Debugging-Support' |
|
1 | 18 |
! |
19 |
||
618 | 20 |
!MiniDebugger class methodsFor:'documentation'! |
89 | 21 |
|
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 25 |
All Rights Reserved |
1 | 26 |
|
89 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
1 | 35 |
|
89 | 36 |
documentation |
37 |
" |
|
38 |
a primitive (non graphical) debugger for use on systems without |
|
39 |
graphics or when the real debugger dies (i.e. an error occurs in |
|
40 |
the graphical debugger). |
|
93 | 41 |
Also, if an interrupt occurs within the debuger, this one is called |
42 |
for. |
|
1297 | 43 |
|
44 |
[author:] |
|
45 |
Claus Gittinger |
|
89 | 46 |
" |
47 |
! ! |
|
1 | 48 |
|
618 | 49 |
!MiniDebugger class methodsFor:'instance creation'! |
50 |
||
4572 | 51 |
enter:aContext withMessage:aString mayProceed:mayProceed |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
52 |
"enter a miniDebugger" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
53 |
|
4960 | 54 |
|active con| |
618 | 55 |
|
56 |
StepInterruptPending := nil. |
|
57 |
||
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
58 |
Object errorSignal handle:[:ex | |
3701 | 59 |
ex return |
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
60 |
] do:[ |
3701 | 61 |
thisContext isRecursive ifTrue:[ |
62 |
"/ 'recursive error in debugger ignored' errorPrintCR. |
|
63 |
^ self |
|
64 |
]. |
|
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
65 |
aString printCR. |
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
66 |
Processor notNil ifTrue:[ |
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
67 |
active := Processor activeProcess. |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
68 |
'process: id=' print. active id print. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
69 |
' name=' print. active name printCR. |
4960 | 70 |
|
71 |
'context: ' print. aContext printString printCR. |
|
72 |
(con := aContext) notNil ifTrue:[ |
|
73 |
con := con sender. |
|
74 |
' ......: ' print. con printString printCR. |
|
75 |
[con notNil] whileTrue:[ |
|
76 |
con := con sender. |
|
77 |
' ......: ' print. con printString printCR. |
|
78 |
] |
|
79 |
] |
|
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
80 |
]. |
618 | 81 |
]. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
82 |
|
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
83 |
OperatingSystem hasConsole ifFalse:[ |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
84 |
Object errorSignal handle:[:ex | |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
85 |
ex return |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
86 |
] do:[ |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
87 |
self warn:('Unexpected error:\' , aString , '\\No MiniDebugger functionality available') withCRs . |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
88 |
]. |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
89 |
|
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
90 |
Object errorSignal handle:[:ex | |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
91 |
Smalltalk exit |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
92 |
] do:[ |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
93 |
AbortSignal raise. |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
94 |
] |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
95 |
] ifTrue:[ |
4535
aaed5f554d8b
code cleanup - removed all obsolete debugger entry protocol
Claus Gittinger <cg@exept.de>
parents:
4470
diff
changeset
|
96 |
self new enterMayProceed:mayProceed. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
97 |
]. |
618 | 98 |
^ nil |
1424 | 99 |
|
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
100 |
"Modified: / 19.5.1999 / 18:14:33 / cg" |
618 | 101 |
! |
1 | 102 |
|
4572 | 103 |
enterWithMessage:aString mayProceed:mayProceed |
104 |
"enter a miniDebugger" |
|
105 |
||
106 |
self enter:thisContext sender withMessage:aString mayProceed:mayProceed |
|
107 |
||
108 |
"Modified: / 19.5.1999 / 18:14:33 / cg" |
|
109 |
! |
|
110 |
||
1 | 111 |
new |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
112 |
"redefined to make certain that there is only one miniDebugger |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
113 |
in the system" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
114 |
|
33 | 115 |
TheOneAndOnlyDebugger isNil ifTrue:[ |
1424 | 116 |
TheOneAndOnlyDebugger := self basicNew initialize |
1 | 117 |
]. |
33 | 118 |
^ TheOneAndOnlyDebugger |
1424 | 119 |
|
3700 | 120 |
" |
121 |
TheOneAndOnlyDebugger := nil |
|
122 |
" |
|
123 |
||
3701 | 124 |
"Modified: / 31.7.1998 / 17:08:07 / cg" |
1 | 125 |
! |
126 |
||
127 |
singleStep:aBlock |
|
128 |
|aDebugger| |
|
129 |
||
130 |
aDebugger := self new stepping. |
|
241 | 131 |
ObjectMemory stepInterruptHandler:aDebugger. |
2 | 132 |
ObjectMemory flushInlineCaches. |
241 | 133 |
StepInterruptPending := 1. |
134 |
InterruptPending := 1. |
|
1 | 135 |
aBlock value. |
2 | 136 |
StepInterruptPending := nil. |
137 |
ObjectMemory stepInterruptHandler:nil |
|
1 | 138 |
! |
139 |
||
140 |
trace:aBlock |
|
1424 | 141 |
self trace:aBlock with:[:where | where printCR] |
142 |
||
143 |
"Modified: 20.5.1996 / 10:27:37 / cg" |
|
1 | 144 |
! |
145 |
||
146 |
trace:aBlock on:aStream |
|
147 |
self trace:aBlock with:[:where | where printString printOn:aStream. |
|
159 | 148 |
aStream cr] |
1 | 149 |
! |
150 |
||
151 |
trace:aBlock with:aTraceBlock |
|
152 |
|aDebugger| |
|
153 |
||
154 |
aDebugger := self new tracingWith:aTraceBlock. |
|
241 | 155 |
ObjectMemory stepInterruptHandler:aDebugger. |
1 | 156 |
ObjectMemory flushInlineCaches. |
241 | 157 |
StepInterruptPending := 1. |
158 |
InterruptPending := 1. |
|
1 | 159 |
aBlock value. |
2 | 160 |
ObjectMemory stepInterruptHandler:nil. |
1 | 161 |
StepInterruptPending := nil. |
162 |
^ nil |
|
163 |
! ! |
|
164 |
||
618 | 165 |
!MiniDebugger methodsFor:'initialization'! |
1 | 166 |
|
167 |
initialize |
|
168 |
traceBlock := nil. |
|
169 |
tracing := false. |
|
170 |
stepping := false |
|
171 |
! ! |
|
172 |
||
618 | 173 |
!MiniDebugger methodsFor:'interrupt handling'! |
1 | 174 |
|
4535
aaed5f554d8b
code cleanup - removed all obsolete debugger entry protocol
Claus Gittinger <cg@exept.de>
parents:
4470
diff
changeset
|
175 |
enterMayProceed:mayProceed |
159 | 176 |
|leaveCmd stillHere| |
74 | 177 |
|
178 |
stillHere := true. |
|
179 |
[stillHere] whileTrue:[ |
|
3769 | 180 |
leaveCmd := self commandLoop. |
1 | 181 |
|
3769 | 182 |
(leaveCmd == $s) ifTrue: [ |
183 |
self stepping. |
|
184 |
ObjectMemory flushInlineCaches. |
|
185 |
ObjectMemory stepInterruptHandler:self. |
|
186 |
stillHere := false. |
|
187 |
StepInterruptPending := 1. |
|
188 |
InterruptPending := 1 |
|
189 |
]. |
|
190 |
(leaveCmd == $t) ifTrue: [ |
|
191 |
traceBlock := [:where | where fullPrint]. |
|
192 |
ObjectMemory flushInlineCaches. |
|
193 |
ObjectMemory stepInterruptHandler:self. |
|
194 |
stillHere := false. |
|
195 |
StepInterruptPending := 1. |
|
196 |
InterruptPending := 1 |
|
197 |
]. |
|
198 |
(leaveCmd == $c) ifTrue: [ |
|
199 |
traceBlock := nil. |
|
200 |
stillHere := false. |
|
201 |
stepping := false. |
|
202 |
tracing := false. |
|
203 |
StepInterruptPending := nil. |
|
204 |
InterruptPending := nil |
|
205 |
]. |
|
206 |
(leaveCmd == $a) ifTrue: [ |
|
207 |
"abort" |
|
208 |
stepping := false. |
|
209 |
tracing := false. |
|
210 |
StepInterruptPending := nil. |
|
211 |
InterruptPending := nil. |
|
212 |
self doAbort. |
|
213 |
stillHere := true. |
|
214 |
"failed abort" |
|
215 |
]. |
|
1 | 216 |
]. |
217 |
^ nil |
|
3769 | 218 |
|
219 |
"Modified: / 18.8.1998 / 18:10:29 / cg" |
|
618 | 220 |
! |
221 |
||
222 |
stepInterrupt |
|
223 |
|where| |
|
224 |
||
225 |
where := thisContext. "where is stepInterrupt context" |
|
226 |
where notNil ifTrue:[ |
|
1424 | 227 |
where := where sender "where is now interrupted methods context" |
618 | 228 |
]. |
229 |
stepping ifTrue:[ |
|
1424 | 230 |
where notNil ifTrue:[ |
231 |
where fullPrint |
|
232 |
] ifFalse:[ |
|
233 |
'stepInterrupt: no context' errorPrintCR |
|
234 |
]. |
|
4535
aaed5f554d8b
code cleanup - removed all obsolete debugger entry protocol
Claus Gittinger <cg@exept.de>
parents:
4470
diff
changeset
|
235 |
self enterMayProceed:true |
618 | 236 |
] ifFalse:[ |
1424 | 237 |
where notNil ifTrue:[ |
238 |
traceBlock notNil ifTrue:[ |
|
239 |
traceBlock value:where |
|
240 |
] |
|
241 |
] ifFalse:[ |
|
242 |
'traceInterrupt: no context' errorPrintCR |
|
243 |
]. |
|
244 |
ObjectMemory flushInlineCaches. |
|
245 |
StepInterruptPending := 1. |
|
246 |
InterruptPending := 1 |
|
618 | 247 |
] |
1424 | 248 |
|
249 |
"Modified: 20.5.1996 / 10:23:11 / cg" |
|
1 | 250 |
! ! |
251 |
||
618 | 252 |
!MiniDebugger methodsFor:'private'! |
74 | 253 |
|
618 | 254 |
findContext:aSelector |
255 |
|con| |
|
74 | 256 |
|
618 | 257 |
con := thisContext sender. |
258 |
[con notNil] whileTrue:[ |
|
259 |
(con isBlockContext not and:[con selector == aSelector]) ifTrue:[ |
|
260 |
"got it" |
|
261 |
^ con |
|
262 |
]. |
|
263 |
con := con sender |
|
74 | 264 |
]. |
618 | 265 |
^ nil |
74 | 266 |
! |
267 |
||
618 | 268 |
getContext |
269 |
|backtrace| |
|
270 |
backtrace := thisContext. |
|
271 |
(backtrace notNil) ifTrue: [ |
|
272 |
"remove Context getContext frame" |
|
273 |
backtrace := backtrace sender. |
|
274 |
"remove Debugger showContext frame" |
|
275 |
backtrace := backtrace sender. |
|
276 |
"remove Debugger commandLoop frame" |
|
277 |
backtrace := backtrace sender. |
|
278 |
"remove Debugger enter frame" |
|
279 |
backtrace := backtrace sender |
|
280 |
]. |
|
281 |
^ backtrace |
|
282 |
! |
|
74 | 283 |
|
2772 | 284 |
printBacktraceFrom:aContext |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
285 |
|context n| |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
286 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
287 |
aContext isNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
288 |
'no context' errorPrintCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
289 |
^ self |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
290 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
291 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
292 |
context := aContext. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
293 |
n := commandCount. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
294 |
[context notNil] whileTrue: [ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
295 |
context fullPrint. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
296 |
context := context sender. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
297 |
n notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
298 |
n := n - 1. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
299 |
n <= 0 ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
300 |
^ self |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
301 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
302 |
] |
2772 | 303 |
] |
304 |
! |
|
305 |
||
618 | 306 |
stepping |
307 |
traceBlock := nil. |
|
308 |
tracing := false. |
|
309 |
stepping := true |
|
74 | 310 |
! |
311 |
||
618 | 312 |
tracingWith:aBlockOrNil |
313 |
traceBlock := aBlockOrNil. |
|
314 |
stepping := false. |
|
315 |
tracing := true |
|
316 |
! ! |
|
317 |
||
318 |
!MiniDebugger methodsFor:'user commands'! |
|
319 |
||
1 | 320 |
commandLoop |
3700 | 321 |
|cmd done valid context id proc| |
1 | 322 |
|
323 |
done := false. |
|
324 |
[done] whileFalse:[ |
|
1424 | 325 |
valid := false. |
326 |
cmd := self getCommand. |
|
2772 | 327 |
cmd isNil ifTrue:[ "/ EOF -> continue |
328 |
cmd := $c |
|
329 |
]. |
|
3700 | 330 |
|
331 |
commandArg notEmpty ifTrue:[ |
|
332 |
id := Number readFrom:commandArg onError:nil. |
|
333 |
||
334 |
id notNil ifTrue:[ |
|
335 |
proc := Process allSubInstances detect:[:p | p id == id] ifNone:nil. |
|
3701 | 336 |
proc == Processor activeProcess ifTrue:[ |
337 |
id := proc := nil |
|
338 |
] |
|
3700 | 339 |
] |
340 |
]. |
|
341 |
||
3701 | 342 |
(cmd == $l) ifTrue:[ |
1424 | 343 |
valid := true. |
3700 | 344 |
proc notNil ifTrue:[ |
345 |
'-------- walkback of process ' print. id print. ' -------' printCR. |
|
346 |
self printBacktraceFrom:(proc suspendedContext) |
|
347 |
] ifFalse:[ |
|
348 |
id notNil ifTrue:[ |
|
349 |
'no process with id: ' print. id printCR. |
|
350 |
] ifFalse:[ |
|
351 |
context isNil ifTrue: [ |
|
352 |
context := self getContext |
|
353 |
]. |
|
354 |
'-------- walkback of current process -------' printCR. |
|
355 |
self printBacktraceFrom:context |
|
356 |
] |
|
1424 | 357 |
]. |
358 |
]. |
|
3700 | 359 |
|
1424 | 360 |
(cmd == $b) ifTrue:[ |
361 |
valid := true. |
|
3700 | 362 |
proc notNil ifTrue:[ |
363 |
'-------- VM walkback of process ' print. id print. ' -------' printCR. |
|
364 |
ObjectMemory printStackBacktraceFrom:(proc suspendedContext) |
|
365 |
] ifFalse:[ |
|
366 |
id notNil ifTrue:[ |
|
367 |
'no process with id: ' print. id printCR. |
|
368 |
] ifFalse:[ |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
369 |
'-------- VM walkback of current process -------' printCR. |
3700 | 370 |
ObjectMemory printStackBacktrace |
371 |
] |
|
372 |
] |
|
1424 | 373 |
]. |
3700 | 374 |
|
2113
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
375 |
(cmd == $B) ifTrue:[ |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
376 |
valid := true. |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
377 |
self printAllBacktraces |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
378 |
]. |
3700 | 379 |
|
1424 | 380 |
(cmd == $P) ifTrue:[ |
381 |
valid := true. |
|
382 |
self showProcesses. |
|
383 |
]. |
|
3700 | 384 |
|
1424 | 385 |
(cmd == $r) ifTrue:[ |
386 |
valid := true. |
|
387 |
context isNil ifTrue: [ |
|
388 |
context := self getContext |
|
389 |
]. |
|
390 |
context notNil ifTrue:[ |
|
391 |
"remove Debugger stepinterrupt/halt frame" |
|
392 |
context sender receiver printCR |
|
393 |
] ifFalse:[ |
|
394 |
'no context - dont know receiver' errorPrintCR |
|
395 |
] |
|
396 |
]. |
|
3700 | 397 |
|
1424 | 398 |
(cmd == $R) ifTrue:[ |
399 |
valid := true. |
|
400 |
context isNil ifTrue: [ |
|
401 |
context := self getContext |
|
402 |
]. |
|
403 |
context notNil ifTrue:[ |
|
404 |
"remove Debugger stepinterrupt/halt frame" |
|
405 |
context sender receiver storeOn:Stdout |
|
406 |
] ifFalse:[ |
|
407 |
'no context - dont know receiver' errorPrintCR |
|
408 |
] |
|
409 |
]. |
|
3700 | 410 |
|
1424 | 411 |
(cmd == $i) ifTrue:[ |
412 |
valid := true. |
|
413 |
context isNil ifTrue: [ |
|
414 |
context := self getContext |
|
415 |
]. |
|
416 |
context notNil ifTrue:[ |
|
417 |
"remove Debugger stepinterrupt/halt frame" |
|
418 |
MiniInspector openOn:(context sender receiver) |
|
419 |
] ifFalse:[ |
|
420 |
'no context - dont know receiver' errorPrintCR |
|
421 |
] |
|
422 |
]. |
|
3700 | 423 |
|
1424 | 424 |
(cmd == $I) ifTrue:[ |
425 |
valid := true. |
|
426 |
context isNil ifTrue: [ |
|
427 |
context := self getContext |
|
428 |
]. |
|
216 | 429 |
"/ context notNil ifTrue:[ |
430 |
"/ "remove Debugger stepinterrupt/halt frame" |
|
431 |
"/ self interpreterLoopWith:(context sender receiver) |
|
432 |
"/ ] ifFalse:[ |
|
1424 | 433 |
"/ 'no context - dont know receiver' errorPrintCR. |
434 |
self interpreterLoopWith:nil |
|
216 | 435 |
"/ ] |
1424 | 436 |
]. |
437 |
context := nil. |
|
3009 | 438 |
|
1424 | 439 |
(cmd == $c) ifTrue:[valid := true. done := true]. |
440 |
(cmd == $s) ifTrue:[valid := true. done := true]. |
|
441 |
(cmd == $t) ifTrue:[valid := true. done := true]. |
|
442 |
(cmd == $a) ifTrue:[valid := true. done := true]. |
|
3700 | 443 |
(cmd == $u) ifTrue:[ |
444 |
stepping := false. |
|
445 |
tracing := false. |
|
446 |
Processor activeProcess vmTrace:false. |
|
447 |
]. |
|
448 |
||
449 |
(cmd == $T) ifTrue:[ |
|
450 |
valid := true. |
|
451 |
proc notNil ifTrue:[ |
|
452 |
proc terminate. |
|
453 |
] ifFalse:[ |
|
454 |
id notNil ifTrue:[ |
|
455 |
'no process with id: ' print. id printCR. |
|
456 |
] ifFalse:[ |
|
457 |
Processor terminateActive |
|
458 |
] |
|
459 |
] |
|
460 |
]. |
|
461 |
||
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
462 |
(cmd == $S) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
463 |
valid := true. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
464 |
proc notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
465 |
'stopping process id: ' print. id printCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
466 |
proc stop. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
467 |
] ifFalse:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
468 |
'invalid process id: ' print. id printCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
469 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
470 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
471 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
472 |
(cmd == $a) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
473 |
"without id-arg, this is handled by caller" |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
474 |
proc notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
475 |
valid := true. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
476 |
proc interruptWith:[AbortSignal raise] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
477 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
478 |
]. |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
479 |
|
3700 | 480 |
(cmd == $Q) ifTrue:[ |
481 |
valid := true. |
|
482 |
proc notNil ifTrue:[ |
|
483 |
proc terminateNoSignal. |
|
484 |
] ifFalse:[ |
|
485 |
id notNil ifTrue:[ |
|
486 |
'no process with id: ' print. id printCR. |
|
487 |
] ifFalse:[ |
|
488 |
Processor terminateActiveNoSignal |
|
489 |
] |
|
490 |
] |
|
491 |
]. |
|
492 |
||
493 |
(cmd == $g) ifTrue:[ |
|
494 |
valid := true. |
|
495 |
id == 3 ifTrue:[ |
|
496 |
ObjectMemory reclaimSymbols. |
|
497 |
ObjectMemory compressOldSpace. |
|
498 |
] ifFalse:[ |
|
499 |
id == 2 ifTrue:[ |
|
500 |
ObjectMemory reclaimSymbols. |
|
501 |
] ifFalse:[ |
|
502 |
ObjectMemory garbageCollect. |
|
503 |
] |
|
504 |
] |
|
505 |
]. |
|
506 |
||
507 |
(cmd == $U) ifTrue:[valid := true. MessageTracer unwrapAllMethods]. |
|
508 |
(cmd == $X) ifTrue:[valid := true. Smalltalk fatalAbort]. |
|
509 |
(cmd == $x) ifTrue:[valid := true. OperatingSystem exit]. |
|
510 |
||
4470 | 511 |
"/ avoid usage print if return was typed ... |
512 |
((cmd == Character return) |
|
513 |
or:[cmd == Character linefeed]) ifTrue:[valid := true.]. |
|
514 |
||
1424 | 515 |
valid ifFalse: [ |
516 |
'valid commands: |
|
3700 | 517 |
c ..... continue |
518 |
s ..... step |
|
519 |
t ..... trace (continue with trace) |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
520 |
a [id]. abort (i.e. raise abort signal) in (current) process |
3700 | 521 |
T [id]. terminate (current) process |
522 |
Q [id]. quick terminate (current) process - no unwinds or cleanup |
|
523 |
||
524 |
P ..... list processes |
|
3701 | 525 |
l [id]. print context chain (of process with id) |
3700 | 526 |
b [id]. full (VM) backtrace |
527 |
B ..... backtrace of all other processes |
|
528 |
||
529 |
r ..... receiver printString |
|
530 |
R ..... Receiver storeString |
|
531 |
i ..... inspect (enter MiniInspector on current receiver) |
|
532 |
I ..... interpreter (expression evaluator) |
|
533 |
U ..... unwrap all traced/breakpointed methods |
|
534 |
g ..... collect all garbage |
|
4463 | 535 |
g 2.... collect all garbage & reclaim symbols |
536 |
g 3.... collect all garbage, reclaim symbols and compress |
|
3700 | 537 |
X ..... exit (+core) |
538 |
x ..... exit Smalltalk |
|
539 |
' errorPrintCR |
|
1424 | 540 |
] |
1 | 541 |
]. |
2113
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
542 |
context := nil. |
1 | 543 |
^ cmd |
1424 | 544 |
|
3701 | 545 |
"Modified: / 31.7.1998 / 17:10:23 / cg" |
1 | 546 |
! |
547 |
||
618 | 548 |
doAbort |
549 |
|con sig| |
|
550 |
||
551 |
(sig := Object abortSignal) isHandled ifTrue:[ |
|
1424 | 552 |
sig raise. |
553 |
'abort raise failed' errorPrintCR. |
|
618 | 554 |
]. |
555 |
||
556 |
"TEMPORARY kludge - find event handler context |
|
557 |
this will be removed, once real debugging is possible |
|
558 |
" |
|
559 |
con := self findContext:#processEvent. |
|
560 |
con isNil ifTrue:[ |
|
1424 | 561 |
con := self findContext:#dispatch. |
618 | 562 |
]. |
563 |
con notNil ifTrue:[ |
|
1424 | 564 |
"got it" |
565 |
con return. |
|
566 |
'return failed' errorPrintCR. |
|
618 | 567 |
]. |
568 |
||
1424 | 569 |
'found no context to resume' errorPrintCR. |
570 |
||
571 |
"Modified: 20.5.1996 / 10:23:00 / cg" |
|
618 | 572 |
! |
573 |
||
1 | 574 |
getCommand |
93 | 575 |
|
2852
b92953bbb7ef
ungrab all screens in case of an error
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
576 |
"/ Display notNil ifTrue:[ |
b92953bbb7ef
ungrab all screens in case of an error
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
577 |
"/ Display ungrabPointer. |
b92953bbb7ef
ungrab all screens in case of an error
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
578 |
"/ Display ungrabKeyboard. |
b92953bbb7ef
ungrab all screens in case of an error
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
579 |
"/ ]. |
3126
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
580 |
|
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
581 |
"/ Screen notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
582 |
"/ Screen allScreens do:[:aScreen | |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
583 |
"/ aScreen ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
584 |
"/ aScreen ungrabKeyboard. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
585 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
586 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
587 |
|
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
588 |
Display notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
589 |
Display ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
590 |
Display ungrabKeyboard. |
852
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
591 |
]. |
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
592 |
|
1 | 593 |
'MiniDebugger> ' print. |
93 | 594 |
|
976 | 595 |
UserInterruptSignal handle:[:ex | |
596 |
ex restart |
|
159 | 597 |
] do:[ |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
598 |
|c cmd arg cnt| |
3700 | 599 |
|
976 | 600 |
cmd := Character fromUser. |
601 |
cmd isNil ifTrue:[ |
|
602 |
" |
|
603 |
mhmh end-of-file; |
|
604 |
return a 'c' (for continue); hope thats ok. |
|
605 |
" |
|
606 |
cmd := $c |
|
607 |
]. |
|
93 | 608 |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
609 |
cnt := nil. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
610 |
(cmd isDigit) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
611 |
cnt := 0. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
612 |
[cmd isDigit] whileTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
613 |
cnt := cnt * 10 + cmd digitValue. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
614 |
cmd := Character fromUser |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
615 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
616 |
[cmd == Character space] whileTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
617 |
cmd := Character fromUser |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
618 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
619 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
620 |
|
976 | 621 |
" |
3700 | 622 |
collect to end-of-line in arg |
976 | 623 |
" |
624 |
c := cmd. |
|
3700 | 625 |
arg := ''. |
976 | 626 |
[c isNil or:[c isEndOfLineCharacter]] whileFalse: [ |
3700 | 627 |
arg := arg copyWith:c. |
976 | 628 |
c := Character fromUser. |
629 |
]. |
|
3700 | 630 |
commandArg := arg copyFrom:2. |
631 |
command := cmd. |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
632 |
commandCount := cnt. |
1 | 633 |
]. |
3700 | 634 |
^ command |
976 | 635 |
|
3700 | 636 |
"Modified: / 31.7.1998 / 16:11:01 / cg" |
1 | 637 |
! |
638 |
||
639 |
interpreterLoopWith:anObject |
|
640 |
|line done| |
|
1424 | 641 |
'read-eval-print loop; exit with empty line' printCR. |
3700 | 642 |
'' printCR. |
643 |
||
1 | 644 |
done := false. |
645 |
[done] whileFalse:[ |
|
3700 | 646 |
'> ' print. |
647 |
||
1424 | 648 |
line := Stdin nextLine. |
649 |
(line size == 0) ifTrue:[ |
|
650 |
done := true |
|
651 |
] ifFalse:[ |
|
652 |
(Compiler evaluate:line |
|
653 |
receiver:anObject |
|
654 |
notifying:nil) printCR |
|
655 |
] |
|
1 | 656 |
] |
1424 | 657 |
|
3700 | 658 |
"Modified: / 31.7.1998 / 16:01:47 / cg" |
618 | 659 |
! |
660 |
||
2772 | 661 |
printAllBacktraces |
662 |
Process allInstancesDo:[:p | |
|
663 |
(p ~~ Processor activeProcess |
|
664 |
and:[p isDead not]) ifTrue:[ |
|
665 |
'---------------------------------------------------------' printCR. |
|
666 |
' proc id=' print. p id print. |
|
667 |
' name=''' print. p name print. |
|
668 |
''' createdBy: ' print. p creatorId print. |
|
669 |
' state=' print. p state print. |
|
670 |
' prio=' print. p priority printCR. |
|
671 |
'' printCR. '' printCR. |
|
672 |
||
673 |
self printBacktraceFrom:(p suspendedContext) |
|
674 |
] |
|
675 |
] |
|
676 |
! |
|
677 |
||
618 | 678 |
showProcesses |
679 |
|active| |
|
680 |
||
681 |
active := Processor activeProcess. |
|
3700 | 682 |
'current id=' print. active id print. ' name=''' print. active name print. '''' printCR. |
618 | 683 |
|
3700 | 684 |
Process allSubInstancesDo:[:p | |
685 |
'proc id=' print. (p id printStringPaddedTo:5) print. |
|
686 |
(p state printStringPaddedTo:10) print. |
|
687 |
' pri=' print. (p priority printStringPaddedTo:2) print. |
|
688 |
' creator:' print. (p creatorId printStringPaddedTo:5) print. |
|
689 |
' name=''' print. p name print. |
|
690 |
'''' printCR. |
|
618 | 691 |
] |
1424 | 692 |
|
3700 | 693 |
"Modified: / 31.7.1998 / 16:30:19 / cg" |
1 | 694 |
! ! |
618 | 695 |
|
658 | 696 |
!MiniDebugger class methodsFor:'documentation'! |
697 |
||
698 |
version |
|
4960 | 699 |
^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.46 1999-10-27 16:17:23 stefan Exp $' |
658 | 700 |
! ! |