plugins/bee: add support for setting a breakpoint
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 11 Jun 2019 11:40:12 +0100
changeset 167 16cd2d937309
parent 166 d55f55ac977b
child 168 6a4863394260
plugins/bee: add support for setting a breakpoint
plugins/bee/BeeSymbol.st
plugins/bee/BeeSymbolListApplication.st
plugins/bee/BeeSymbolPresenter.st
--- a/plugins/bee/BeeSymbol.st	Mon Jun 10 15:22:49 2019 +0100
+++ b/plugins/bee/BeeSymbol.st	Tue Jun 11 11:40:12 2019 +0100
@@ -31,6 +31,14 @@
     addr := something.
 !
 
+breakpoints
+    "Return a list of breakpoints on this symbol"
+
+    ^ debugger breakpoints select:[:each | each addr between: addr and: addr + size ] as: OrderedCollection
+
+    "Created: / 10-06-2019 / 15:40:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 disassemble
     | result disassembly arch |
 
--- a/plugins/bee/BeeSymbolListApplication.st	Mon Jun 10 15:22:49 2019 +0100
+++ b/plugins/bee/BeeSymbolListApplication.st	Tue Jun 11 11:40:12 2019 +0100
@@ -272,6 +272,12 @@
 
 !BeeSymbolListApplication methodsFor:'event handling'!
 
+onBreakpointEvent: aGDBBreakpointModifiedEvent
+    self enqueueDelayedInvalidateInternalList
+
+    "Created: / 10-06-2019 / 15:49:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 onStoppedEvent: aGDBStoppedEvent
 
     aGDBStoppedEvent reason ~= EndSteppingRange ifTrue:[ 
@@ -295,10 +301,12 @@
     super subscribe.
     debugger notNil ifTrue:[ 
         debugger announcer 
-            when: GDBStoppedEvent       send: #onStoppedEvent:  to: self.
+            when: GDBStoppedEvent       send: #onStoppedEvent:      to: self;
+            when: GDBBreakpointEvent    send: #onBreakpointEvent:   to: self
     ]
 
     "Created: / 10-06-2019 / 14:12:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-06-2019 / 15:49:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !BeeSymbolListApplication class methodsFor:'documentation'!
--- a/plugins/bee/BeeSymbolPresenter.st	Mon Jun 10 15:22:49 2019 +0100
+++ b/plugins/bee/BeeSymbolPresenter.st	Tue Jun 11 11:40:12 2019 +0100
@@ -9,6 +9,7 @@
 	category:'VDB-Plugin-Bee-Presentation'
 !
 
+
 !BeeSymbolPresenter class methodsFor:'menu specs'!
 
 contextMenu
@@ -30,6 +31,29 @@
      #(Menu
         (
          (MenuItem
+            label: 'Add Breakpoint'
+            itemValue: doBreakpointAdd
+            isVisible: canBreakpointAdd
+          )
+         (MenuItem
+            label: 'Disable Breakpoint'
+            itemValue: doBreakpointDisable
+            isVisible: canBreakpointDisable
+          )
+         (MenuItem
+            label: 'Enable Breakpoint'
+            itemValue: doBreakpointEnable
+            isVisible: canBreakpointEnable
+          )
+         (MenuItem
+            label: 'Remove Breakpoint'
+            itemValue: doBreakpointRemove
+            isVisible: canBreakpointRemove
+          )
+         (MenuItem
+            label: '-'
+          )
+         (MenuItem
             label: 'Disassemble'
             itemValue: doDisassemble
             isVisible: true
@@ -44,13 +68,28 @@
 
 label
     ^ String streamContents: [ :s |
+        | bkpts |
+
+        s nextPutAll: '0x'.
         symbol addr printOn:s base: 16 size: (8 * 2) fill: $0.
+
+        bkpts := symbol breakpoints.
+        bkpts notEmptyOrNil ifTrue:[ 
+            (bkpts anySatisfy:[:e|e enabled]) ifTrue:[ 
+                s nextPutAll:' B'
+            ] ifFalse:[ 
+                s nextPutAll:' d'
+            ].
+        ] ifFalse:[ 
+            s nextPutAll: '  '
+        ].
+
         s space.
         s nextPutAll: symbol name
     ].
 
     "Created: / 07-06-2019 / 14:39:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 07-06-2019 / 16:20:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-06-2019 / 12:39:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 subject
@@ -77,6 +116,45 @@
 
 !BeeSymbolPresenter methodsFor:'menu actions'!
 
+doBreakpointAdd
+    <resource: #uiCallback>
+
+    symbol debugger send: (GDBMI_break_insert arguments: (Array with: '*0x', (symbol addr printStringRadix: 16)))
+
+    "Modified: / 10-06-2019 / 16:07:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doBreakpointDisable
+    <resource: #uiCallback>
+
+    symbol breakpoints do:[:e | e enabled: false ]
+
+    "Modified: / 10-06-2019 / 16:05:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doBreakpointEnable
+    <resource: #uiCallback>
+
+    symbol breakpoints do:[:e | e enabled: true ].
+
+    "Modified (format): / 10-06-2019 / 16:06:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doBreakpointRemove
+    <resource: #uiCallback>
+
+    "automatically generated by UIEditor ..."
+
+    "*** the code below performs no action"
+    "*** (except for some feedback on the Transcript)"
+    "*** Please change as required and accept in the browser."
+    "*** (and replace this comment by something more useful ;-)"
+
+    "action to be added ..."
+
+    Logger info:'action for #doBreakpointRemove ...'.
+!
+
 doDisassemble
     | application |
 
@@ -96,3 +174,50 @@
     "Created: / 10-06-2019 / 10:46:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!BeeSymbolPresenter methodsFor:'menu queries'!
+
+canBreakpointAdd
+    <resource: #uiCallback>
+
+    ^ symbol breakpoints isEmpty
+
+    "Modified: / 10-06-2019 / 15:59:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+canBreakpointDisable
+    <resource: #uiCallback>
+
+    | breakpoints |
+
+    breakpoints := symbol breakpoints.
+    ^ breakpoints notEmpty and:[ breakpoints anySatisfy:[:e|e enabled]]
+
+    "Modified: / 10-06-2019 / 16:01:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+canBreakpointEnable
+    <resource: #uiCallback>
+
+    | breakpoints |
+
+    breakpoints := symbol breakpoints.
+    ^ breakpoints notEmpty and:[ breakpoints anySatisfy:[:e|e enabled not]]
+
+    "Modified: / 10-06-2019 / 16:01:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+canBreakpointRemove
+    <resource: #uiCallback>
+
+    ^ symbol breakpoints notEmpty
+
+    "Modified: / 10-06-2019 / 15:59:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BeeSymbolPresenter class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+