Artifact Content
Not logged in

Artifact f18562976753621a5cc5ea63bc453ba19dd7b917


     1  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.
     2  
     3  
     4  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.
     5  
     6  import stacktrace;
     7  
     8  void main(string[] argv){
     9  ...
    10  }
    11  
    12  Now all Errors will get trace information.
    13  If you need a backtrace at a certain point in your code just do the following:
    14  
    15  module foo;
    16  
    17  import stacktrace;
    18  
    19  void blup(){
    20  ...
    21  StackTrace trace = new StackTrace();
    22  auto stack = trace.GetCallstack();
    23  foreach(char[] s;stack)
    24  writefln("%s",s);
    25  ...
    26  }
    27  
    28  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.
    29  
    30  XP Users:
    31  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.