File Annotation
Not logged in
423f308350 2010-11-07        kinaba: I wrote a small piece of sourcecode that generates stacktraces in D 2.0 under windows. It works both with the pdb and cv debug symbol format. For Exceptions that are derived from the Error class the trace information is automatically appended, this causes all builtin D errors to get a stacktrace information. The only point where this does not work is the Access Vioaltion error, as it does not call the stacktrace callback function for some reason.
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: It is very easy to use, just copy the two files from the zip archive to your root source directory and import the stacktrace module inside your main file.
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: import stacktrace;
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: void main(string[] argv){
423f308350 2010-11-07        kinaba: ...
423f308350 2010-11-07        kinaba: }
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: Now all Errors will get trace information.
423f308350 2010-11-07        kinaba: If you need a backtrace at a certain point in your code just do the following:
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: module foo;
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: import stacktrace;
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: void blup(){
423f308350 2010-11-07        kinaba: ...
423f308350 2010-11-07        kinaba: StackTrace trace = new StackTrace();
423f308350 2010-11-07        kinaba: auto stack = trace.GetCallstack();
423f308350 2010-11-07        kinaba: foreach(char[] s;stack)
423f308350 2010-11-07        kinaba: writefln("%s",s);
423f308350 2010-11-07        kinaba: ...
423f308350 2010-11-07        kinaba: }
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: It is released under the BSD license. If this licence causes any problems for you, feel free to contact me and we will fix the problem.
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: XP Users:
423f308350 2010-11-07        kinaba: If you get a stacktrace with numbers only download a new version of dbghelp.dll and put it into your project root directory. That should fix it.