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