Debugger

Contents




Overview


The HBasic debugger may be used to step through a HBasic program in small steps and to display or change variable values at runtime. The debugger will be started with a mouseclick on the debugger icon in the toolbar before running the interpreter.


HBasic will automatically start the debugger if you have defined some breakpoints in your sourcecode.


 
Starting the debugger opens 2 debugger related windows in the HBasic mainwindow and closes all other windows. The following image shows the debugger after setting a breakpoint and starting the example program debug.bas. The program has been interrupted at the breakpoint in the source code line glob2=111. The window on the left will show the call-stack which is a list of functions that have been called until this source code position. The window on the right is split into two subwidgets. The top widget shows a list of variable values that will be defined at the current source code position and the bottom window could be used to define a list of watched variables. For the top window you may select with a mouseclick on the buttens in the window if you want to see all variables or only a list of globa, formlocal or sublocal variables. The icons in front of each variable shows the variable range the variable value belongs to.



If a program has been interrupted you can restart it or walk through the program in small steps with a mouseclick on the buttons in the call stack window. It is possible to start

Continue execution
Execute command starting at the last breakpoint
Step in
Execute commands until next source line has been reached. If it's a subroutine call abort in first line within subroutine body
Step over
Execute commands until next source line has been reached. If it's a subroutine execute commands until end of subroutine body has been reached.
Step out
Execute commands until end of current subroutine has been reached.



Breakpoints


Set new breakpoints or clear existing breakpoints with a mouseclick in the left border of a sourcecode window. Breakpoints will be displayed as a small icon in the line where you have clicked. In the current version of HBasic breakpoints will not be saved in a project file.




Call stack window


The callstack window displays the function call hierarchy for the current sourcecode position. In the following example the functions called have been:

Button1_clicked -- called -> Func1 -- called -> Func2 -- called -> Func3





Display variable values in debugger


The variable window displays the range, name and value of every variable that has been defined at the current source code position. You may limit the list of displayed values or create your own list in the bottom watched values window. To add or drop a variable in the watched values window click with the right mouse button on the window and select Add or Delete in the popup window.



If you want to get a some information about values of variables at runtime you should first take a look at the second debugger window. This window will normally display a list of all variables currently defined in the runtime environment for the current code position.



Get detailed variable information


If you double click on a value in the values window you will get a new dialog that may be used to change the value of a variable at runtime. Currently it is only possible to change some simple type values like integer or double.



To change the current value of the variable insert a new value in the Value LineEdit widget and click on the OK button.



Display array values


If you have defined a variable of array type the variable window of the debugger will only display the start address of the array. To display values within the array double click on the line with the matching variable name in the value window. A new dialog similar to the following image will pop up.



There is an additional LineEdit widget in this dialog which will display the defined array dimension in a Label widget. Type in the array position for which you want to display the value and click on the Display button.  The value line will display the value of the array at the position listed.



Display values in source code window

If the HBasic runtime environment reaches a breakpoint it opens the source code window displaying the breakpoint position. The HBasic source code window can also be used to display variable values at runtime. Move the mousecursor over a variable name for which you want to see the value and a short popup displays the current value of the variable.