RunTime Debugger

Introduction

The PureBasic runtime debugger is an external program which controls the execution of the programme. It controls and verify in realtime all the parameters given to the functions, avoid forbidden operations (like zero divide) and more. With PureBasic, the programme execution can be stopped, analysed step by step to locate any faults and interrupted at any moment ! This can be very useful in case a programme falls into an endless loop. Even more, it allows to monitor any variables and even ASM registers is the 'Enable Inline ASM' function is enabled in the Compiler Option menu.

Functions

Stop

This will halt the execution then display the current code position.

Cont

This will continue a previously stopped programme.

Step

This button allows code to be inserted step by step, ie: line after line. It is very handy to locate any faults.

Asm

Display an ASM monitoring window with all the CPU registers and CPU flags. This is for experienced users only which already know the ASM langage. The 'Enable Inline ASM' function must be enabled in the Compiler Option and the debugger must be stopped (STOP or STEP) to access to this window. This monitor is only useful when watching inlined ASM, not for normal basic code. A cool feature is the ability to modify on the fly the value of any registers by pressing the button 'Write New Value'.

Show variables

Display a window which show every global variables used in the program. The variables content are updated in realtime to follow easely the program flow.

Show Output Window

Display a window which show the output of the 'Debug' command.

Exit

This quits the debugger; the compiler; and any programme in case of any problems or if an "endless loop" cannot be stopped in any other way.

Debugger keywords in PureBasic

CallDebugger

This invokes the "debugger" and freezes the programme immediately.

Debug <expression> [, DebugLevel]

Display the DebugOutput window and the result inside it. The expression can be any valid PureBasic expression, from numeric to string. An important point is than the Debug command and its associated expression is totally ignored (not compiled) when the debugger is desactivated. This means than this command can be used to trace easely in the program without having to comment all the debug commands when creating the final executable.

The 'DebugLevel' is the level of priority of the debug message. All normal debug message (without specifying a debug level) are automically displayed. When a level is specified then the message will be displayed only if the current DebugLevel (set with the following 'DebugLevel' command) is equals or above this number. This allows hierarchical debug mode, by displaying more and more precise informations in function of the used DebugLevel.

DebugLevel

Set the current debug level for the 'Debug' message.

DisableDebugger

This will disable the debugger checks on the source code which follow this command.

EnableDebugger

This will enable the debugger checks on the source code which follow this command (if the debugger was previously disabled with DisableDebugger).