/
GTBytecodeDebugger.class.st
150 lines (119 loc) · 3.83 KB
/
GTBytecodeDebugger.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
"
I am a debugger that provides the ability to step through the execution at the bytecode level (e.g. one bytecode at a time).
"
Class {
#name : #GTBytecodeDebugger,
#superclass : #GTGenericStackDebugger,
#category : #'GT-BytecodeDebugger-UI'
}
{ #category : #accessing }
GTBytecodeDebugger class >> defaultTitle [
^ 'Bytecode'
]
{ #category : #accessing }
GTBytecodeDebugger class >> helpClass [
^ GTBytecodeDebuggerHelp
]
{ #category : #'tools registry' }
GTBytecodeDebugger class >> register [
self registerToolsOn: Smalltalk tools.
]
{ #category : #'tools registry' }
GTBytecodeDebugger class >> registerToolsOn: registry [
"Add ourselves to registry. See [Smalltalk tools]"
registry registerDebugger: self withRank: 5.
]
{ #category : #accessing }
GTBytecodeDebugger class >> sessionClass [
^ GTBytecodeDebuggerSession
]
{ #category : #accessing }
GTBytecodeDebugger class >> variablesBrowserClass [
^ GTBytecodeDebuggerVariablesBrowser
]
{ #category : #'building actions' }
GTBytecodeDebugger >> bytecodeActionsPragmas [
^ #( bytecodeCodeDebuggingAction )
]
{ #category : #'building presentations' }
GTBytecodeDebugger >> bytecodeIn: aComposite forContext: aContext [
(self methodBytecodeWidgetIn: aComposite forContext: aContext)
initialize: [ :bytecodePresentation |
bytecodePresentation selection: (self session symbolicBytecodeForCurrentPCFrom: self currentContext) ];
with: [ :bytecode | self installActionsForRootPragmas: self bytecodeActionsPragmas in: bytecode ].
]
{ #category : #accessing }
GTBytecodeDebugger >> bytecodePane [
^ self browser paneNamed: #bytecode
]
{ #category : #accessing }
GTBytecodeDebugger >> bytecodePresentation [
^ self bytecodePane presentations first
]
{ #category : #building }
GTBytecodeDebugger >> debuggerStructureIn: browser [
browser
row: #stack;
row: [ :c | c
column: #code;
column: #bytecode ] span: 2;
row: #inspector.
]
{ #category : #building }
GTBytecodeDebugger >> debuggerTransmissionsIn: browser [
super debuggerTransmissionsIn: browser.
browser transmit
from: #stack port: #selection;
to: #bytecode;
andShow: [ :composite :aContext | self bytecodeIn: composite forContext: aContext ]
]
{ #category : #'building presentations' }
GTBytecodeDebugger >> decompiledCodeWidgetIn: arg1 forContext: arg2 [
| tmp2 |
tmp2 := arg1 pharoMethod.
tmp2
title: 'Decompiled';
format: [ arg2 compiledCode codeForNoSource ];
smalltalkClass: [ arg2 methodClass ];
doItReceiver: [ arg2 receiver ].
^ tmp2 doItContext: [ arg2 ]
]
{ #category : #'printing/formatting' }
GTBytecodeDebugger >> formatBytecode: aBytecode [
| textAttributes|
textAttributes := {TextColor new color: self theme textColor}.
self selectedContext pc = aBytecode offset ifTrue: [ textAttributes := {TextColor new color: self theme textColor. TextEmphasis italic} ].
self selectedContext pc > aBytecode offset ifTrue: [ textAttributes := {TextColor new color: Color gray} ].
^ Text
string: aBytecode printString
attributes: textAttributes
]
{ #category : #'building presentations' }
GTBytecodeDebugger >> methodBytecodeWidgetIn: arg1 forContext: arg2 [
| tmp2 |
tmp2 := arg1 tree.
tmp2
title: 'Bytecode';
rootsExpanded;
display: [ arg2 compiledCode symbolicBytecodes ];
children: [ :arg3 |
arg3 isArray
ifTrue: [ arg3 ]
ifFalse: #() ];
format: [ :arg4 | self formatBytecode: arg4 ].
^ tmp2
onChangeOfPort: #selection
act: [ :arg5 |
| tmp3 |
self codePresentation
selectionInterval:
((tmp3 := arg5 selection)
ifNil: [ 1 to: 0 ]
ifNotNil: [ tmp3 sourceInterval ]) ]
]
{ #category : #'building presentations' }
GTBytecodeDebugger >> methodCodeIn: composite forContext: aContext [
(self methodCodeWidgetIn: composite forContext: aContext)
with: [ :code | self installCodeActionsFor: code ].
"self decompiledCodeWidgetIn: composite forContext: aContext"
]