MessageTracer.st
branchjv
changeset 3239 76ca693c6a30
parent 3208 e8bdf898d7ac
child 3240 7d753640035b
--- a/MessageTracer.st	Wed Apr 17 10:19:24 2013 +0200
+++ b/MessageTracer.st	Wed Apr 24 19:37:49 2013 +0100
@@ -245,7 +245,6 @@
 "
 ! !
 
-
 !MessageTracer class methodsFor:'Signal constants'!
 
 breakpointSignal
@@ -258,7 +257,6 @@
     "Created: / 21.4.1998 / 14:38:49 / cg"
 ! !
 
-
 !MessageTracer class methodsFor:'class initialization'!
 
 initialize
@@ -304,7 +302,6 @@
     "Created: / 30.7.1998 / 17:00:09 / cg"
 ! !
 
-
 !MessageTracer class methodsFor:'class tracing'!
 
 untraceAllClasses
@@ -325,7 +322,6 @@
     ^ self untrapClass:aClass
 ! !
 
-
 !MessageTracer class methodsFor:'class wrapping'!
 
 wrapClass:orgClass selector:aSelector onEntry:entryBlock onExit:exitBlock 
@@ -490,7 +486,6 @@
     "Modified: / 01-07-2011 / 10:01:59 / cg"
 ! !
 
-
 !MessageTracer class methodsFor:'cleanup'!
 
 cleanup
@@ -508,7 +503,6 @@
     "
 ! !
 
-
 !MessageTracer class methodsFor:'execution trace'!
 
 debugTrace:aBlock
@@ -625,7 +619,6 @@
     "
 ! !
 
-
 !MessageTracer class methodsFor:'method breakpointing'!
 
 trapClass:aClass selector:aSelector
@@ -861,6 +854,42 @@
     ^ self unwrapMethod:aMethod
 ! !
 
+!MessageTracer class methodsFor:'method breakpointing - new'!
+
+breakMethod: method atLine: line 
+    "Installs new breakpoint in given method at given line.
+     Returns the installed breakpoint or nil if none could be
+     installed"
+
+    | analyzer map lines i breakpoint table |
+
+    (ConfigurableFeatures includesFeature: #VMBreakpointSupport) ifFalse:[
+        self error: 'Breakpoint support not present'.
+        ^nil.
+    ].
+
+    analyzer := BreakpointAnalyzer parseMethodSilent: method source in: method mclass.
+    map := analyzer messageSendMap.
+    lines := map keys asSortedCollection.
+    i := lines indexForInserting: line.
+    i > lines size ifTrue:[
+        ^nil
+    ].
+    breakpoint := Breakpoint new line: (lines at: i).
+    breakpoint breaksToIgnore: (((map at: breakpoint line) size - 1) max: 0).
+
+    table := method breakpointTable.
+    table isNil ifTrue:[
+        table := Array with: (breakpoint line) with: breakpoint.
+    ] ifFalse:[
+        table := table, (Array with: (breakpoint line) with: breakpoint).
+    ].
+    method breakpointTable: table.
+
+    ^breakpoint
+
+    "Created: / 16-04-2013 / 00:25:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
 
 !MessageTracer class methodsFor:'method counting'!
 
@@ -937,7 +966,6 @@
     "Modified: 15.12.1995 / 15:43:53 / cg"
 ! !
 
-
 !MessageTracer class methodsFor:'method memory usage'!
 
 countMemoryUsageOfMethod:aMethod
@@ -1072,7 +1100,6 @@
     "Modified: 18.12.1995 / 21:54:36 / stefan"
 ! !
 
-
 !MessageTracer class methodsFor:'method timing'!
 
 executionTimesOfMethod:aMethod
@@ -1170,7 +1197,6 @@
     "Modified: / 05-03-2007 / 15:34:01 / cg"
 ! !
 
-
 !MessageTracer class methodsFor:'method tracing'!
 
 traceClass:aClass selector:aSelector
@@ -1527,7 +1553,6 @@
     ^ self unwrapMethod:aMethod
 ! !
 
-
 !MessageTracer class methodsFor:'method wrapping'!
 
 unwrapAllMethods
@@ -1822,7 +1847,6 @@
     "Modified: / 01-07-2011 / 10:01:48 / cg"
 ! !
 
