Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.tbc to .tcl file

Tags:

tcl

this is a strange question and i searched but couldn't find any satisfactory answer.

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

I read here and someone mentioned about ::tcl_traceCompile and said this could be used to disassemble the .tbc file. But being a novice tcl user i am not sure if this is possible, or to say more, how exactly to use it.

Though i know that tcl compiler doesn't compile all the statements and so these statements can be easily seen in .tbc file but can we get the whole tcl back from .tbc file.

Any comment would be great.

like image 892
Puneet Mittal Avatar asked Jan 31 '13 18:01

Puneet Mittal


People also ask

What is .TBC file?

A TBC file is an . LDS (LaserDisc Sample) file that has been converted into a PAL or NTSC video using the ld-decode application. It contains a stream of 16-bit unsigned values, each of which represents a single grayscale value. With a significant amount of effort, TBC files can be used to create .

What is TBC Tcl?

The TBC file format is an encoding of Tcl's bytecode, which is not normally saved at all; the TBC stands for Tcl ByteCode.

What is Tcl file extension?

tcl) Definition. An ASCII text file (with the extension . tcl) that contains importable Tcl code or an executable Tcl script. Tcl, an abbreviation of the name "Tool Command Language", is a scripting language for controlling and extending software applications.


1 Answers

No, or at least not without a lot of work; you're doing something that quite a bit of effort was put in to prevent (the TBC format is intended for protecting commercial code from prying eyes).


The TBC file format is an encoding of Tcl's bytecode, which is not normally saved at all; the TBC stands for Tcl ByteCode. The TBC format data is only produced by one tool, the commercial “Tcl Compiler” (originally written by either Sun or Scriptics; the tool dates from about the time of the transition), which really is a leveraging of the built-in compiler that every Tcl system has together with some serialization code. It also strips as much of the original source code away as possible. The encoding used is unpleasant; you want to avoid writing your own loader of it if you can, and instead use the tbcload extension to do the work.

You'll then need to use it with a custom build of Tcl that disables a few defensive checks so that you can disassemble the loaded code with the tcl::unsupported::disassemble command (which normally refuses to take apart anything coming from tbcload); that command exists from Tcl 8.5 onwards. After that, you'll have to piece together what the code is doing from the bytecodes; I'm not aware of any tools for doing that at all, but the bytecodes are mostly fairly high level so it's not too difficult for small pieces of code.

There's no manual page for disassemble; it's formally unsupported after all! However, that wiki page I linked to should cover most of the things you need to get started.

like image 126
Donal Fellows Avatar answered Sep 28 '22 00:09

Donal Fellows