Add custom Debugger checks for every line
Posted: Sat Nov 08, 2008 4:58 pm
Related to [Feature Requests and Wishlists] Debugger check for PBHeap and [PureBasic Team Blog] Debugging tips - Part 1: Heap corruption i wrote an include-file which adds a heap check to every line and send an error-message to the debugger if the heaps are invalid.
So you can check this before the pb-team will add this as an option in future debugger versions.
If you want you can also add your own checks that shall be called every line. You only have to add a constant in the first Enumeration. (something like "#DebuggerCheck_MyCheck = 1<<1"). And add the check after the ";- Insert checks for every line here"-comment.
Variables you may use:
DebuggerLineCheck_CurrentFile (string)
DebuggerLineCheck_CurrentLine (long)
DebuggerLineCheck_Flags (long) - the checks that are activated
Procedures you may use:
PB_DEBUGGER_SendError(msg.s)
PB_DEBUGGER_SendWarning(msg.s)
Download: http://www.deeem2031.de/PB/DebuggerLineChecks.zip
A test-code for the heapcheck:
And a test code for the profiler:
Note that there is also a #DebuggerCheck_CheckPointer, which should check all pointer inside the programm if they are valid or null but because of this bug: http://www.purebasic.fr/english/viewtopic.php?t=37332 i cant continue developing this as it's impossible to handle interfaces correctly.
So you can check this before the pb-team will add this as an option in future debugger versions.

If you want you can also add your own checks that shall be called every line. You only have to add a constant in the first Enumeration. (something like "#DebuggerCheck_MyCheck = 1<<1"). And add the check after the ";- Insert checks for every line here"-comment.
Variables you may use:
DebuggerLineCheck_CurrentFile (string)
DebuggerLineCheck_CurrentLine (long)
DebuggerLineCheck_Flags (long) - the checks that are activated
Procedures you may use:
PB_DEBUGGER_SendError(msg.s)
PB_DEBUGGER_SendWarning(msg.s)
Download: http://www.deeem2031.de/PB/DebuggerLineChecks.zip
A test-code for the heapcheck:
Code: Select all
XIncludeFile "Includes\DebuggerLineChecks.pbi"
If DLC_Activate(#DebuggerCheck_Heap) = 0
Debug "ActivateDebuggerLineChecks failed!"
CallDebugger
EndIf
x = AllocateMemory(4096)
For i = x To x+10*1024
Debug i-x
PokeB(i,42)
Next
Code: Select all
IncludePath "Includes"
IncludeFile "DebuggerLineChecks.pbi"
DLC_Activate(#DebuggerCheck_Profile)
For i = 1 To 10000
x = Random(1000)
Next
DLC_ViewProfileResult()