git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 4d1cb1ad70b607a809129de298594beb4d82ba71

DebugInterface: simplify code with getMemoryBuffer

Alex Beregszaszi committed on 8/6/2016, 3:23:44 AM
Parent: 11bf38b337c307194ff2f28d9c812769e3b0d156

Files changed

debugInterface.jschanged
debugInterface.jsView
@@ -12,13 +12,13 @@
1212
1313 get exportTable () {
1414 return {
1515 '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()}>`)
1717 }.bind(this),
1818
1919 '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')}>`)
2121 }.bind(this),
2222
2323 'evmStackTrace': function (sp, op) {
2424 const opcode = opcodes(op)
@@ -27,11 +27,15 @@
2727 }
2828 console.error(opcode.name)
2929 console.log('-------------stack--------------')
3030 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')}`)
3232 }
3333 return sp
3434 }.bind(this)
3535 }
3636 }
37+
38+ getMemoryBuffer (offset, length) {
39+ return new Buffer(new Uint8Array(this.module.exports.memory, offset, length))
40+ }
3741 }

Built with git-ssb-web