MiniInspector.st
author Claus Gittinger <cg@exept.de>
Tue, 29 Dec 1998 17:56:57 +0100
changeset 3950 f9c4485a91d1
parent 2775 acdd73312418
child 4965 e4f22bc0d3c8
permissions -rw-r--r--
avoid nil package return
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
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
720
f31e0e5ab6e0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
    13
Object subclass:#MiniInspector
1297
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    14
	instanceVariableNames:'inspectedObject'
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    15
	classVariableNames:''
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    16
	poolDictionaries:''
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    17
	category:'System-Debugging-Support'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
89
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    20
!MiniInspector class methodsFor:'documentation'!
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    21
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    22
copyright
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    23
"
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    24
 COPYRIGHT (c) 1989 by Claus Gittinger
308
f04744ef7b5d *** empty log message ***
claus
parents: 93
diff changeset
    25
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    26
89
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    27
 This software is furnished under a license and may be used
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    28
 only in accordance with the terms of that license and with the
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    30
 be provided or otherwise made available to, or used by, any
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    31
 other person.  No title to or ownership of the software is
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    32
 hereby transferred.
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    33
"
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    34
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    35
89
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    36
documentation
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    37
"
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    38
    a primitive (non graphical) inspector for use on systems without
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    39
    graphics or when the real inspector dies.
1297
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    40
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    41
    [author:]
073d4d41ba0f documentation
Claus Gittinger <cg@exept.de>
parents: 903
diff changeset
    42
        Claus Gittinger
89
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    43
"
7be0b86ef80f *** empty log message ***
claus
parents: 74
diff changeset
    44
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    45
a27a279701f8 Initial revision
claus
parents:
diff changeset
    46
!MiniInspector class methodsFor:'instance creation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    47
a27a279701f8 Initial revision
claus
parents:
diff changeset
    48
openOn:anObject
a27a279701f8 Initial revision
claus
parents:
diff changeset
    49
    |anInspector|
a27a279701f8 Initial revision
claus
parents:
diff changeset
    50
    anInspector := (self new) initializeFor:anObject.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    51
    anInspector enter
a27a279701f8 Initial revision
claus
parents:
diff changeset
    52
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
    53
a27a279701f8 Initial revision
claus
parents:
diff changeset
    54
!MiniInspector methodsFor:'private'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    55
a27a279701f8 Initial revision
claus
parents:
diff changeset
    56
commandLoop
a27a279701f8 Initial revision
claus
parents:
diff changeset
    57
    |cmd done valid|
a27a279701f8 Initial revision
claus
parents:
diff changeset
    58
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    59
    'Inspector:' printCR.
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    60
    ' ' printCR.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    61
    done := false.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    62
    [done] whileFalse:[
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    63
        valid := false.
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    64
        cmd := self getCommand.
2775
acdd73312418 handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
    65
        cmd isNil ifTrue:[   "/ EOF -> quit
acdd73312418 handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
    66
            cmd := $q
acdd73312418 handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
    67
        ].
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    68
        (cmd >= $0 and:[cmd <= $9]) ifTrue:[
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    69
            valid := true.
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    70
            self inspectInstvar:(cmd asciiValue - $0 asciiValue) of:inspectedObject
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    71
        ].
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    72
        (cmd == $i) ifTrue:[
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    73
            valid := true.
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    74
            self printInstVarsOf:inspectedObject
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    75
        ].
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    76
        (cmd == $p) ifTrue:[
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    77
            valid := true.
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    78
            inspectedObject printCR
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    79
        ].
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    80
        (cmd == $q) ifTrue:[valid := true. done := true ].
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    81
        valid ifFalse: [
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    82
            'valid commands:
74
5fb970c7cb96 *** empty log message ***
claus
parents: 5
diff changeset
    83
   (i)nstvars
5fb970c7cb96 *** empty log message ***
claus
parents: 5
diff changeset
    84
   (p)rint
903
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
    85
   (0-9) inspect instvar
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    86
   (q)uit'       errorPrintCR
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    87
        ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    88
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
    89
    ^ cmd
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
    90
2775
acdd73312418 handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
    91
    "Modified: 24.7.1997 / 10:00:24 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    92
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    93
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    94
enter
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    95
    self commandLoop.
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    96
    ^ nil
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    97
!
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    98
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    99
getCommand
a27a279701f8 Initial revision
claus
parents:
diff changeset
   100
    |cmd c|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   101
    'inspector> ' print.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   102
    cmd := Character fromUser.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   103
    c := cmd.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   104
    [ c isEndOfLineCharacter ] whileFalse: [
308
f04744ef7b5d *** empty log message ***
claus
parents: 93
diff changeset
   105
	c := Character fromUser
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   106
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   107
    ^ cmd
a27a279701f8 Initial revision
claus
parents:
diff changeset
   108
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   109
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   110
initializeFor:anObject
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   111
    inspectedObject := anObject.
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   112
    ^self
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   113
!
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   114
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   115
inspectInstvar:which of:anObject
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   116
    which > (anObject class instSize) ifTrue:[
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   117
        which > (anObject basicSize) ifTrue:[
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   118
            'invalid instvar' printCR
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   119
        ] ifFalse:[
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   120
            (anObject basicAt:which) inspect
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   121
        ]
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   122
    ] ifFalse: [
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   123
        (anObject instVarAt:which) inspect
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   124
    ]
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   125
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   126
    "Modified: 20.5.1996 / 10:27:40 / cg"
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   127
!
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   128
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   129
printInstVarsOf:anObject
903
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   130
    |n "{ Class: SmallInteger }" |
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   131
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   132
    n := anObject class instSize.
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   133
    'number of instvars: ' print. n printCR.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   134
    1 to:n do:[:i |
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   135
        '  ' print. i print. ': ' print.
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   136
        (anObject instVarAt:i) printCR
903
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   137
    ].
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   138
    n := anObject basicSize.
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   139
    'number of indexed instvars: ' print. n printCR.
903
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   140
    n > 10 ifTrue:[n := 10].
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   141
    1 to:n do:[:i |
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   142
        ' [' print. i print. ']: ' print.
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   143
        (anObject basicAt:i) printCR
903
234a9d6e4492 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   144
    ].
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   145
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1297
diff changeset
   146
    "Modified: 20.5.1996 / 10:27:45 / cg"
618
9048d43527d2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   147
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   148
658
cf969399434d version at the end
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
   149
!MiniInspector class methodsFor:'documentation'!
cf969399434d version at the end
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
   150
cf969399434d version at the end
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
   151
version
2775
acdd73312418 handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   152
    ^ '$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.19 1997-07-24 11:38:43 cg Exp $'
658
cf969399434d version at the end
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
   153
! !