Commit 4d1cb1ad70b607a809129de298594beb4d82ba71
DebugInterface: simplify code with getMemoryBuffer
Alex Beregszaszi committed on 8/6/2016, 3:23:44 AMParent: 11bf38b337c307194ff2f28d9c812769e3b0d156
Files changed
debugInterface.js | changed |
debugInterface.js | ||
---|---|---|
@@ -12,13 +12,13 @@ | ||
12 | 12 | |
13 | 13 | get exportTable () { |
14 | 14 | return { |
15 | 15 | 'print': function (offset, length) { |
16 | - console.log(`<DEBUG(str): ${new Buffer(new Uint8Array(this.module.exports.memory, offset, length)).toString()}>`) | |
16 | + console.log(`<DEBUG(str): ${this.getMemoryBuffer(offset, length).toString()}>`) | |
17 | 17 | }.bind(this), |
18 | 18 | |
19 | 19 | 'printHex': function (offset, length) { |
20 | - console.log(`<DEBUG(hex): ${new Buffer(new Uint8Array(this.module.exports.memory, offset, length)).toString('hex')}>`) | |
20 | + console.log(`<DEBUG(hex): ${this.getMemoryBuffer(offset, length).toString('hex')}>`) | |
21 | 21 | }.bind(this), |
22 | 22 | |
23 | 23 | 'evmStackTrace': function (sp, op) { |
24 | 24 | const opcode = opcodes(op) |
@@ -27,11 +27,15 @@ | ||
27 | 27 | } |
28 | 28 | console.error(opcode.name) |
29 | 29 | console.log('-------------stack--------------') |
30 | 30 | for (let i = sp; i > 0; i -= 32) { |
31 | - console.log(`${(sp - i) / 32} ${new Buffer(new Uint8Array(this.module.exports.memory, i - 24, 32)).toString('hex')}`) | |
31 | + console.log(`${(sp - i) / 32} ${this.getMemoryBuffer(i - 24, 32).toString('hex')}`) | |
32 | 32 | } |
33 | 33 | return sp |
34 | 34 | }.bind(this) |
35 | 35 | } |
36 | 36 | } |
37 | + | |
38 | + getMemoryBuffer (offset, length) { | |
39 | + return new Buffer(new Uint8Array(this.module.exports.memory, offset, length)) | |
40 | + } | |
37 | 41 | } |
Built with git-ssb-web