MiniDebugger.st
changeset 15195 e92dd9929b4f
parent 15122 7fc1cae5a632
child 15691 80911ed523c0
child 18059 b882507b9fdf
--- a/MiniDebugger.st	Mon Apr 29 07:46:49 2013 +0000
+++ b/MiniDebugger.st	Tue Apr 30 14:51:20 2013 +0200
@@ -285,6 +285,8 @@
         ].
         (leaveCmd == $c) ifTrue: [
             traceBlock := nil.
+            ObjectMemory flushInlineCaches.
+            ObjectMemory stepInterruptHandler:nil.
             stillHere := false.
             stepping := false.
             tracing := false.
@@ -293,6 +295,8 @@
         ].
         (leaveCmd == $a) ifTrue: [
             "abort"
+            ObjectMemory flushInlineCaches.
+            ObjectMemory stepInterruptHandler:nil.
             stepping := false.
             tracing := false.
             StepInterruptPending := nil.
@@ -748,6 +752,11 @@
     (cmd == $L) ifTrue:[self printDotsMethodSource:true. ^ false ].
     (cmd == $-) ifTrue:[self moveDotUp. self printDot. ^ false ].
     (cmd == $+) ifTrue:[self moveDotDown. self printDot. ^ false ].
+    (cmd == $?) ifTrue:[
+        commandArg notEmpty ifTrue:[
+            self helpOn:commandArg. ^ false 
+        ]
+    ].
 
     "/ avoid usage print if return was typed ...
     ((cmd == Character return)
@@ -824,6 +833,57 @@
     "Modified: / 31.7.1998 / 16:11:01 / cg"
 !
 
+helpOn:commandArg
+    |args className sym val match showMethod|
+
+    commandArg withoutSeparators isEmpty ifTrue:[
+        'usage: H className [methodPattern]' printCR.
+        ^self
+    ].
+    args := commandArg asCollectionOfWords.
+    className := args first.
+    
+    (sym := className asSymbolIfInterned) isNil ifTrue:[
+        'no such class' printCR.
+        ^ self.
+    ].
+    val := Smalltalk at:sym ifAbsent:['no such class' printCR. ^ self.].
+    val isBehavior ifFalse:[
+        'not a class: ' print. className printCR.
+        val := val class.
+        'showing help for ' print. val name printCR.
+    ].
+    args size > 1 ifTrue:[
+        match := args at:2
+    ] ifFalse:[
+        match := '*'
+    ].
+
+    showMethod := 
+        [:sel :cls | 
+            |mthd|
+
+            ((match includesMatchCharacters and:[ sel matches:match ignoreCase:true])
+            or:[ sel asLowercase startsWith:match asLowercase ]) ifTrue:[
+                mthd := cls compiledMethodAt:sel.
+                mthd category ~= 'documentation' ifTrue:[
+                    sel printCR.
+                    (mthd comment ? '') asStringCollection do:[:l |
+                        '    ' print. l withoutSeparators printCR.
+                    ].
+                    '' printCR
+                ].
+            ].
+        ].
+
+    val theMetaclass selectors copy sort do:[:sel |
+        showMethod value:sel value:val theMetaclass
+    ].
+    val theNonMetaclass selectors copy sort do:[:sel |
+        showMethod value:sel value:val theNonMetaclass
+    ].
+!
+
 interpreterLoopWith:anObject
     'read-eval-print loop; exit with "#exit"; help with "?"' printCR.
     (ReadEvalPrintLoop new doChunkFormat:false; error:Stderr; prompt:'> ')readEvalPrintLoop.
@@ -938,6 +998,7 @@
    i ...... inspect receiver (in dot)
    I ...... interpreter (expression evaluator)
    e expr   evaluate expression
+   ? c [p]  help on class c (selectors matching p)
 '  errorPrintCR.
 
    (XWorkstation notNil and:[ Screen default isKindOf:XWorkstation ]) ifTrue:[
@@ -955,10 +1016,10 @@
 !MiniDebugger class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.84 2013-04-19 09:40:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.85 2013-04-30 12:51:20 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.84 2013-04-19 09:40:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.85 2013-04-30 12:51:20 cg Exp $'
 ! !