MiniInspector.st
author Stefan Vogel <sv@exept.de>
Fri, 30 Sep 2016 16:48:48 +0200
changeset 20484 5bc49b246ef2
parent 19390 c9149f3022e1
child 19410 f9d7cb8bd74c
child 20721 79c02fb533fb
permissions -rw-r--r--
#OTHER by stefan Use (*WriteStream on:'') instead of (*WriteStream on:String new)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
308
f04744ef7b5d *** empty log message ***
claus
parents: 93
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
7092
630807cd320f Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 5805
diff changeset
    12
"{ Package: 'stx:libbasic' }"
630807cd320f Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 5805
diff changeset
    13
19381
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
    14
"{ NameSpace: Smalltalk }"
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
    15
720
f31e0e5ab6e0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
    16
Object subclass:#MiniInspector
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    17
	instanceVariableNames:'inspectedObject commandArg inputStream'
1297
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    18
	classVariableNames:''
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    19
	poolDictionaries:''
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    20
	category:'System-Debugging-Support'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    21
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    22
89
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    23
!MiniInspector class methodsFor:'documentation'!
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    24
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    25
copyright
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    26
"
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    27
 COPYRIGHT (c) 1989 by Claus Gittinger
308
f04744ef7b5d *** empty log message ***
claus
parents: 93
diff changeset
    28
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    29
89
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    30
 This software is furnished under a license and may be used
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    31
 only in accordance with the terms of that license and with the
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    33
 be provided or otherwise made available to, or used by, any
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    34
 other person.  No title to or ownership of the software is
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    35
 hereby transferred.
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    36
"
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    37
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    38
89
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    39
documentation
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    40
"
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    41
    a primitive (non graphical) inspector for use on systems without
15926
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
    42
    graphics or when the real inspector dies (i.e. the UI is locked).
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
    43
    Sometimes useful as a last chance to fix a broken UI / event handling.
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
    44
    Needs a console.
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
    45
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
    46
    MiniInspector openOn: Display
1297
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    47
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    48
    [author:]
16558
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
    49
	Claus Gittinger
89
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    50
"
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    51
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    52
a27a279701f8 Initial revision
claus
parents:
diff changeset
    53
!MiniInspector class methodsFor:'instance creation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    54
a27a279701f8 Initial revision
claus
parents:
diff changeset
    55
openOn:anObject
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    56
    ^ self openOn:anObject input:nil
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    57
!
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    58
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    59
openOn:anObject input:inputStreamOrNil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    60
    |anInspector|
14938
bb6698374550 class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 10323
diff changeset
    61
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    62
    anInspector := (self new) initializeFor:anObject.
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    63
    anInspector inputStream:inputStreamOrNil.
14938
bb6698374550 class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 10323
diff changeset
    64
    anInspector enter.
bb6698374550 class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 10323
diff changeset
    65
    ^ anInspector
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    66
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
    67
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    68
!MiniInspector methodsFor:'accessing'!
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    69
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    70
inputStream:something
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    71
    inputStream := something.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    72
! !
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    73
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    74
!MiniInspector methodsFor:'private'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    75
a27a279701f8 Initial revision
claus
parents:
diff changeset
    76
commandLoop
5802
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
    77
    |cmd valid|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    78
16250
c376e523d007 class: MiniInspector
Stefan Vogel <sv@exept.de>
parents: 15926
diff changeset
    79
    'MiniInspector on ' errorPrint.  inspectedObject displayString errorPrintCR.
c376e523d007 class: MiniInspector
Stefan Vogel <sv@exept.de>
parents: 15926
diff changeset
    80
    '' errorPrintCR.
5802
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
    81
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
    82
    [true] whileTrue:[
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    83
        valid := false.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    84
        cmd := self getCommand:'inspector> '.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    85
        cmd isNil ifTrue:[   "/ EOF -> quit
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    86
            cmd := $q
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    87
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    88
        cmd isNumber ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    89
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    90
            self inspectInstvar:cmd of:inspectedObject
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    91
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    92
        (cmd == $i) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    93
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    94
            self printInstVarsOf:inspectedObject
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    95
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    96
        (cmd == $p) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    97
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    98
            inspectedObject displayString errorPrintCR
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
    99
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   100
        (cmd == $c) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   101
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   102
            inspectedObject class displayString errorPrintCR
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   103
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   104
        (cmd == $C) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   105
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   106
            MiniInspector openOn:inspectedObject class input:inputStream.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   107
            'back in previous inspector; inspecting ' errorPrint.  inspectedObject displayString errorPrintCR.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   108
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   109
        (cmd == $d) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   110
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   111
            ObjectMemory dumpObject:inspectedObject
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   112
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   113
        (cmd == $E) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   114
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   115
            Parser evaluate:commandArg receiver:inspectedObject.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   116
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   117
        (cmd == $e) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   118
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   119
            (Parser evaluate:commandArg receiver:inspectedObject) errorPrintCR.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   120
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   121
        (cmd == $e) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   122
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   123
            ObjectMemory dumpObject:inspectedObject
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   124
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   125
        (cmd == $*) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   126
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   127
            inspectedObject becomeNil.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   128
            ^ cmd.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   129
        ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   130
        (cmd == $I) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   131
            valid := true.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   132
            self interpreterLoopWith:inspectedObject
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   133
        ].
5802
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   134
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   135
        (cmd == $q) ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   136
            ^ cmd.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   137
        ].
