Fix for multi-location breakpoints created initially as pending
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 07 Feb 2019 15:18:41 +0000
changeset 175 a04e1a36e888
parent 174 18ef81a3fee5
child 176 e734c17e7c37
Fix for multi-location breakpoints created initially as pending If the breakpoint has been created as pending breakpoint it is unknown whether it is a multi-location breakpoint or not so it has no locations. If, once the object is loaded abd breakpoint can be installed, it turns out there are multiple locations, we get an an =breakpoint-modified event listing all locations. Therefore, we have to update existing breakpoint and add locations.
GDBDebugger.st
GDBDebuggerObject.st
--- a/GDBDebugger.st	Mon Jan 28 22:47:57 2019 +0000
+++ b/GDBDebugger.st	Thu Feb 07 15:18:41 2019 +0000
@@ -79,16 +79,22 @@
 !
 
 breakpointForId: id
+    ^ self breakpointForId: id ifAbsent:[self error: ('No breakpoint with id ''%1'' found!!' bindWith: id)]
+
+    "Created: / 18-05-2018 / 13:39:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-02-2019 / 15:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+breakpointForId: id ifAbsent: block
     self breakpoints do:[:bp |
         bp number = id ifTrue:[ ^ bp ].
         bp locations do: [ :loc |
             loc number = id ifTrue:[ ^ loc ].
         ].
     ].
-    self error: ('No breakpoint with id ''%1'' found!!' bindWith: id)
+    ^ block value.
 
-    "Created: / 18-05-2018 / 13:39:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 18-05-2018 / 15:03:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 07-02-2019 / 15:04:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 breakpoints
@@ -801,13 +807,44 @@
     aGDBBreakpointModifiedEvent breakpoints do:[:new | 
         | old |    
 
-        old := self breakpointForId: new number.
-        old updateFrom: new.
+        old := self breakpointForId: new number ifAbsent:[ nil ].
+        old notNil ifTrue:[
+            old updateFrom: new.
+        ] ifFalse:[ 
+            "/ Care for breakpoints with multiple locations. 
+            "/ 
+            "/.If the breakpoint has been created as pending breakpoint
+            "/ it is unknown whether it is a multi-location breakpoint or not
+            "/ so it has no locations.
+            "/ 
+            "/ If, once the object is loaded abd breakpoint can be installed,
+            "/ it turns out there are multiple locations, we get an an
+            "/ =breakpoint-modified event listing all locations.
+            "/ 
+            "/ Therefore, we have to update existing breakpoint and add 
+            "/ locations.
+
+            | dot |
+
+            "/ First, check if it is a 'location':
+            dot := new number indexOf: $..
+            dot ~~ 0 ifTrue:[ 
+                | bpt |    
+
+                bpt := self breakpointForId: (new number copyTo: dot - 1).
+                "/ See GDBBreakpoint >> locations...
+                (bpt locations includes: bpt) ifTrue:[ 
+                    bpt locations: (Array with: new)
+                ] ifFalse:[ 
+                    bpt locations: (bpt locations copyWith: new)
+                ].
+            ].
+        ].
     ].
 
     "Created: / 06-07-2017 / 16:28:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 15-01-2018 / 23:11:52 / jv"
-    "Modified: / 18-05-2018 / 14:58:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-02-2019 / 15:14:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 onCmdParamChangedEvent: aGDBCmdParamChangedEvent
--- a/GDBDebuggerObject.st	Mon Jan 28 22:47:57 2019 +0000
+++ b/GDBDebuggerObject.st	Thu Feb 07 15:18:41 2019 +0000
@@ -65,11 +65,11 @@
 !GDBDebuggerObject methodsFor:'initialization & release'!
 
 setDebugger: aGDBDebugger
-    self assert: (debugger isNil or:[ aGDBDebugger isNil ]).
+    self assert: (debugger isNil or:[ aGDBDebugger isNil or:[debugger == aGDBDebugger]]).
     debugger := aGDBDebugger
 
     "Created: / 07-09-2014 / 21:17:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 10-07-2017 / 12:57:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-02-2019 / 15:15:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBDebuggerObject methodsFor:'private'!