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