5802
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   138
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   139
        valid ifFalse: [
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   140
            'valid commands:
15926
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   141
 p ...... print inspected object
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   142
 c ...... print inspected objects class
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   143
 i ...... print instvars
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   144
 d ...... VM-dump inspected object
5804
33282793d66d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5803
diff changeset
   145
15926
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   146
 I ...... interpreter
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   147
 e expr   evaluate expression & print result ("E" to not print)
5804
33282793d66d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5803
diff changeset
   148
15926
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   149
 C ...... inspect class
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   150
 <Num> .. inspect instvar num (1..)
5803
a478ecef08c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5802
diff changeset
   151
15926
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   152
 * ...... becomeNil and quit (dangerous)
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   153
 q ...... quit
5802
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   154
'       errorPrintCR
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   155
        ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   156
    ].
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   157
15926
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   158
    "Modified: / 03-02-2014 / 10:19:46 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   159
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   160
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   161
enter
15904
7b8100b48c7a AbortSignal -> AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents: 14938
diff changeset
   162
    AbortOperationRequest handle:[:ex |
16558
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   163
	'** Abort Signal caught - back in previous debugLevel' printCR.
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   164
	ex restart
5805
007549d68d4b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5804
diff changeset
   165
    ] do:[
16558
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   166
	Error handle:[:ex |
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   167
	    |yesNo|
5805
007549d68d4b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5804
diff changeset
   168
16558
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   169
	    'Error while executing command: ' errorPrint.
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   170
	    ex description errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   171
	    yesNo := self getCommand:'- (i)gnore / (p)roceed / (d)ebug ? '.
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   172
	    yesNo == $d ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   173
		ex reject
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   174
	    ].
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   175
	    yesNo == $p ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   176
		ex proceed
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   177
	    ].
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   178
	    ex restart
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   179
	] do:[
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   180
	    self commandLoop.
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   181
	].
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   182
    ].
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   183
    ^ nil
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   184
!
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   185
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   186
getCharacter
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   187
    inputStream isNil ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   188
        "/ globally blocking
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   189
        ^ Character fromUser
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   190
    ].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   191
    ^ inputStream next
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   192
!
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   193
5805
007549d68d4b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5804
diff changeset
   194
getCommand:prompt
15926
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   195
    |cmd c num arg|
5802
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   196
16250
c376e523d007 class: MiniInspector
Stefan Vogel <sv@exept.de>
parents: 15926
diff changeset
   197
    prompt errorPrint.
5802
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   198
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   199
    c := cmd := self getCharacter.
16250
c376e523d007 class: MiniInspector
Stefan Vogel <sv@exept.de>
parents: 15926
diff changeset
   200
    c isNil ifTrue:[
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   201
        ^ nil.
16250
c376e523d007 class: MiniInspector
Stefan Vogel <sv@exept.de>
parents: 15926
diff changeset
   202
    ].
c376e523d007 class: MiniInspector
Stefan Vogel <sv@exept.de>
parents: 15926
diff changeset
   203
    c isDigit ifTrue:[
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   204
        num := 0.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   205
        [
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   206
            num := (num * 10) + c digitValue.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   207
            c := self getCharacter.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   208
        ] doWhile:[c notNil and:[c isDigit]].
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   209
        ^ num "/ numeric
5802
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   210
    ].
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   211
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   212
    c := self getCharacter.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   213
    [c notNil and:[c isEndOfLineCharacter not and:[c isSeparator ]]] whileTrue:[ c := self getCharacter ].
15926
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   214
    arg := ''.
4965
e4f22bc0d3c8 Fix input of nil character.
Stefan Vogel <sv@exept.de>
parents: 2775
diff changeset
   215
    [c notNil and:[c isEndOfLineCharacter]] whileFalse:[
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   216
        arg := arg copyWith:c.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   217
        c := self getCharacter
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   218
    ].
15926
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   219
    commandArg := arg.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   220
    ^ cmd
15926
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   221
2a89ee50988c class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 15904
diff changeset
   222
    "Modified: / 03-02-2014 / 10:16:49 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   223
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   224
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   225
initializeFor:anObject
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   226
    inspectedObject := anObject.
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   227
    ^self
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   228
!
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   229
16635
ee5ebbb9e049 class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 16558
diff changeset
   230
inspect:anObject
ee5ebbb9e049 class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 16558
diff changeset
   231
    inspectedObject := anObject.
ee5ebbb9e049 class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 16558
diff changeset
   232
