DEMO VIDEO DBUG demo
Update 4, files are changed! 28-jan-2010
- new buttons for debugging and managing the expressions list (add, delete, save, restore)
- button images
- pause button
- mouse over variable names in the source code displays the current variable value as tooltip!
- Debug the complete script or just parts of it
- Display run status (linenumber of currently executed function)
- GUI default always-on-top in the upper right corner for comfortable debugging
- WM_NOTIFY and WM_COMMAND hook to prevent interference with possible message handlers
- Display scope, type and value of variables, expressions, macro's and constants (global AND function local)
- Execute commands in an immediate window. Can be expressions, functions and assignments
- Detailed display of array, struct and object variables
- Dynamic display of variable value in the source code (under cursor)
1) #include <dbug.au3> as first line of the script to debug (after placing dbug.au3 in the include folder of course)
2) copy the images in a folder IMAGES on the same level as the Include folder
3) run the script!
That's all. Take special care when debugging message handlers, when they don't return fast enough, strange things may happen. To prevent this, you may add a line ;STOP DBUG before the part you want to exclude from debugging until the line ;START DBUG (or the end of the script).
Update 3, files are changed!
Extended to debug complete scripts, not just lines.
Although the GUI looks the same, the script is completely rewritten. Changes:
- More reliable: debugger doesn't fail on constants and not declared variables.
- No limitation to the count of variables that are read.
- Determination of variable scope is correct.
- Indication of breakpoint line when used with SciTE.
- Re-entry of the debugger is prevented and indicated.
Damn, I found a serious flaw in the script. The basic idea is to Execute() a function with the local variables as arguments. To be changable at debug time they are passed ByRef. This works wonderfull for variables but when constants are passed then the Execute() fails silently. I don't see how I can prevent this, anybody any idea?
when playing with AutoIt I felt the need of an easy way to debug a bit more sophisticated then endless adding msgbox and consolewrites to my scripts. After looking around I start thinking of a way to make local variables visible outside there scope and came up with Dbug.au3. It's far from perfect but I wanted to share with you. Hope to hear your comments and maybe you find it usefull.
By now the features are:
- display scope, type and value of variables, expressions, macro's and constants (global AND function local)
- execute commands in an immediate window. Can be expressions, functions and assignments
- detailed display of array, struct and object variables
- set a breakpoint expression
Limitations are there also:
- max 20 variables to display
- scope display is not as reliable as it should be
- when there is a not declared variable in the debugged function, debugging fails without an errormessage (Opt('MustDeclareVars', 1) helps)
- multiple debug windows not allowed (but who does need them anyway?)
- and without doubt more not yet discovered bugs!
display: binary($var), @scriptdir, $var_a & $var_b, $arr, timerinit(), etc
commands: $a = $b, ($c >= $d), $struc, $arr = 'testDBUG', StringRegExp('TestDBUG', 'D(.*)', 2), etc, etc
- Include the debug script dbug.au3 in the script you want to debug.
- Write Execute(_debug()) on every line you want to inspect.
- That's all!
To play right away I supplied a little test script too (TestDBUG.au3)
dbug.au3 - debug script (Update 3 downloads: 94)
IMAGES - Folder with fancy button images
TestDBUG.au3 - declaration of some variables and calls to debugger
I really like to know what you think of it and if you can use it. I spent far more time on it then planned So feedback is appreciated!