plugins/bee: add menu item to disassemble given symbol
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 10 Jun 2019 14:59:26 +0100
changeset 165 1e2a4cb4afdd
parent 164 364ebdd1d42c
child 166 d55f55ac977b
plugins/bee: add menu item to disassemble given symbol Also, symbol list is auto-updated each time inferior stops. This may take time and has to be oprimized (later)
plugins/bee/BeeSymbol.st
plugins/bee/BeeSymbolListApplication.st
plugins/bee/BeeSymbolPresenter.st
plugins/bee/Make.proto
plugins/bee/bc.mak
--- a/plugins/bee/BeeSymbol.st	Mon Jun 10 14:36:46 2019 +0100
+++ b/plugins/bee/BeeSymbol.st	Mon Jun 10 14:59:26 2019 +0100
@@ -2,7 +2,7 @@
 
 "{ NameSpace: Smalltalk }"
 
-GDBObject subclass:#BeeSymbol
+GDBDebuggerObject subclass:#BeeSymbol
 	instanceVariableNames:'name addr size'
 	classVariableNames:''
 	poolDictionaries:''
@@ -31,6 +31,20 @@
     addr := something.
 !
 
+disassemble
+    | result disassembly arch |
+
+    result := debugger send: (GDBMI_data_disassemble arguments: (Array with: '-s' with: addr with: '-e' with: addr + size with: '--' with: 5)).
+
+    disassembly := result propertyAt: 'asm_insns'.
+    arch := GDBArchitecture named: 'i386:x86-64'.    
+    disassembly do:[:each | each setDebugger: debugger; setArchitecture: arch ].
+    ^ disassembly
+
+    "Created: / 10-06-2019 / 10:30:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-06-2019 / 11:34:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 name
     ^ name
 !
--- a/plugins/bee/BeeSymbolListApplication.st	Mon Jun 10 14:36:46 2019 +0100
+++ b/plugins/bee/BeeSymbolListApplication.st	Mon Jun 10 14:59:26 2019 +0100
@@ -5,7 +5,7 @@
 VDBAbstractListApplication subclass:#BeeSymbolListApplication
 	instanceVariableNames:'symbolListHolder selectedSymbolHolder'
 	classVariableNames:''
-	poolDictionaries:''
+	poolDictionaries:'GDBStopReasons'
 	category:'VDB-Plugin-Bee-UI'
 !
 
@@ -101,16 +101,17 @@
         debugger send: GDBMI_bee_list_symbols new andWithResultDo: [ :result |
             result isDone ifTrue:[
                 symbols := result propertyAt: #result.
+                symbols do:[:e | e setDebugger: debugger ].
                 symbols sort:[ :a :b | a name < b name ].
                 self symbolListHolder value: symbols.
-            ]
+            ].
         ]
     ] ifFalse:[ 
         self symbolListHolder value: nil.
     ].
 
     "Created: / 07-06-2019 / 14:59:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 07-06-2019 / 21:42:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-06-2019 / 10:31:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 delayedUpdateInternalList
@@ -132,6 +133,29 @@
     "Modified (format): / 07-06-2019 / 15:07:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!BeeSymbolListApplication methodsFor:'event handling'!
+
+onStoppedEvent: aGDBStoppedEvent
+
+    aGDBStoppedEvent reason ~= EndSteppingRange ifTrue:[ 
+        self enqueueDelayedUpdateContents
+    ].
+
+    "Created: / 10-06-2019 / 14:12:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BeeSymbolListApplication methodsFor:'initialization & release'!
+
+subscribe
+    super subscribe.
+    debugger notNil ifTrue:[ 
+        debugger announcer 
+            when: GDBStoppedEvent       send: #onStoppedEvent:  to: self.
+    ]
+
+    "Created: / 10-06-2019 / 14:12:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !BeeSymbolListApplication class methodsFor:'documentation'!
 
 version_HG
