debugger.qml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. import QtQuick 2.0
  2. import QtQuick.Controls 1.0;
  3. import QtQuick.Layouts 1.0;
  4. import QtQuick.Dialogs 1.0;
  5. import QtQuick.Window 2.1;
  6. import QtQuick.Controls.Styles 1.1
  7. import Ethereum 1.0
  8. ApplicationWindow {
  9. visible: false
  10. title: "IceCREAM"
  11. minimumWidth: 1280
  12. minimumHeight: 700
  13. width: 1290
  14. height: 700
  15. property alias codeText: codeEditor.text
  16. property alias dataText: rawDataField.text
  17. MenuBar {
  18. Menu {
  19. title: "Debugger"
  20. MenuItem {
  21. text: "Run"
  22. shortcut: "Ctrl+r"
  23. onTriggered: debugCurrent()
  24. }
  25. MenuItem {
  26. text: "Next"
  27. shortcut: "Ctrl+n"
  28. onTriggered: dbg.next()
  29. }
  30. }
  31. }
  32. SplitView {
  33. anchors.fill: parent
  34. property var asmModel: ListModel {
  35. id: asmModel
  36. }
  37. TableView {
  38. id: asmTableView
  39. width: 200
  40. TableViewColumn{ role: "value" ; title: "" ; width: 200 }
  41. model: asmModel
  42. }
  43. Rectangle {
  44. color: "#00000000"
  45. anchors.left: asmTableView.right
  46. anchors.right: parent.right
  47. SplitView {
  48. orientation: Qt.Vertical
  49. anchors.fill: parent
  50. Rectangle {
  51. color: "#00000000"
  52. height: 330
  53. anchors.left: parent.left
  54. anchors.right: parent.right
  55. TextArea {
  56. id: codeEditor
  57. anchors.top: parent.top
  58. anchors.bottom: parent.bottom
  59. anchors.left: parent.left
  60. anchors.right: settings.left
  61. }
  62. Column {
  63. id: settings
  64. spacing: 5
  65. width: 300
  66. height: parent.height
  67. anchors.right: parent.right
  68. anchors.top: parent.top
  69. anchors.bottom: parent.bottom
  70. Label {
  71. text: "Arbitrary data"
  72. }
  73. TextArea {
  74. id: rawDataField
  75. anchors.left: parent.left
  76. anchors.right: parent.right
  77. height: 150
  78. }
  79. Label {
  80. text: "Amount"
  81. }
  82. TextField {
  83. id: txValue
  84. width: 200
  85. placeholderText: "Amount"
  86. validator: RegExpValidator { regExp: /\d*/ }
  87. }
  88. Label {
  89. text: "Amount of gas"
  90. }
  91. TextField {
  92. id: txGas
  93. width: 200
  94. validator: RegExpValidator { regExp: /\d*/ }
  95. text: "10000"
  96. placeholderText: "Gas"
  97. }
  98. Label {
  99. text: "Gas price"
  100. }
  101. TextField {
  102. id: txGasPrice
  103. width: 200
  104. placeholderText: "Gas price"
  105. text: "1000000000000"
  106. validator: RegExpValidator { regExp: /\d*/ }
  107. }
  108. }
  109. }
  110. SplitView {
  111. orientation: Qt.Vertical
  112. id: inspectorPane
  113. height: 500
  114. SplitView {
  115. orientation: Qt.Horizontal
  116. height: 150
  117. TableView {
  118. id: stackTableView
  119. property var stackModel: ListModel {
  120. id: stackModel
  121. }
  122. height: parent.height
  123. width: 300
  124. TableViewColumn{ role: "value" ; title: "Temp" ; width: 200 }
  125. model: stackModel
  126. }
  127. TableView {
  128. id: memoryTableView
  129. property var memModel: ListModel {
  130. id: memModel
  131. }
  132. height: parent.height
  133. width: parent.width - stackTableView.width
  134. TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50}
  135. TableViewColumn{ role: "value" ; title: "Memory" ; width: 750}
  136. model: memModel
  137. }
  138. }
  139. Rectangle {
  140. height: 100
  141. width: parent.width
  142. TableView {
  143. id: storageTableView
  144. property var memModel: ListModel {
  145. id: storageModel
  146. }
  147. height: parent.height
  148. width: parent.width
  149. TableViewColumn{ id: key ; role: "key" ; title: "#" ; width: storageTableView.width / 2}
  150. TableViewColumn{ role: "value" ; title: "Storage" ; width: storageTableView.width / 2}
  151. model: storageModel
  152. }
  153. }
  154. Rectangle {
  155. height: 200
  156. width: parent.width
  157. TableView {
  158. id: logTableView
  159. property var logModel: ListModel {
  160. id: logModel
  161. }
  162. height: parent.height
  163. width: parent.width
  164. TableViewColumn{ id: message ; role: "message" ; title: "log" ; width: logTableView.width }
  165. model: logModel
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. toolBar: ToolBar {
  173. RowLayout {
  174. spacing: 5
  175. Button {
  176. property var enabled: true
  177. id: debugStart
  178. onClicked: {
  179. debugCurrent()
  180. }
  181. text: "Debug"
  182. }
  183. Button {
  184. property var enabled: true
  185. id: debugNextButton
  186. onClicked: {
  187. dbg.next()
  188. }
  189. text: "Next"
  190. }
  191. CheckBox {
  192. id: breakEachLine
  193. objectName: "breakEachLine"
  194. text: "Break each instruction"
  195. checked: true
  196. }
  197. }
  198. }
  199. function debugCurrent() {
  200. dbg.debug(txValue.text, txGas.text, txGasPrice.text, codeEditor.text, rawDataField.text)
  201. }
  202. function setAsm(asm) {
  203. asmModel.append({asm: asm})
  204. }
  205. function clearAsm() {
  206. asmModel.clear()
  207. }
  208. function setInstruction(num) {
  209. asmTableView.selection.clear()
  210. asmTableView.selection.select(num)
  211. }
  212. function setMem(mem) {
  213. memModel.append({num: mem.num, value: mem.value})
  214. }
  215. function clearMem(){
  216. memModel.clear()
  217. }
  218. function setStack(stack) {
  219. stackModel.append({value: stack})
  220. }
  221. function addDebugMessage(message){
  222. debuggerLog.append({value: message})
  223. }
  224. function clearStack() {
  225. stackModel.clear()
  226. }
  227. function clearStorage() {
  228. storageModel.clear()
  229. }
  230. function setStorage(storage) {
  231. storageModel.append({key: storage.key, value: storage.value})
  232. }
  233. function setLog(msg) {
  234. logModel.insert(0, {message: msg})
  235. }
  236. function clearLog() {
  237. logModel.clear()
  238. }
  239. }