-->
Page 1 of 1

Using ChunkySpy to disassemble eLua compiled code

PostPosted: Mon May 04, 2015 6:52 am
by TerryE
For those interested in what the nodeMCU compiler generates, you will need to copy the .lc file onto your dev PC and use this utility: ChunkySpy. The latest version has 5.1 and 5.2 variants. You will need to use the 5.1 version (0.9.8). Note that because the eLua system has added extra constant types (rotables, light functions and light user data), you will need to apply the following patch, and use the --elua option to disassemble the nodeMCU complied code files:
Code: Select all--- a/ChunkSpy-0.9.8/5.1/ChunkSpy.lua   2015-05-04 12:39:01.267975498 +0100
+++ b/ChunkSpy-0.9.8/5.1/ChunkSpy.lua   2015-05-04 12:35:59.623983095 +0100
@@ -2193,6 +2193,9 @@
           config.AUTO_DETECT = true
         elseif a == "--brief" then
           config.DISPLAY_BRIEF = true
+        elseif a == "--elua" then
+          config.LUA_TNUMBER = 5
+          config.LUA_TSTRING = 6
         elseif a == "--interact" then
           perform = ChunkSpy_Interact



Happy dissassembly!

Re: Using ChunkySpy to disassemble eLua compiled code

PostPosted: Tue May 05, 2015 7:22 am
by TerryE
One immediate point to note from this is that there are two methods of saving compiled Lua to flash
  1. the first is to use node.compile() on the lua file
  2. the second is to use loadfile() to load it, then use string.dump()to convert it in-RAM to a serialised load format and then write this back to the file system.
It is well worth noting that these do not generate the same output. Basically, option (1) strips out all line and variable information, that the runtime error system uses to report line numbers, etc. and the second doesn't. What this means is that (1) is typically 60% the size of [2], but that any runtime errors are extremely limited.

So my recommendation is to use (1) if you have stable production code that you want to run in as low a RAM footprint as possible and (2) if you are still debugging, but want to avoid compilation overhead as any errors will be reported just the same as with load-and-go lua source.

Re: Using ChunkySpy to disassemble eLua compiled code

PostPosted: Tue May 05, 2015 9:54 am
by TimRen
Thanks Terry for all these info! I also trace your other post on ESP8266-harness project as well.

-Tim

Re: Using ChunkySpy to disassemble eLua compiled code

PostPosted: Mon Jul 15, 2019 4:13 am
by evilxiaohao
error occurred
./ChunkSpy.lua:1206: could not load integer