author | Claus Gittinger <cg@exept.de> |
Tue, 27 Jul 1999 16:54:33 +0200 | |
changeset 4463 | 60cc202629e2 |
parent 4209 | 7c1b4df9e555 |
child 4470 | 8b5faec7deef |
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 |
||
51 |
enter |
|
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 |
|
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
54 |
^ self enterWithMessage:'MiniDebugger entered' |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
55 |
|
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
56 |
"Modified: / 19.5.1999 / 18:15:03 / cg" |
618 | 57 |
! |
58 |
||
59 |
enter:aContext |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
60 |
"enter a miniDebugger - for protocol compatibility with the GUI-debugger" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
61 |
|
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
62 |
^ self enterWithMessage:'MiniDebugger entered' |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
63 |
|
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
64 |
"Modified: / 19.5.1999 / 18:13:06 / cg" |
618 | 65 |
! |
66 |
||
67 |
enter:aContext withMessage:aString |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
68 |
"enter a miniDebugger - for protocol compatibility with the GUI-debugger" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
69 |
|
618 | 70 |
^ self enterWithMessage:aString |
71 |
! |
|
72 |
||
73 |
enterWithMessage:aString |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
74 |
"enter a miniDebugger" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
75 |
|
618 | 76 |
|active| |
77 |
||
78 |
StepInterruptPending := nil. |
|
79 |
||
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
80 |
Object errorSignal handle:[:ex | |
3701 | 81 |
ex return |
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
82 |
] do:[ |
3701 | 83 |
thisContext isRecursive ifTrue:[ |
84 |
"/ 'recursive error in debugger ignored' errorPrintCR. |
|
85 |
^ self |
|
86 |
]. |
|
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
87 |
aString printCR. |
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
88 |
Processor notNil ifTrue:[ |
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
89 |
active := Processor activeProcess. |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
90 |
'process: id=' print. active id print. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
91 |
' name=' print. active name printCR. |
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
92 |
]. |
618 | 93 |
]. |
4209
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 |
OperatingSystem hasConsole ifFalse:[ |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
96 |
Object errorSignal handle:[:ex | |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
97 |
ex return |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
98 |
] do:[ |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
99 |
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
|
100 |
]. |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
101 |
|
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
102 |
Object errorSignal handle:[:ex | |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
103 |
Smalltalk exit |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
104 |
] do:[ |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
105 |
AbortSignal raise. |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
106 |
] |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
107 |
] ifTrue:[ |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
108 |
self new enter. |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
109 |
]. |
618 | 110 |
^ nil |
1424 | 111 |
|
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
112 |
"Modified: / 19.5.1999 / 18:14:33 / cg" |
618 | 113 |
! |
1 | 114 |
|
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 |
||
131 |
singleStep:aBlock |
|
132 |
|aDebugger| |
|
133 |
||
134 |
aDebugger := self new stepping. |
|
241 | 135 |
ObjectMemory stepInterruptHandler:aDebugger. |
2 | 136 |
ObjectMemory flushInlineCaches. |
241 | 137 |
StepInterruptPending := 1. |
138 |
InterruptPending := 1. |
|
1 | 139 |
aBlock value. |
2 | 140 |
StepInterruptPending := nil. |
141 |
ObjectMemory stepInterruptHandler:nil |
|
1 | 142 |
! |
143 |
||
144 |
trace:aBlock |
|
1424 | 145 |
self trace:aBlock with:[:where | where printCR] |
146 |
||
147 |
"Modified: 20.5.1996 / 10:27:37 / cg" |
|
1 | 148 |
! |
149 |
||
150 |
trace:aBlock on:aStream |
|
151 |
self trace:aBlock with:[:where | where printString printOn:aStream. |
|
159 | 152 |
aStream cr] |
1 | 153 |
! |
154 |
||
155 |
trace:aBlock with:aTraceBlock |
|
156 |
|aDebugger| |
|
157 |
||
158 |
aDebugger := self new tracingWith:aTraceBlock. |
|
241 | 159 |
ObjectMemory stepInterruptHandler:aDebugger. |
1 | 160 |
ObjectMemory flushInlineCaches. |
241 | 161 |
StepInterruptPending := 1. |
162 |
InterruptPending := 1. |
|
1 | 163 |
aBlock value. |
2 | 164 |
ObjectMemory stepInterruptHandler:nil. |
1 | 165 |
StepInterruptPending := nil. |
166 |
^ nil |
|
167 |
! ! |
|
168 |
||
618 | 169 |
!MiniDebugger methodsFor:'initialization'! |
1 | 170 |
|
171 |
initialize |
|
172 |
traceBlock := nil. |
|
173 |
tracing := false. |
|
174 |
stepping := false |
|
175 |
! ! |
|
176 |
||
618 | 177 |
!MiniDebugger methodsFor:'interrupt handling'! |
1 | 178 |
|
179 |
enter |
|
159 | 180 |
|leaveCmd stillHere| |
74 | 181 |
|
182 |
stillHere := true. |
|
183 |
[stillHere] whileTrue:[ |
|
3769 | 184 |
leaveCmd := self commandLoop. |
1 | 185 |
|
3769 | 186 |
(leaveCmd == $s) ifTrue: [ |
187 |
self stepping. |
|
188 |
ObjectMemory flushInlineCaches. |
|
189 |
ObjectMemory stepInterruptHandler:self. |
|
190 |
stillHere := false. |
|
191 |
StepInterruptPending := 1. |
|
192 |
InterruptPending := 1 |
|
193 |
]. |
|
194 |
(leaveCmd == $t) ifTrue: [ |
|
195 |
traceBlock := [:where | where fullPrint]. |
|
196 |
ObjectMemory flushInlineCaches. |
|
197 |
ObjectMemory stepInterruptHandler:self. |
|
198 |
stillHere := false. |
|
199 |
StepInterruptPending := 1. |
|
200 |
InterruptPending := 1 |
|
201 |
]. |
|
202 |
(leaveCmd == $c) ifTrue: [ |
|
203 |
traceBlock := nil. |
|
204 |
stillHere := false. |
|
205 |
stepping := false. |
|
206 |
tracing := false. |
|
207 |
StepInterruptPending := nil. |
|
208 |
InterruptPending := nil |
|
209 |
]. |
|
210 |
(leaveCmd == $a) ifTrue: [ |
|
211 |
"abort" |
|
212 |
stepping := false. |
|
213 |
tracing := false. |
|
214 |
StepInterruptPending := nil. |
|
215 |
InterruptPending := nil. |
|
216 |
self doAbort. |
|
217 |
stillHere := true. |
|
218 |
"failed abort" |
|
219 |
]. |
|
1 | 220 |
]. |
221 |
^ nil |
|
3769 | 222 |
|
223 |
"Modified: / 18.8.1998 / 18:10:29 / cg" |
|
618 | 224 |
! |
225 |
||
226 |
stepInterrupt |
|
227 |
|where| |
|
228 |
||
229 |
where := thisContext. "where is stepInterrupt context" |
|
230 |
where notNil ifTrue:[ |
|
1424 | 231 |
where := where sender "where is now interrupted methods context" |
618 | 232 |
]. |
233 |
stepping ifTrue:[ |
|
1424 | 234 |
where notNil ifTrue:[ |
235 |
where fullPrint |
|
236 |
] ifFalse:[ |
|
237 |
'stepInterrupt: no context' errorPrintCR |
|
238 |
]. |
|
239 |
self enter |
|
618 | 240 |
] ifFalse:[ |
1424 | 241 |
where notNil ifTrue:[ |
242 |
traceBlock notNil ifTrue:[ |
|
243 |
traceBlock value:where |
|
244 |
] |
|
245 |
] ifFalse:[ |
|
246 |
'traceInterrupt: no context' errorPrintCR |
|
247 |
]. |
|
248 |
ObjectMemory flushInlineCaches. |
|
249 |
StepInterruptPending := 1. |
|
250 |
InterruptPending := 1 |
|
618 | 251 |
] |
1424 | 252 |
|
253 |
"Modified: 20.5.1996 / 10:23:11 / cg" |
|
1 | 254 |
! ! |
255 |
||
618 | 256 |
!MiniDebugger methodsFor:'private'! |
74 | 257 |
|
618 | 258 |
findContext:aSelector |
259 |
|con| |
|
74 | 260 |
|
618 | 261 |
con := thisContext sender. |
262 |
[con notNil] whileTrue:[ |
|
263 |
(con isBlockContext not and:[con selector == aSelector]) ifTrue:[ |
|
264 |
"got it" |
|
265 |
^ con |
|
266 |
]. |
|
267 |
con := con sender |
|
74 | 268 |
]. |
618 | 269 |
^ nil |
74 | 270 |
! |
271 |
||
618 | 272 |
getContext |
273 |
|backtrace| |
|
274 |
backtrace := thisContext. |
|
275 |
(backtrace notNil) ifTrue: [ |
|
276 |
"remove Context getContext frame" |
|
277 |
backtrace := backtrace sender. |
|
278 |
"remove Debugger showContext frame" |
|
279 |
backtrace := backtrace sender. |
|
280 |
"remove Debugger commandLoop frame" |
|
281 |
backtrace := backtrace sender. |
|
282 |
"remove Debugger enter frame" |
|
283 |
backtrace := backtrace sender |
|
284 |
]. |
|
285 |
^ backtrace |
|
286 |
! |
|
74 | 287 |
|
2772 | 288 |
printBacktraceFrom:aContext |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
289 |
|context n| |
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 |
aContext isNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
292 |
'no context' errorPrintCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
293 |
^ self |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
294 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
295 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
296 |
context := aContext. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
297 |
n := commandCount. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
298 |
[context notNil] whileTrue: [ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
299 |
context fullPrint. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
300 |
context := context sender. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
301 |
n notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
302 |
n := n - 1. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
303 |
n <= 0 ifTrue:[ |
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 |
] |
2772 | 307 |
] |
308 |
! |
|
309 |
||
618 | 310 |
stepping |
311 |
traceBlock := nil. |
|
312 |
tracing := false. |
|
313 |
stepping := true |
|
74 | 314 |
! |
315 |
||
618 | 316 |
tracingWith:aBlockOrNil |
317 |
traceBlock := aBlockOrNil. |
|
318 |
stepping := false. |
|
319 |
tracing := true |
|
320 |
! ! |
|
321 |
||
322 |
!MiniDebugger methodsFor:'user commands'! |
|
323 |
||
1 | 324 |
commandLoop |
3700 | 325 |
|cmd done valid context id proc| |
1 | 326 |
|
327 |
done := false. |
|
328 |
[done] whileFalse:[ |
|
1424 | 329 |
valid := false. |
330 |
cmd := self getCommand. |
|
2772 | 331 |
cmd isNil ifTrue:[ "/ EOF -> continue |
332 |
cmd := $c |
|
333 |
]. |
|
3700 | 334 |
|
335 |
commandArg notEmpty ifTrue:[ |
|
336 |
id := Number readFrom:commandArg onError:nil. |
|
337 |
||
338 |
id notNil ifTrue:[ |
|
339 |
proc := Process allSubInstances detect:[:p | p id == id] ifNone:nil. |
|
3701 | 340 |
proc == Processor activeProcess ifTrue:[ |
341 |
id := proc := nil |
|
342 |
] |
|
3700 | 343 |
] |
344 |
]. |
|
345 |
||
3701 | 346 |
(cmd == $l) ifTrue:[ |
1424 | 347 |
valid := true. |
3700 | 348 |
proc notNil ifTrue:[ |
349 |
'-------- walkback of process ' print. id print. ' -------' printCR. |
|
350 |
self printBacktraceFrom:(proc suspendedContext) |
|
351 |
] ifFalse:[ |
|
352 |
id notNil ifTrue:[ |
|
353 |
'no process with id: ' print. id printCR. |
|
354 |
] ifFalse:[ |
|
355 |
context isNil ifTrue: [ |
|
356 |
context := self getContext |
|
357 |
]. |
|
358 |
'-------- walkback of current process -------' printCR. |
|
359 |
self printBacktraceFrom:context |
|
360 |
] |
|
1424 | 361 |
]. |
362 |
]. |
|
3700 | 363 |
|
1424 | 364 |
(cmd == $b) ifTrue:[ |
365 |
valid := true. |
|
3700 | 366 |
proc notNil ifTrue:[ |
367 |
'-------- VM walkback of process ' print. id print. ' -------' printCR. |
|
368 |
ObjectMemory printStackBacktraceFrom:(proc suspendedContext) |
|
369 |
] ifFalse:[ |
|
370 |
id notNil ifTrue:[ |
|
371 |
'no process with id: ' print. id printCR. |
|
372 |
] ifFalse:[ |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
373 |
'-------- VM walkback of current process -------' printCR. |
3700 | 374 |
ObjectMemory printStackBacktrace |
375 |
] |
|
376 |
] |
|
1424 | 377 |
]. |
3700 | 378 |
|
2113
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
379 |
(cmd == $B) ifTrue:[ |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
380 |
valid := true. |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
381 |
self printAllBacktraces |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
382 |
]. |
3700 | 383 |
|
1424 | 384 |
(cmd == $P) ifTrue:[ |
385 |
valid := true. |
|
386 |
self showProcesses. |
|
387 |
]. |
|
3700 | 388 |
|
1424 | 389 |
(cmd == $r) ifTrue:[ |
390 |
valid := true. |
|
391 |
context isNil ifTrue: [ |
|
392 |
context := self getContext |
|
393 |
]. |
|
394 |
context notNil ifTrue:[ |
|
395 |
"remove Debugger stepinterrupt/halt frame" |
|
396 |
context sender receiver printCR |
|
397 |
] ifFalse:[ |
|
398 |
'no context - dont know receiver' errorPrintCR |
|
399 |
] |
|
400 |
]. |
|
3700 | 401 |
|
1424 | 402 |
(cmd == $R) ifTrue:[ |
403 |
valid := true. |
|
404 |
context isNil ifTrue: [ |
|
405 |
context := self getContext |
|
406 |
]. |
|
407 |
context notNil ifTrue:[ |
|
408 |
"remove Debugger stepinterrupt/halt frame" |
|
409 |
context sender receiver storeOn:Stdout |
|
410 |
] ifFalse:[ |
|
411 |
'no context - dont know receiver' errorPrintCR |
|
412 |
] |
|
413 |
]. |
|
3700 | 414 |
|
1424 | 415 |
(cmd == $i) ifTrue:[ |
416 |
valid := true. |
|
417 |
context isNil ifTrue: [ |
|
418 |
context := self getContext |
|
419 |
]. |
|
420 |
context notNil ifTrue:[ |
|
421 |
"remove Debugger stepinterrupt/halt frame" |
|
422 |
MiniInspector openOn:(context sender receiver) |
|
423 |
] ifFalse:[ |
|
424 |
'no context - dont know receiver' errorPrintCR |
|
425 |
] |
|
426 |
]. |
|
3700 | 427 |
|
1424 | 428 |
(cmd == $I) ifTrue:[ |
429 |
valid := true. |
|
430 |
context isNil ifTrue: [ |
|
431 |
context := self getContext |
|
432 |
]. |
|
216 | 433 |
"/ context notNil ifTrue:[ |
434 |
"/ "remove Debugger stepinterrupt/halt frame" |
|
435 |
"/ self interpreterLoopWith:(context sender receiver) |
|
436 |
"/ ] ifFalse:[ |
|
1424 | 437 |
"/ 'no context - dont know receiver' errorPrintCR. |
438 |
self interpreterLoopWith:nil |
|
216 | 439 |
"/ ] |
1424 | 440 |
]. |
441 |
context := nil. |
|
3009 | 442 |
|
1424 | 443 |
(cmd == $c) ifTrue:[valid := true. done := true]. |
444 |
(cmd == $s) ifTrue:[valid := true. done := true]. |
|
445 |
(cmd == $t) ifTrue:[valid := true. done := true]. |
|
446 |
(cmd == $a) ifTrue:[valid := true. done := true]. |
|
3700 | 447 |
(cmd == $u) ifTrue:[ |
448 |
stepping := false. |
|
449 |
tracing := false. |
|
450 |
Processor activeProcess vmTrace:false. |
|
451 |
]. |
|
452 |
||
453 |
(cmd == $T) ifTrue:[ |
|
454 |
valid := true. |
|
455 |
proc notNil ifTrue:[ |
|
456 |
proc terminate. |
|
457 |
] ifFalse:[ |
|
458 |
id notNil ifTrue:[ |
|
459 |
'no process with id: ' print. id printCR. |
|
460 |
] ifFalse:[ |
|
461 |
Processor terminateActive |
|
462 |
] |
|
463 |
] |
|
464 |
]. |
|
465 |
||
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
466 |
(cmd == $S) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
467 |
valid := true. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
468 |
proc notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
469 |
'stopping process id: ' print. id printCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
470 |
proc stop. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
471 |
] ifFalse:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
472 |
'invalid process id: ' print. id printCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
473 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
474 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
475 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
476 |
(cmd == $a) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
477 |
"without id-arg, this is handled by caller" |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
478 |
proc notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
479 |
valid := true. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
480 |
proc interruptWith:[AbortSignal raise] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
481 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
482 |
]. |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
483 |
|
3700 | 484 |
(cmd == $Q) ifTrue:[ |
485 |
valid := true. |
|
486 |
proc notNil ifTrue:[ |
|
487 |
proc terminateNoSignal. |
|
488 |
] ifFalse:[ |
|
489 |
id notNil ifTrue:[ |
|
490 |
'no process with id: ' print. id printCR. |
|
491 |
] ifFalse:[ |
|
492 |
Processor terminateActiveNoSignal |
|
493 |
] |
|
494 |
] |
|
495 |
]. |
|
496 |
||
497 |
(cmd == $g) ifTrue:[ |
|
498 |
valid := true. |
|
499 |
id == 3 ifTrue:[ |
|
500 |
ObjectMemory reclaimSymbols. |
|
501 |
ObjectMemory compressOldSpace. |
|
502 |
] ifFalse:[ |
|
503 |
id == 2 ifTrue:[ |
|
504 |
ObjectMemory reclaimSymbols. |
|
505 |
] ifFalse:[ |
|
506 |
ObjectMemory garbageCollect. |
|
507 |
] |
|
508 |
] |
|
509 |
]. |
|
510 |
||
511 |
(cmd == $U) ifTrue:[valid := true. MessageTracer unwrapAllMethods]. |
|
512 |
(cmd == $X) ifTrue:[valid := true. Smalltalk fatalAbort]. |
|
513 |
(cmd == $x) ifTrue:[valid := true. OperatingSystem exit]. |
|
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 |
|
4463 | 699 |
^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.42 1999-07-27 14:54:33 cg Exp $' |
658 | 700 |
! ! |