VDBThreadPresenter.st
changeset 197 a4f790013a99
parent 60 bcdb393c956f
child 207 27e7fa4229b3
--- a/VDBThreadPresenter.st	Sat Aug 08 22:45:10 2020 +0100
+++ b/VDBThreadPresenter.st	Sun Aug 09 07:18:09 2020 +0100
@@ -1,6 +1,7 @@
 "
 jv:vdb - Visual / VM Debugger
 Copyright (C) 2015-now Jan Vrany
+Copyright (C) 2020 LabWare
 
 This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
 
@@ -23,6 +24,7 @@
 "
 jv:vdb - Visual / VM Debugger
 Copyright (C) 2015-now Jan Vrany
+Copyright (C) 2020 LabWare
 
 This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
 
@@ -30,6 +32,36 @@
 "
 ! !
 
+!VDBThreadPresenter 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:VDBThreadPresenter andSelector:#contextMenu
+     (Menu new fromLiteralArrayEncoding:(VDBThreadPresenter contextMenu)) startUp
+    "
+
+    <resource: #menu>
+
+    ^ 
+     #(Menu (
+         (MenuItem
+            enabled: canCopyBacktrace
+            label: 'Copy Backtrace To Clipboard'
+            itemValue: doCopyBacktraceToClipboard
+            isVisible: true
+         )
+       ) nil
+        nil
+     )
+! !
+
 !VDBThreadPresenter methodsFor:'accessing'!
 
 icon
@@ -75,6 +107,29 @@
     "Modified: / 12-07-2017 / 14:21:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!VDBThreadPresenter methodsFor:'menu actions'!
+
+doCopyBacktraceToClipboard
+    | backtrace |
+
+    backtrace := String streamContents:[:s|
+        thread stack 
+            do: [:frame | frame dumpOn: s ]
+            separatedBy: [ s cr; nextPutAll: '--'; cr ]       
+    ].
+    self doCopy: backtrace
+
+    "Modified: / 09-08-2020 / 07:15:42 / Jan Vrany <jan.vrany@labware.com>"
+! !
+
+!VDBThreadPresenter methodsFor:'menu queries'!
+
+canCopyBacktrace
+    ^ [ thread isStopped ]
+
+    "Modified: / 09-08-2020 / 07:01:35 / Jan Vrany <jan.vrany@labware.com>"
+! !
+
 !VDBThreadPresenter methodsFor:'protocol-accessing'!
 
 fetchChildren