.tbc to .tcl file

This is a strange question, and I searched, but could not find a satisfactory answer.

I have a compiled tcl file, i.e. .tbc file. So, there is a way to convert this .tbc file to a .tcl file.

I read here and someone mentioned ::tcl_traceCompile and said that this can be used to disassemble the .tbc file. But, as a newbie, I'm not sure if this is possible, or to say more how to use it.

Although I know that the tcl compiler does not compile all the instructions, and therefore these statements can be easily seen in the .tbc file, we can return the whole tcl from the .tbc file.

Any comments would be great.

+4
source share
2 answers

No, or at least not without a lot of work; you are doing something that was taken to prevent it (the TBC format is designed to protect commercial code from prying eyes).


The TBC file format is Tcl bytecode encoding, which is usually not stored at all; TBC stands for T cl B yte C ode. TBC format data is produced by only one tool - the commercial "Tcl Compiler" (originally written by Sun or Scriptics, the tool dates from transition time), which is really using the built-in compiler that every Tcl system along with some serialization code. It also removes as much of the source code as possible. The encoding used is unpleasant; you want to avoid writing your own bootloader if you can, and use the tbcload extension tbcload to do the job.

Then you will need to use it with a custom Tcl assembly that will disable several security checks so that you can parse the downloaded code using tcl::unsupported::disassemble (which usually refuses to separate everything that comes from tbcload ); this command exists from Tcl 8.5 onwards. After that, you will have to combine what the code is doing from bytecodes; I don’t know any tools for this, but the bytecodes are mostly pretty high level, so it’s not too difficult for small code fragments.

There is no manual page for disassemble ; it is not formally supported in the end! However, this wiki page that I'm linked to should cover most of the things you need to get started.

+4
source

I can partially say yes and convention too. This condition is that the source code for tcl is written in the namespace, and procs are defined in braces in the namespace. Then you upload the tbc file to tkcon / wish and see the code using the info procs and namespace commands. If you need to know the namespace name. However, this can also be found.

0
source

All Articles