| title | Debugging |
|---|---|
| parent | Compiler and IDE Features |
| nav_order | 2 |
| permalink | /Features/Compiler-IDE/Debugging |
twinBASIC adds three debugging features to those of VB6: a trace logger that also works in a compiled executable, the Debug.Cls statement, and detection of stale pointers. Breakpoints, stepping, the panel that opens at a run-time error and the Variables, Watches, Call Stack and Debug Console panels are described in Running and debugging.
A trace logger creates detailed logs, to the debug console or to a file. Messages can be output with Debug.TracePrint. The logger works both when running from the IDE and in compiled executables. The trace logger explains the trace settings and shows an example.
Debug.Cls empties the Debug Console from code, the same as its Clear Debug Console button. Calling it as a run begins separates that run's output from the previous one.
Bugs result from using Strings and Variants after they have been freed. It may not be noticed immediately if the memory has not been overwritten, but it's sometimes hard to detect and can cause issues like a String displaying it's previous value or garbage. This debugging option detects use-after-free, and replaces the data with a special symbol indicating the problem.
Below shows an example where the ListView ColumnHeader text had been set by previously-freed string and detected by this feature:
