Friday, January 18, 2008

Installing Tango Backtrace Hack on Tango Bundles

Yesterday I was wrote that the Tango Backtrace Hack is available from our download page. Due to the patcher (that is a .bat file) included, the installation is pretty simple and quick. Unfortunately not in all cases.
The Tango team some time ago introduced "Bundles and Binaries". We will be playing with the dmd "current release bundled with Tangobos" package, but everything I'm going to describe should be similar on other packages. OK as I said there are some packages, but unfortunately they are far from out of the box philosophy. You will not get a bad impression at the first sight (despite needing to download Rebuild or Build), but when you start doing some real coding, you will find out those packages are lacking some stuff.
Of course the patcher does some serious compiling and is obviously showing the lack of necessary components in tango packages. But have no fear, team0xf is here! ;) So what do you need to add to the package, so that the tango hack will work?
Go to http://www.digitalmars.com/d/1.0/dcompiler.html and download the DMC package. Copy files from dm/include to yourtangobundle/include (you will probably need to create that directory). Also copy dmc.exe and scppn.exe from dm/bin to yourtangobundle/bin.

After that you can run patchTango.bat.
You can test the backtrace hack by running code like:
module Main;

void main(){
assert(false);
}

Compile it with dmd -g Main.d
When running Main.exe you will get:

Tango backtrace hack intiated
Unhandled D exception!
Error: Assertion failure (tango.core.Exception.AssertException) in Main.d [4]
backtrace:
004040ea onAssertError (+2e)
0040201e _Dmain (+e)
004023d1 extern (C) int dmain2.main(int, char**) . void runMain(void*) (+d)
0040e586 mainCRTStartup (+aa)
7c816fd8 ???
00000001 ???


If you don't see the backtrace, that would mean you forgot something ( or there is something I haven't written about ).

I hope this short article will help with patching tango bundles. If there are other problems in applying the tango hack to other packages, please paste a comment here reporting it. We will try to post a similar article, solving your problem.

There are some other files you should get from the orginal dmd/dmc packages. The most important is to add these libraries to yourtangobundle/lib :
  • gdi32.lib
  • usergdi32.lib
  • winmm.lib