UI: add support for multi-location breakpoints
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 26 Mar 2019 11:25:48 +0000
changeset 153 063fd7d1d5be
parent 150 2bd269c89e8c
child 155 85d7d83f4280
UI: add support for multi-location breakpoints ...namely: * better textual description of multi-location breakpoints * make a breakpoint list actually a tree with individual locations as child of the breakpoint
VDBBreakpointListApplication.st
VDBBreakpointPresenter.st
--- a/VDBBreakpointListApplication.st	Wed Mar 13 14:18:16 2019 +0000
+++ b/VDBBreakpointListApplication.st	Tue Mar 26 11:25:48 2019 +0000
@@ -10,7 +10,7 @@
 
 "{ NameSpace: Smalltalk }"
 
-VDBAbstractListApplication subclass:#VDBBreakpointListApplication
+VDBAbstractTreeApplication subclass:#VDBBreakpointListApplication
 	instanceVariableNames:'selectedBreakpointHolder'
 	classVariableNames:''
 	poolDictionaries:''
@@ -59,10 +59,12 @@
     ^ 
     #(FullSpec
        name: windowSpec
+       uuid: '8774fbe0-4fb0-11e9-b432-606720e43e2c'
        window: 
       (WindowSpec
          label: 'VDBAbstractListApplication'
          name: 'VDBAbstractListApplication'
+         uuid: '475530e1-4fae-11e9-b432-606720e43e2c'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 300 577)
        )
@@ -72,14 +74,16 @@
           (VariableVerticalPanelSpec
              name: 'VariableVerticalPanel1'
              layout: (LayoutFrame 0 0 0 0 0 1 0 1)
+             uuid: '475530e2-4fae-11e9-b432-606720e43e2c'
              showHandle: true
              snapMode: both
              handlePosition: left
              component: 
             (SpecCollection
                collection: (
-                (SelectionInListModelViewSpec
-                   name: 'SelectionInListModelView1'
+                (HierarchicalListViewSpec
+                   name: 'Breakpoints'
+                   uuid: '475530e3-4fae-11e9-b432-606720e43e2c'
                    model: internalSelectionHolder
                    menu: contextMenu
                    hasHorizontalScrollBar: true
@@ -88,10 +92,14 @@
                    useIndex: false
                    highlightMode: line
                    doubleClickSelector: doDoubleClick
+                   showLines: false
+                   useDefaultIcons: false
+                   showRoot: false
                    postBuildCallback: postBuildInternalListView:
                  )
                 (SubCanvasSpec
                    name: 'BreakpointCanvas'
+                   uuid: '475557f0-4fae-11e9-b432-606720e43e2c'
                    hasHorizontalScrollBar: false
                    hasVerticalScrollBar: false
                    majorKey: VDBBreakpointApplication
@@ -119,8 +127,6 @@
         
        )
      )
-
-    "Modified (format): / 14-07-2017 / 10:28:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !VDBBreakpointListApplication class methodsFor:'plugIn spec'!
@@ -176,13 +182,19 @@
 !VDBBreakpointListApplication methodsFor:'change & update-delayed'!
 
 delayedUpdateInternalList
-    | oldBreakpointPs newBreakpointPs |
+    | root list |
 
-    oldBreakpointPs := self internalListHolder value.
-    newBreakpointPs := debugger breakpoints collect:[ :e| VDBBreakpointPresenter new setBreakpoint: e ].
-    self internalListHolder value: newBreakpointPs.
+    debugger isNil ifTrue:[
+        self internalListHolder root children:#().
+        ^ self.
+    ].  
+    root := self internalListHolder root.
+    list := debugger breakpoints collect:[:b | VDBBreakpointPresenter new setBreakpoint: b; parent: root ].
+    root children:list.
+    root expand.
+    self delayedInvalidateInternalList
 
-    "Modified: / 10-07-2017 / 13:37:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 26-03-2019 / 10:17:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 delayedUpdateSelection
--- a/VDBBreakpointPresenter.st	Wed Mar 13 14:18:16 2019 +0000
+++ b/VDBBreakpointPresenter.st	Tue Mar 26 11:25:48 2019 +0000
@@ -87,37 +87,57 @@
             location := breakpoint propertyAt: 'what'.
             aStream nextPutAll: location ? '??'.
         ] ifFalse:[
+            | func |
             aStream nextPutAll: 'B '.
             breakpoint number printOn:aStream.
             aStream nextPutAll:', '.
+
+            func := breakpoint func.
+            func isNil and:[  
+                func := breakpoint propertyAt:'original-location'
+            ].
     
-            breakpoint func notNil ifTrue:[ 
+            func notNil ifTrue:[ 
                 aStream nextPutAll:'in '.
-                breakpoint func printOn:aStream.   
-                aStream nextPutAll:'(), '. 
+                func printOn:aStream.   
+                "/ I (JV) prefer to have () after plain C function names. GDB seems to
+                "/ to add them for C functions but does add them for C++ functions / methods
+                "/ (well. perhaps this is compile who does that, does not matter).
+                "/ 
+                "/ So, if there's no $(, assume it's a C function and add () at the end.
+                "/ We'll see how this works...
+                (func includes: $() ifFalse:[
+                    aStream nextPutAll:'()'. 
+                ].
+                aStream nextPutAll:', '
             ].
-            breakpoint file notNil ifTrue:[
-                breakpoint file printOn:aStream.
-                aStream nextPut:$:.
-                breakpoint line printOn:aStream.
-            ] ifFalse:[ 
-                | addr |
+            breakpoint hasMultipleLocations ifTrue:[ 
+                breakpoint locations size printOn: aStream.
+                aStream nextPutAll: ' locations'.
+            ] ifFalse:[
+                breakpoint file notNil ifTrue:[
+                    breakpoint file printOn:aStream.
+                    aStream nextPut:$:.
+                    breakpoint line printOn:aStream.
+                ] ifFalse:[ 
+                    | addr |
 
-                addr := breakpoint addr.
-                addr isNil ifTrue:[ 
-                    aStream nextPutAll:'at ??'.
-                ] ifFalse:[addr isInteger ifTrue:[
-                    aStream nextPutAll:'at 0x'.
-                    addr printOn: aStream radix: 16
-                ] ifFalse:[ 
-                    addr printOn: aStream
-                ]].
-            ].                                                  
+                    addr := breakpoint addr.
+                    addr isNil ifTrue:[ 
+                        aStream nextPutAll:'at ??'.
+                    ] ifFalse:[addr isInteger ifTrue:[
+                        aStream nextPutAll:'at 0x'.
+                        addr printOn: aStream radix: 16
+                    ] ifFalse:[ 
+                        addr printOn: aStream
+                    ]].
+                ].      
+            ].
         ]
     ].
 
     "Created: / 10-07-2017 / 13:30:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 21-01-2019 / 21:13:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 26-03-2019 / 10:58:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 subject
@@ -164,6 +184,18 @@
     "Created: / 05-02-2018 / 12:26:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!VDBBreakpointPresenter methodsFor:'private'!
+
+fetchChildren
+    breakpoint hasMultipleLocations ifTrue:[
+        ^ breakpoint locations collect:[ :l | VDBBreakpointPresenter new setBreakpoint: l; parent: self ]
+    ] ifFalse:[ 
+        ^ #()
+    ].
+
+    "Created: / 26-03-2019 / 10:10:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !VDBBreakpointPresenter methodsFor:'testing'!
 
 isBreakpointPresenter