--- a/plugins/bee/BeeSymbolPresenter.st	Mon Jun 10 14:36:46 2019 +0100
+++ b/plugins/bee/BeeSymbolPresenter.st	Mon Jun 10 14:59:26 2019 +0100
@@ -9,6 +9,37 @@
 	category:'VDB-Plugin-Bee-Presentation'
 !
 
+!BeeSymbolPresenter class methodsFor:'menu specs'!
+
+contextMenu
+    "This resource specification was automatically generated
+     by the MenuEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the MenuEditor may not be able to read the specification."
+
+
+    "
+     MenuEditor new openOnClass:BeeSymbolPresenter andSelector:#contextMenu
+     (Menu new fromLiteralArrayEncoding:(BeeSymbolPresenter contextMenu)) startUp
+    "
+
+    <resource: #menu>
+
+    ^ 
+     #(Menu
+        (
+         (MenuItem
+            label: 'Disassemble'
+            itemValue: doDisassemble
+            isVisible: true
+          )
+         )
+        nil
+        nil
+      )
+! !
+
 !BeeSymbolPresenter methodsFor:'accessing'!
 
 label
@@ -44,3 +75,24 @@
     "Created: / 07-06-2019 / 14:54:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!BeeSymbolPresenter methodsFor:'menu actions'!
+
+doDisassemble
+    | application |
+
+    application := VDBInstructionListApplication new
+                    debugger: symbol debugger;  
+                    disassemblable: symbol;
+                    title: symbol name;
+                    yourself.
+    WindowGroup activeGroup application doOpenToolApplication: application.
+
+    "Modified: / 10-06-2019 / 11:36:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doDoubleClick
+    self doDisassemble
+
+    "Created: / 10-06-2019 / 10:46:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/plugins/bee/Make.proto	Mon Jun 10 14:36:46 2019 +0100
+++ b/plugins/bee/Make.proto	Mon Jun 10 14:59:26 2019 +0100
@@ -135,8 +135,8 @@
 
 
 # BEGINMAKEDEPEND --- do not remove this line; make depend needs it
-$(OUTDIR)BeeSymbol.$(O) BeeSymbol.$(C) BeeSymbol.$(H): BeeSymbol.st $(INCLUDE_TOP)/jv/libgdbs/GDBObject.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
-$(OUTDIR)BeeSymbolListApplication.$(O) BeeSymbolListApplication.$(C) BeeSymbolListApplication.$(H): BeeSymbolListApplication.st $(INCLUDE_TOP)/jv/vdb/VDBAbstractApplication.$(H) $(INCLUDE_TOP)/jv/vdb/VDBAbstractContentsApplication.$(H) $(INCLUDE_TOP)/jv/vdb/VDBAbstractListApplication.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libview2/ApplicationModel.$(H) $(INCLUDE_TOP)/stx/libview2/Model.$(H) $(STCHDR)
+$(OUTDIR)BeeSymbol.$(O) BeeSymbol.$(C) BeeSymbol.$(H): BeeSymbol.st $(INCLUDE_TOP)/jv/libgdbs/GDBDebuggerObject.$(H) $(INCLUDE_TOP)/jv/libgdbs/GDBObject.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)BeeSymbolListApplication.$(O) BeeSymbolListApplication.$(C) BeeSymbolListApplication.$(H): BeeSymbolListApplication.st $(INCLUDE_TOP)/jv/libgdbs/GDBStopReasons.$(H) $(INCLUDE_TOP)/jv/vdb/VDBAbstractApplication.$(H) $(INCLUDE_TOP)/jv/vdb/VDBAbstractContentsApplication.$(H) $(INCLUDE_TOP)/jv/vdb/VDBAbstractListApplication.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libview2/ApplicationModel.$(H) $(INCLUDE_TOP)/stx/libview2/Model.$(H) $(STCHDR)
 $(OUTDIR)BeeSymbolPresenter.$(O) BeeSymbolPresenter.$(C) BeeSymbolPresenter.$(H): BeeSymbolPresenter.st $(INCLUDE_TOP)/jv/vdb/VDBAbstractPresenter.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libwidg2/AbstractHierarchicalItem.$(H) $(INCLUDE_TOP)/stx/libwidg2/HierarchicalItem.$(H) $(STCHDR)
 $(OUTDIR)GDBMI_bee_list_symbols.$(O) GDBMI_bee_list_symbols.$(C) GDBMI_bee_list_symbols.$(H): GDBMI_bee_list_symbols.st $(INCLUDE_TOP)/jv/libgdbs/GDBCommand.$(H) $(INCLUDE_TOP)/jv/libgdbs/GDBMICommand.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)jv_vdb_plugins_bee.$(O) jv_vdb_plugins_bee.$(C) jv_vdb_plugins_bee.$(H): jv_vdb_plugins_bee.st $(INCLUDE_TOP)/stx/libbasic/LibraryDefinition.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/ProjectDefinition.$(H) $(STCHDR)
