Debugging, stacktrace output

BlitzMax Forums/BlitzMax Beginners Area/Debugging, stacktrace output

pappavis(Posted 2006) [#1]
Hi Blitzers!

Has anyone made a debug library, or have some quick code for me to allow a runtime stacktrace of my executable? Ideally, the output must be written to a appendable flat file.

I'dlike this sort of output:

22-mei-2006 14:47.00000 ** APP debug starting **
22-mei-2006 14:47.00001 ENTER method Main()
22-mei-2006 14:47.00002 setting variables
22-mei-2006 14:47.00003 setting variables
22-mei-2006 14:47.00004 setting display to 800, 600 depth 32
22-mei-2006 14:47.00005 END method Main()
22-mei-2006 14:47.00006 Application ending
22-mei-2006 14:47.00003 ** APP debug END **


In my program code id would do something like

GLOBAL DebugLog:String = "";

Method Main()
  Local strMethodName1:String = "Main()";

  Debugger.WriteLine("TMain", strMethodName1, "** APP debug starting **");

end Method


I'd rather not reinvent the wheel ;)


klepto2(Posted 2006) [#2]
Well, I have currently written one for my own BMax IDE, but the code is in VB.Net. But I could give you a short summary on how BMax handles the stacktrace:

Step 1:
You have to get the process of you executable. Then you have to write "t" to the process Inputstream. Now the Stcktrace starts and you will get an output like this:
~>Stacktrace
~>Function YourAppname
~>Global A:Int=10
~>Global Test:TTest=$00232d80
etc.
the output is buffered in the process errorstream and you have to handle the output by yourself with err.Readline().
The Keyword 'Function' shows you which scope the following lines are belonging to.
Step 2:
You have noticed the line ~>Global Test:TTest=$00232d80?
Now, to receive full detail on this object, you have to dump this object. The Address is the value behind the = . To achieve this you have to write "d"+the address(without $) to the inputstream. And handle this the same way as the output from the stacktrace.

I hope this will help you. Maybe you should take a look to the Process module source and the Maxide source.

klepto2