Skip to content

Commit 0a82e3b

Browse files
committed
Stack info
1 parent 9689a20 commit 0a82e3b

File tree

4 files changed

+92
-31
lines changed

4 files changed

+92
-31
lines changed

Mist/assets/debugger/debugger.qml

Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,37 @@ ApplicationWindow {
8686
TableView {
8787
id: asmTableView
8888
width: 200
89+
headerVisible: false
8990
TableViewColumn{ role: "value" ; title: "" ; width: asmTableView.width - 2 }
9091
model: asmModel
92+
/*
93+
alternatingRowColors: false
94+
itemDelegate: Item {
95+
Rectangle {
96+
anchors.fill: parent
97+
color: "#DDD"
98+
Text {
99+
anchors {
100+
left: parent.left
101+
right: parent.right
102+
leftMargin: 10
103+
verticalCenter: parent.verticalCenter
104+
}
105+
color: "#333"
106+
elide: styleData.elideMode
107+
text: styleData.value
108+
font.pixelSize: 11
109+
MouseArea {
110+
acceptedButtons: Qt.LeftButton
111+
anchors.fill: parent
112+
onClicked: {
113+
mouse.accepted = true
114+
}
115+
}
116+
}
117+
}
118+
}
119+
*/
91120
}
92121

93122
Rectangle {
@@ -201,8 +230,8 @@ ApplicationWindow {
201230
}
202231
height: parent.height
203232
width: parent.width - stackTableView.width
204-
TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50}
205-
TableViewColumn{ role: "value" ; title: "Memory" ; width: 750}
233+
TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50 }
234+
TableViewColumn{ role: "value" ; title: "Memory" ; width: 750 }
206235
model: memModel
207236
}
208237
}
@@ -223,31 +252,21 @@ ApplicationWindow {
223252
}
224253
}
225254

226-
SplitView {
227-
Rectangle {
228-
height: 200
229-
width: parent.width * 0.66
230-
TableView {
231-
id: logTableView
232-
property var logModel: ListModel {
233-
id: logModel
234-
}
235-
height: parent.height
236-
width: parent.width
237-
TableViewColumn{ id: message ; role: "message" ; title: "log" ; width: logTableView.width - 2 }
238-
model: logModel
239-
}
240-
}
241-
242-
TextArea {
243-
objectName: "info"
244-
anchors {
245-
top: parent.top
246-
bottom: parent.bottom
255+
Rectangle {
256+
height: 200
257+
width: parent.width * 0.66
258+
TableView {
259+
id: logTableView
260+
property var logModel: ListModel {
261+
id: logModel
247262
}
248-
readOnly: true
263+
height: parent.height
264+
width: parent.width
265+
TableViewColumn{ id: message ; role: "message" ; title: "log" ; width: logTableView.width - 2 }
266+
model: logModel
249267
}
250268
}
269+
251270
}
252271
}
253272
}
@@ -271,12 +290,37 @@ ApplicationWindow {
271290
exec()
272291
}
273292
}
293+
294+
RowLayout {
295+
anchors.left: dbgCommand.right
296+
anchors.leftMargin: 10
297+
spacing: 5
298+
y: parent.height / 2 - this.height / 2
299+
300+
Text {
301+
objectName: "stackFrame"
302+
font.pixelSize: 10
303+
text: "<b>stack ptr</b>: 0"
304+
}
305+
306+
Text {
307+
objectName: "stackSize"
308+
font.pixelSize: 10
309+
text: "<b>stack size</b>: 0"
310+
}
311+
312+
Text {
313+
objectName: "memSize"
314+
font.pixelSize: 10
315+
text: "<b>mem size</b>: 0"
316+
}
317+
}
274318
}
275319

276320
toolBar: ToolBar {
277321
height: 30
278322
RowLayout {
279-
spacing: 5
323+
spacing: 10
280324

281325
Button {
282326
property var enabled: true
@@ -338,6 +382,7 @@ ApplicationWindow {
338382
function setInstruction(num) {
339383
asmTableView.selection.clear()
340384
asmTableView.selection.select(num)
385+
asmTableView.positionViewAtRow(num, ListView.Center)
341386
}
342387

343388
function setMem(mem) {

Mist/debugger.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"math/big"
66
"strconv"
77
"strings"
8+
"unicode"
89

910
"github.com/ethereum/eth-go/ethchain"
1011
"github.com/ethereum/eth-go/ethstate"
@@ -271,9 +272,20 @@ func (d *Debugger) halting(pc int, op ethvm.OpCode, mem *ethvm.Memory, stack *et
271272
d.win.Root().Call("clearStorage")
272273

273274
addr := 0
274-
for i := 0; i+32 <= mem.Len(); i += 32 {
275-
d.win.Root().Call("setMem", memAddr{fmt.Sprintf("%03d", addr), fmt.Sprintf("% x", mem.Data()[i:i+32])})
276-
addr++
275+
for i := 0; i+32 <= mem.Len(); i += 16 {
276+
dat := mem.Data()[i : i+16]
277+
var str string
278+
279+
for _, d := range dat {
280+
if unicode.IsGraphic(rune(d)) {
281+
str += string(d)
282+
} else {
283+
str += "?"
284+
}
285+
}
286+
287+
d.win.Root().Call("setMem", memAddr{fmt.Sprintf("%03d", addr), fmt.Sprintf("%s % x", str, dat)})
288+
addr += 16
277289
}
278290

279291
for _, val := range stack.Data() {
@@ -284,7 +296,11 @@ func (d *Debugger) halting(pc int, op ethvm.OpCode, mem *ethvm.Memory, stack *et
284296
d.win.Root().Call("setStorage", storeVal{fmt.Sprintf("% x", key), fmt.Sprintf("% x", node.Str())})
285297
})
286298

287-
d.win.Root().ObjectByName("info").Set("text", fmt.Sprintf(`stack frame %v`, new(big.Int).SetBytes(mem.Get(0, 32))))
299+
stackFrameAt := new(big.Int).SetBytes(mem.Get(0, 32))
300+
psize := mem.Len() - int(new(big.Int).SetBytes(mem.Get(0, 32)).Uint64())
301+
d.win.Root().ObjectByName("stackFrame").Set("text", fmt.Sprintf(`<b>stack ptr</b>: %v`, stackFrameAt))
302+
d.win.Root().ObjectByName("stackSize").Set("text", fmt.Sprintf(`<b>stack size</b>: %d`, psize))
303+
d.win.Root().ObjectByName("memSize").Set("text", fmt.Sprintf(`<b>mem size</b>: %v`, mem.Len()))
288304

289305
out:
290306
for {

Mist/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func defaultAssetPath() string {
4444
// assume a debug build and use the source directory as
4545
// asset directory.
4646
pwd, _ := os.Getwd()
47-
if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "Mist") {
47+
if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "mist") {
4848
assetPath = path.Join(pwd, "assets")
4949
} else {
5050
switch runtime.GOOS {

javascript/javascript_runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (jsre *JSRE) LoadExtFile(path string) {
4242
}
4343

4444
func (jsre *JSRE) LoadIntFile(file string) {
45-
assetPath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "Mist", "assets", "ext")
45+
assetPath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "mist", "assets", "ext")
4646
jsre.LoadExtFile(path.Join(assetPath, file))
4747
}
4848

0 commit comments

Comments
 (0)