--- a/plugins/bee/bc.mak	Mon Jun 10 14:36:46 2019 +0100
+++ b/plugins/bee/bc.mak	Mon Jun 10 14:59:26 2019 +0100
@@ -82,8 +82,8 @@
 
 
 # BEGINMAKEDEPEND --- do not remove this line; make depend needs it
-$(OUTDIR)BeeSymbol.$(O) BeeSymbol.$(C) BeeSymbol.$(H): BeeSymbol.st $(INCLUDE_TOP)\jv\libgdbs\GDBObject.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
-$(OUTDIR)BeeSymbolListApplication.$(O) BeeSymbolListApplication.$(C) BeeSymbolListApplication.$(H): BeeSymbolListApplication.st $(INCLUDE_TOP)\jv\vdb\VDBAbstractApplication.$(H) $(INCLUDE_TOP)\jv\vdb\VDBAbstractContentsApplication.$(H) $(INCLUDE_TOP)\jv\vdb\VDBAbstractListApplication.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libview2\ApplicationModel.$(H) $(INCLUDE_TOP)\stx\libview2\Model.$(H) $(STCHDR)
+$(OUTDIR)BeeSymbol.$(O) BeeSymbol.$(C) BeeSymbol.$(H): BeeSymbol.st $(INCLUDE_TOP)\jv\libgdbs\GDBDebuggerObject.$(H) $(INCLUDE_TOP)\jv\libgdbs\GDBObject.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)BeeSymbolListApplication.$(O) BeeSymbolListApplication.$(C) BeeSymbolListApplication.$(H): BeeSymbolListApplication.st $(INCLUDE_TOP)\jv\libgdbs\GDBStopReasons.$(H) $(INCLUDE_TOP)\jv\vdb\VDBAbstractApplication.$(H) $(INCLUDE_TOP)\jv\vdb\VDBAbstractContentsApplication.$(H) $(INCLUDE_TOP)\jv\vdb\VDBAbstractListApplication.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libview2\ApplicationModel.$(H) $(INCLUDE_TOP)\stx\libview2\Model.$(H) $(STCHDR)
 $(OUTDIR)BeeSymbolPresenter.$(O) BeeSymbolPresenter.$(C) BeeSymbolPresenter.$(H): BeeSymbolPresenter.st $(INCLUDE_TOP)\jv\vdb\VDBAbstractPresenter.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libwidg2\AbstractHierarchicalItem.$(H) $(INCLUDE_TOP)\stx\libwidg2\HierarchicalItem.$(H) $(STCHDR)
 $(OUTDIR)GDBMI_bee_list_symbols.$(O) GDBMI_bee_list_symbols.$(C) GDBMI_bee_list_symbols.$(H): GDBMI_bee_list_symbols.st $(INCLUDE_TOP)\jv\libgdbs\GDBCommand.$(H) $(INCLUDE_TOP)\jv\libgdbs\GDBMICommand.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)jv_vdb_plugins_bee.$(O) jv_vdb_plugins_bee.$(C) jv_vdb_plugins_bee.$(H): jv_vdb_plugins_bee.st $(INCLUDE_TOP)\stx\libbasic\LibraryDefinition.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\ProjectDefinition.$(H) $(STCHDR)