<aname="l3"></a>* You can enter the debugger with </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l764"><spanclass=cF4>Debug</span></a><spanclass=cF0>() or </span><spanclass=cF2><CTRL-ALT-d></span><spanclass=cF0>. You might enter the debugger through a fault. Enter </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l528"><spanclass=cF4>G</span></a><spanclass=cF0>() or </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l560"><spanclass=cF4>G2</span></a><spanclass=cF0>()
<aname="l4"></a>to continue execution. Place a call to </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l764"><spanclass=cF4>Debug</span></a><spanclass=cF0>() in your code at fatal error points to enter the debugger. If you see a stack
<aname="l5"></a>dump, record the label+offset and unassemble, </span><ahref="https://zeal-operating-system.github.io/ZealOS/Compiler/UAsm.ZC.html#l836"><spanclass=cF4>U</span></a><spanclass=cF0>(). </span><ahref="https://zeal-operating-system.github.io/ZealOS/Compiler/UAsm.ZC.html#l836"><spanclass=cF4>U</span></a><spanclass=cF0>(</span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4082"><spanclass=cF4>_RIP</span></a><spanclass=cF0>);
<aname="l7"></a>* </span><ahref="https://zeal-operating-system.github.io/ZealOS/Compiler/UAsm.ZC.html#l836"><spanclass=cF4>U</span></a><spanclass=cF0>(&FunName+offset) to unassemble mem or </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/Debug.ZC.html#l334"><spanclass=cF4>Uf</span></a><spanclass=cF0>("FunName") to unassemble a function. </span><ahref="https://zeal-operating-system.github.io/ZealOS/Compiler/UAsm.ZC.html#l836"><spanclass=cF4>U</span></a><spanclass=cF0>(</span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4082"><spanclass=cF4>_RIP</span></a><spanclass=cF0>-16);
<aname="l9"></a>* While debugging, you specify addresses of assembly routines with just the label, as in </span><spanclass=cF2>_MALLOC+0x20</span><spanclass=cF0>. You specify </span><ahref="https://zeal-operating-system.github.io/ZealOS/Doc/ZealC.DD.html#l1"><spanclass=cF4>ZealC</span></a><spanclass=cF0>
<aname="l10"></a>function names with </span><spanclass=cF2>&</span><spanclass=cF0> before functions as in </span><spanclass=cF2>&Print+0x10</span><spanclass=cF0>.
<aname="l12"></a>* You can use </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l166"><spanclass=cF4>progress1</span></a><spanclass=cF0>-</span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l181"><spanclass=cF4>progress4</span></a><spanclass=cF0> for debugging because they show on the wallpaper. They're just global int variables.
<aname="l14"></a>* You can use </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/Job.ZC.html#l507"><spanclass=cF4>SysLog</span></a><spanclass=cF0>() to send text to the </span><ahref="https://zeal-operating-system.github.io/ZealOS/Doc/Glossary.DD.html#l154"><spanclass=cF4>System Task</span></a><spanclass=cF0> window. It works like </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/StrPrint.ZC.html#l1110"><spanclass=cF4>Print</span></a><spanclass=cF0>(). You could also use </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l244"><spanclass=cF4>RawPrint</span></a><spanclass=cF0>().
<aname="l16"></a>* </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l195"><spanclass=cF4>Dump</span></a><spanclass=cF0>(), </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/DolDoc/DocPutS.ZC.html#l366"><spanclass=cF4>DocDump</span></a><spanclass=cF0>(), </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l263"><spanclass=cF4>RawDump</span></a><spanclass=cF0>() to do 16 column hex dump mem with numbering from zero. With </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/DolDoc/DocPutS.ZC.html#l366"><spanclass=cF4>DocDump</span></a><spanclass=cF0> the values are updated
<aname="l19"></a>* </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l230"><spanclass=cF4>DumpMem</span></a><spanclass=cF0>(), </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/DolDoc/DocPutS.ZC.html#l352"><spanclass=cF4>DocDumpMem</span></a><spanclass=cF0>(), </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l281"><spanclass=cF4>RawDumpMem</span></a><spanclass=cF0>() to do 16 column hex dump mem with addresses showing.
<aname="l21"></a>* </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l235"><spanclass=cF4>DumpAddress</span></a><spanclass=cF0>() to do one column address dump (for stack, etc.) with symbolic addresses.
<aname="l23"></a>* </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l383"><spanclass=cF4>DumpRegs</span></a><spanclass=cF0>() dumps registers. You can display and modify registers in the debugger with variable-like labels, </span><spanclass=cF4>_RAX</span><spanclass=cF0>, </span><spanclass=cF4>_RBX</span><spanclass=cF0>,
<aname="l26"></a>* </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/Debug.ZC.html#l216"><spanclass=cF4>ClassRep</span></a><spanclass=cF0>() and the dynamic version </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/Debug.ZC.html#l246"><spanclass=cF4>ClassRepD</span></a><spanclass=cF0>() can be used to dump structures.
<aname="l28"></a>* </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/Utils/Profiler.ZC.html#l30"><spanclass=cF4>Prof</span></a><spanclass=cF0>() and </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/Utils/Profiler.ZC.html#l95"><spanclass=cF4>ProfRep</span></a><spanclass=cF0>() provide code profiling. See </span><ahref="https://zeal-operating-system.github.io/ZealOS/Demo/InFile/InProfile.IN.html#l1"><spanclass=cF4>::/Demo/InFile/InProfile.IN</span></a><spanclass=cF0> (This is an </span><ahref="https://zeal-operating-system.github.io/ZealOS/Doc/Glossary.DD.html#l220"><spanclass=cF4>InFile</span></a><spanclass=cF0>.)
<aname="l30"></a>* Use </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.ZC.html#l244"><spanclass=cF4>RawPrint</span></a><spanclass=cF0>() to print debug info bypassing the window framework. You pass these routines a count in milliseconds for how
<aname="l31"></a>long it should be displayed. You can use </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KMisc.ZC.html#l257"><spanclass=cF4>Raw</span></a><spanclass=cF0>(</span><spanclass=cF2>TRUE</span><spanclass=cF0>) to make all output bypass the window framework. The </span><spanclass=cF2>WinMgr</span><spanclass=cF0> runs on </span><spanclass=cF2>Core0</span><spanclass=cF0>
<aname="l34"></a>* Use </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KMisc.ZC.html#l247"><spanclass=cF4>SysDebug</span></a><spanclass=cF0>() to set a flag which you can read with </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KMisc.ZC.html#l252"><spanclass=cF4>IsSysDebug</span></a><spanclass=cF0>() when you wish to trigger some debug activity. It's just a
<aname="l37"></a>* There are flags for various trace options that can help debugging when there are compiler bugs. Often, you place them in </span><spanclass=cF2>#e
<aname="l40"></a></span><ahref="https://zeal-operating-system.github.io/ZealOS/Compiler/CMisc.ZC.html#l66"><spanclass=cF4>Echo</span></a><spanclass=cF0>() turns on or off raw data going into the lexical analyzer.
<aname="l42"></a></span><ahref="https://zeal-operating-system.github.io/ZealOS/Compiler/CMisc.ZC.html#l61"><spanclass=cF4>Trace</span></a><spanclass=cF0>() unassembles code generated from the ZealC compiler.
<aname="l44"></a></span><ahref="https://zeal-operating-system.github.io/ZealOS/Compiler/CMisc.ZC.html#l50"><spanclass=cF4>PassTrace</span></a><spanclass=cF0>() shows intermediate code coming-out after optimization. The bits ctrl which passes are displayed.
<aname="l47"></a>* There is a heap check utility which can find leaks. Use </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/Utils/HeapLog.ZC.html#l83"><spanclass=cF4>HeapLog</span></a><spanclass=cF0>(), </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/Utils/HeapLog.ZC.html#l139"><spanclass=cF4>HeapLogAddrRep</span></a><spanclass=cF0>() and </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/Utils/HeapLog.ZC.html#l175"><spanclass=cF4>HeapLogSizeRep</span></a><spanclass=cF0>(). It's a really
<aname="l48"></a>simple program which intercepts </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/MAllocFree.ZC.html#l391"><spanclass=cF4>MAlloc</span></a><spanclass=cF0>() and </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/MAllocFree.ZC.html#l387"><spanclass=cF4>Free</span></a><spanclass=cF0>(). You can customize the code to find other heap issues.
<aname="l50"></a>* You can define handler functions for </span><spanclass=cF2><CTRL-ALT-letter></span><spanclass=cF0> keys with </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KeyDev.ZC.html#l201"><spanclass=cF4>CtrlAltCBSet</span></a><spanclass=cF0>(). They operate either in a interrupt
<aname="l51"></a>environment or in the window mgr when it queues kbd messages. You can do </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KMisc.ZC.html#l257"><spanclass=cF4>Raw</span></a><spanclass=cF0>() output. </span><spanclass=cF2><CTRL-ALT-letter></span><spanclass=cF0> handlers take a
<aname="l54"></a>* If you recompile </span><spanclass=cF2>Kernel</span><spanclass=cF0> with </span><ahref="https://zeal-operating-system.github.io/ZealOS/System/Boot/BootHDIns.ZC.html#l25"><spanclass=cF4>BootHDIns</span></a><spanclass=cF0>(), you can set the </span><spanclass=cF4>MemInit</span><spanclass=cF0>, option to initialize memory to a value at boot, the </span><spanclass=cF4>HeapI
<aname="l55"></a>nit</span><spanclass=cF0> option to cause mem alloced off the heap to be initialized or </span><spanclass=cF4>VarInit</span><spanclass=cF0> option so both global and local variables will be
<aname="l56"></a>initialized to a value, but global AOT variables are always zero if not initialized. Pick a non-zero value to discover
<aname="l57"></a>uninitialized variable bugs. You can set </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l145"><spanclass=cF4>sys_var_init_flag</span></a><spanclass=cF0>, and </span><ahref="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l141"><spanclass=cF4>sys_heap_init_flag</span></a><spanclass=cF0> directly after booting.