-
 !MessageTracer class methodsFor:'object breakpointing'!
 
 objectHasWraps:anObject
@@ -1976,7 +2000,6 @@
     ^ anObject class selectors
 ! !
 
-
 !MessageTracer class methodsFor:'object modification traps'!
 
 trapModificationsIn:anObject
@@ -2172,7 +2195,6 @@
     "
 ! !
 
-
 !MessageTracer class methodsFor:'object tracing'!
 
 trace:anObject selector:aSelector
@@ -2528,7 +2550,6 @@
     ^ self untrap:anObject selector:aSelector
 ! !
 
-
 !MessageTracer class methodsFor:'object wrapping'!
 
 wrap:anObject selector:aSelector onEntry:entryBlock onExit:exitBlock
@@ -2793,7 +2814,6 @@
     "Modified: 5.6.1996 / 14:50:07 / stefan"
 ! !
 
-
 !MessageTracer class methodsFor:'queries'!
 
 allWrappedMethods
@@ -2853,7 +2873,6 @@
     "Modified: 22.10.1996 / 17:40:37 / cg"
 ! !
 
-
 !MessageTracer class methodsFor:'trace helpers'!
 
 dummyEmptyMethod
@@ -3050,39 +3069,37 @@
 !
 
 printUpdateEntryFull:aContext level:lvl on:aStream
-    |con sndr|
+    |con|
 
     con := aContext.
 
-"/    [
-"/        con notNil and:[con selector ~~ #'changed:with:']
-"/    ] whileTrue:[
-"/        con := con sender.
-"/    ].
-    con := con findNextContextWithSelector:#'changed:with:' or:nil or:nil.
-
+    [con notNil
+     and:[con selector ~~ #'changed:with:'] 
+    ] whileTrue:[
+        con := con sender.
+    ].
+    "/ con is #'changed:with:'
     con isNil ifTrue:[
-	^ self printEntryFull:aContext level:lvl on:aStream.
+        ^ self printEntryFull:aContext level:lvl on:aStream.
     ].
 
-    "/ con is #'changed:with:'
-    ((sndr := con sender) notNil
-    and:[ sndr selector == #'changed:']) ifTrue:[
-	con := sndr.
+    (con sender notNil
+    and:[ con sender selector == #'changed:']) ifTrue:[
+        con := con sender.
     ].
-    ((sndr := con sender) notNil
-    and:[ sndr selector == #'changed']) ifTrue:[
-	con := sndr.
+    (con sender notNil
+    and:[ con sender selector == #'changed']) ifTrue:[
+        con := con sender.
     ].
-    ((sndr := con sender) notNil) ifTrue:[
-	con := sndr.
+    (con sender notNil) ifTrue:[
+        con := con sender.
     ].
 
     aStream spaces:lvl; nextPutAll:'enter '.
     self
-	printFull:aContext
-	on:aStream
-	withSenderContext:con
+        printFull:aContext 
+        on:aStream 
+        withSenderContext:con
 !
 
 traceEntryFull:aContext on:aStream
@@ -3123,7 +3140,6 @@
 
 ! !
 
-
 !MessageTracer methodsFor:'trace helpers'!
 
 trace:aBlock detail:fullDetail
@@ -3155,7 +3171,6 @@
     "
 ! !
 
-
 !MessageTracer::InteractionCollector methodsFor:'trace helpers'!
 
 stepInterrupt
@@ -3165,7 +3180,6 @@
     InterruptPending := 1.
 ! !
 
-
 !MessageTracer::MethodTimingInfo methodsFor:'accessing'!
 
 avgTime
@@ -3230,7 +3244,6 @@
     ^ sumTimes
 ! !
 
-
 !MessageTracer::MethodTimingInfo methodsFor:'initialization'!
 
 rememberExecutionTime:t
@@ -3252,14 +3265,12 @@
     "Created: / 05-03-2007 / 15:32:43 / cg"
 ! !
 
-
 !MessageTracer::PrintingMessageTracer methodsFor:'accessing'!
 
 output:something
     output := something.
 ! !
 
-
 !MessageTracer::PrintingMessageTracer methodsFor:'trace helpers'!
 
 stepInterrupt
@@ -3338,7 +3349,6 @@
     "
 ! !
 
-
 !MessageTracer class methodsFor:'documentation'!
 
 version_CVS