!
ee5ebbb9e049 class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 16558
diff changeset
   233
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   234
inspectInstvar:which of:anObject
5802
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   235
    |numInsts idx|
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   236
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   237
    numInsts := anObject class instSize.
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   238
93748287026d better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents: 4965
diff changeset
   239
    which > numInsts ifTrue:[
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   240
        idx := which - numInsts.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   241
        idx > anObject basicSize ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   242
            'invalid indexed instvar index: ' errorPrint. idx errorPrintCR
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   243
        ] ifFalse:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   244
            'Inspecting indexed instVar ' errorPrint. idx errorPrint. '...' errorPrintCR.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   245
            MiniInspector openOn:(anObject basicAt:idx) input:inputStream.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   246
            'back in previous inspector; inspecting ' errorPrint.  inspectedObject displayString errorPrintCR.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   247
        ]
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   248
    ] ifFalse: [
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   249
        which < 0 ifTrue:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   250
            'invalid instVar # (must be >= 1)' errorPrintCR
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   251
        ] ifFalse:[
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   252
            'Inspecting instVar ' errorPrint. which errorPrint. '...' errorPrintCR.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   253
            MiniInspector openOn:(anObject instVarAt:which) input:inputStream.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   254
            'back in previous inspector; inspecting ' errorPrint.  inspectedObject displayString errorPrintCR.
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   255
        ].
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   256
    ]
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   257
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   258
    "Modified: 20.5.1996 / 10:27:40 / cg"
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   259
!
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   260
7092
630807cd320f Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 5805
diff changeset
   261
interpreterLoopWith:anObject
630807cd320f Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 5805
diff changeset
   262
    |line done rslt|
16558
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   263
16250
c376e523d007 class: MiniInspector
Stefan Vogel <sv@exept.de>
parents: 15926
diff changeset
   264
    'read-eval-print loop; exit with empty line' errorPrintCR.
c376e523d007 class: MiniInspector
Stefan Vogel <sv@exept.de>
parents: 15926
diff changeset
   265
    '' errorPrintCR.
16558
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   266
7092
630807cd320f Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 5805
diff changeset
   267
    done := false.
630807cd320f Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 5805
diff changeset
   268
    [done] whileFalse:[
19381
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   269
        '> ' errorPrint.
16558
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   270
19381
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   271
        line := Processor activeProcess stdin nextLine.
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   272
        (line size == 0) ifTrue:[
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   273
            done := true
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   274
        ] ifFalse:[
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   275
            rslt := Compiler
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   276
                evaluate:line
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   277
                in:nil
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   278
                receiver:anObject
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   279
                notifying:nil
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   280
                ifFail:[].
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   281
            rslt errorPrintCR.
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   282
        ]
7092
630807cd320f Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 5805
diff changeset
   283
    ]
630807cd320f Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 5805
diff changeset
   284
!
630807cd320f Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 5805
diff changeset
   285
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   286
printInstVarsOf:anObject
5805
007549d68d4b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5804
diff changeset
   287
    |n "{ Class: SmallInteger }" names |
903
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   288
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   289
    n := anObject class instSize.
5805
007549d68d4b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5804
diff changeset
   290
    names := anObject class allInstVarNames.
007549d68d4b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5804
diff changeset
   291
16250
c376e523d007 class: MiniInspector
Stefan Vogel <sv@exept.de>
parents: 15926
diff changeset
   292
    'number of instvars: ' errorPrint. n errorPrintCR.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   293
    1 to:n do:[:i |
16558
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   294
	(i printStringLeftPaddedTo:2) errorPrint.
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   295
	' {' errorPrint. (names at:i) errorPrint. '}' errorPrint.
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   296
	': ' errorPrint.
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   297
	((anObject instVarAt:i) displayString contractAtEndTo:80) errorPrintCR
903
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   298
    ].
5805
007549d68d4b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5804
diff changeset
   299
903
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   300
    n := anObject basicSize.
5805
007549d68d4b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5804
diff changeset
   301
    n > 0 ifTrue:[
16558
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   302
	'number of indexed instvars: ' errorPrint. n errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   303
	n > 10 ifTrue:[n := 10].
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   304
	1 to:n do:[:i |
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   305
	    ' [' errorPrint. i errorPrint. ']: ' errorPrint.
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   306
	    ((anObject basicAt:i) displayString contractAtEndTo:80) errorPrintCR
Claus Gittinger <cg@exept.de>
parents: 16250
diff changeset
   307
	]
903
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   308
    ].
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   309
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   310
    "Modified: 20.5.1996 / 10:27:45 / cg"
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   311
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   312
658
cf969399434d version at the end
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
   313
!MiniInspector class methodsFor:'documentation'!
cf969399434d version at the end
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
   314
cf969399434d version at the end
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
   315
version
19381
ff17cf92e2c3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16635
diff changeset
   316
    ^ '$Header$'
19390
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   317
!
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   318
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   319
version_CVS
c9149f3022e1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19381
diff changeset
   320
    ^ '$Header$'
658
cf969399434d version at the end
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
   321
! !
16635
ee5ebbb9e049 class: MiniInspector
Claus Gittinger <cg@exept.de>
parents: 16558
diff changeset
   322