From 9f222971e304d4ec03a3af9015744530f2c8793d Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Thu, 2 Feb 2017 22:08:53 +0100 Subject: readDebug --- src/lundump.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lundump.js b/src/lundump.js index bab34fe..46a9d70 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -190,6 +190,36 @@ class BytecodeParser { } } + readDebug(f) { + let n = this.readInt(); + for (let i = 0; i < n; i++) + f.lineinfo[i] = this.readInt(); + + n = this.readInt(); + for (let i = 0; i < n; i++) { + f.locvars[i] = { + varname: this.readString(), + startpc: this.readInt(), + endpc: this.readInt() + } + + console.log(` + f.locvars[${i}].varname = ${f.locvars[i].varname} + f.locvars[${i}].startpc = ${f.locvars[i].startpc} + f.locvars[${i}].endpc = ${f.locvars[i].endpc} + `); + } + + n = this.readInt(); + for (let i = 0; i < n; i++) { + f.upvalues[i].name = this.readString(); + + console.log(` + f.upvalues[${i}].name = ${f.upvalues[i].name} + `); + } + } + readFunction(f, psource) { f.source = this.readString(); if (f.source === null || f.source === undefined || f.source.length === 0) /* no source in dump? */ @@ -213,7 +243,7 @@ class BytecodeParser { this.readConstants(f); this.readUpvalues(f); this.readProtos(f); - // this.readDebug(f); + this.readDebug(f); } checkHeader() { @@ -260,7 +290,7 @@ class BytecodeParser { this.readFunction(cl.p); - // assert(cl.nupvalues === cl.p.upvalues.length); + assert(cl.nupvalues === cl.p.upvalues.length); return cl; } -- cgit v1.2.3-54-g00ecf