ZealOS/docs/Doc/DebugOverview.html
TomAwezome 5002ed5880 Fix HTML index file generation.
Fix HTML generation tab width.
2021-07-04 18:11:43 -04:00

85 lines
12 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.05">
<style type="text/css">
body {background-color:#000000;}
.cF0{color:#ffffff;background-color:#000000;}
.cF1{color:#3465a4;background-color:#000000;}
.cF2{color:#4e9a06;background-color:#000000;}
.cF3{color:#06989a;background-color:#000000;}
.cF4{color:#a24444;background-color:#000000;}
.cF5{color:#75507b;background-color:#000000;}
.cF6{color:#ce982f;background-color:#000000;}
.cF7{color:#bcc0b9;background-color:#000000;}
.cF8{color:#555753;background-color:#000000;}
.cF9{color:#729fcf;background-color:#000000;}
.cFA{color:#82bc49;background-color:#000000;}
.cFB{color:#34e2e2;background-color:#000000;}
.cFC{color:#ac3535;background-color:#000000;}
.cFD{color:#ad7fa8;background-color:#000000;}
.cFE{color:#fce94f;background-color:#000000;}
.cFF{color:#000000;background-color:#000000;}
</style>
</head>
<body>
<pre style="font-family:courier;font-size:10pt">
<a name="l1"></a><span class=cF5> Debugging Overview</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a>* You can enter the debugger with </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l732"><span class=cF4>Debug</span></a><span class=cF0>() or </span><span class=cF2>&lt;CTRL-ALT-d&gt;</span><span class=cF0>. You might enter the debugger through a fault. Enter </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l499"><span class=cF4>G</span></a><span class=cF0>() or </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l530"><span class=cF4>G2</span></a><span class=cF0>() to
<a name="l4"></a>continue execution. Place a call to </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l732"><span class=cF4>Debug</span></a><span class=cF0>() in your code at fatal error points to enter the debugger. If you see a stack dump,
<a name="l5"></a>record the label+offset and unassemble, </span><a href="https://tomawezome.github.io/ZealOS/Compiler/UAsm.html#l771"><span class=cF4>U</span></a><span class=cF0>(). </span><a href="https://tomawezome.github.io/ZealOS/Compiler/UAsm.html#l771"><span class=cF4>U</span></a><span class=cF0>(</span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.html#l4044"><span class=cF4>_RIP</span></a><span class=cF0>);
<a name="l6"></a>
<a name="l7"></a>* </span><a href="https://tomawezome.github.io/ZealOS/Compiler/UAsm.html#l771"><span class=cF4>U</span></a><span class=cF0>(&amp;FunName+offset) to unassemble mem or </span><a href="https://tomawezome.github.io/ZealOS/System/Debug.html#l330"><span class=cF4>Uf</span></a><span class=cF0>(&quot;FunName&quot;) to unassemble a function. </span><a href="https://tomawezome.github.io/ZealOS/Compiler/UAsm.html#l771"><span class=cF4>U</span></a><span class=cF0>(</span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.html#l4044"><span class=cF4>_RIP</span></a><span class=cF0>-16);
<a name="l8"></a>
<a name="l9"></a>* While debugging, you specify addresses of assembly routines with just the label, as in </span><span class=cF2>_MALLOC+0x20</span><span class=cF0>. You specify </span><a href="https://tomawezome.github.io/ZealOS/Doc/CosmiC.html#l1"><span class=cF4>CosmiC</span></a><span class=cF0>
<a name="l10"></a>function names with </span><span class=cF2>&amp;</span><span class=cF0> before functions as in </span><span class=cF2>&amp;Print+0x10</span><span class=cF0>.
<a name="l11"></a>
<a name="l12"></a>* You can use </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelB.html#l166"><span class=cF4>progress1</span></a><span class=cF0>-</span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelB.html#l181"><span class=cF4>progress4</span></a><span class=cF0> for debugging because they show on the wallpaper. They're just global int vars.
<a name="l13"></a>
<a name="l14"></a>* You can use </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Job.html#l507"><span class=cF4>SysLog</span></a><span class=cF0>() to send text to the </span><a href="https://tomawezome.github.io/ZealOS/Doc/Glossary.html#l154"><span class=cF4>System Task</span></a><span class=cF0> window. It works like </span><a href="https://tomawezome.github.io/ZealOS/Kernel/StrPrint.html#l1110"><span class=cF4>Print</span></a><span class=cF0>(). You could also use </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l232"><span class=cF4>RawPrint</span></a><span class=cF0>().
<a name="l15"></a>
<a name="l16"></a>* </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l183"><span class=cF4>D</span></a><span class=cF0>(), </span><a href="https://tomawezome.github.io/ZealOS/System/DolDoc/DocPutS.html#l366"><span class=cF4>DocD</span></a><span class=cF0>(), </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l251"><span class=cF4>RawD</span></a><span class=cF0>() to do 16 column hex dump mem with numbering from zero. With </span><a href="https://tomawezome.github.io/ZealOS/System/DolDoc/DocPutS.html#l366"><span class=cF4>DocD</span></a><span class=cF0> the values are updated continually and
<a name="l17"></a>you can alter mem by editing.
<a name="l18"></a>
<a name="l19"></a>* </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l218"><span class=cF4>Dm</span></a><span class=cF0>(), </span><a href="https://tomawezome.github.io/ZealOS/System/DolDoc/DocPutS.html#l352"><span class=cF4>DocDm</span></a><span class=cF0>(), </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l269"><span class=cF4>RawDm</span></a><span class=cF0>() to do 16 column hex dump mem with addresses showing.
<a name="l20"></a>
<a name="l21"></a>* </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l223"><span class=cF4>Da</span></a><span class=cF0>() to do one column address dump (for stack, etc.) with symbolic addresses.
<a name="l22"></a>
<a name="l23"></a>* </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l354"><span class=cF4>Dr</span></a><span class=cF0>() dumps regs. You can display and modify regs in the debugger with var-like labels, </span><span class=cF4>_RAX</span><span class=cF0>, </span><span class=cF4>_RBX</span><span class=cF0>, etc.
<a name="l24"></a>
<a name="l25"></a>* </span><a href="https://tomawezome.github.io/ZealOS/System/Debug.html#l216"><span class=cF4>ClassRep</span></a><span class=cF0>() and the dynamic version </span><a href="https://tomawezome.github.io/ZealOS/System/Debug.html#l246"><span class=cF4>ClassRepD</span></a><span class=cF0>() can be used to dump structures.
<a name="l26"></a>
<a name="l27"></a>* </span><a href="https://tomawezome.github.io/ZealOS/System/Utils/Profiler.html#l30"><span class=cF4>Prof</span></a><span class=cF0>() and </span><a href="https://tomawezome.github.io/ZealOS/System/Utils/Profiler.html#l61"><span class=cF4>ProfRep</span></a><span class=cF0>() provide code profiling. See </span><a href="https://tomawezome.github.io/ZealOS/Demo/InFile/InProfile.html#l1"><span class=cF4>::/Demo/InFile/InProfile.IN</span></a><span class=cF0> (This is an </span><a href="https://tomawezome.github.io/ZealOS/Doc/Glossary.html#l218"><span class=cF4>InFile</span></a><span class=cF0>.)
<a name="l28"></a>
<a name="l29"></a>* Use </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KDebug.html#l232"><span class=cF4>RawPrint</span></a><span class=cF0>() to print debug info bypassing the window framework. You pass these routines a count in milliseconds for how
<a name="l30"></a>long it should be displayed. You can use </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KMisc.html#l257"><span class=cF4>Raw</span></a><span class=cF0>(</span><span class=cF2>TRUE</span><span class=cF0>) to make all output bypass the window framework. The </span><span class=cF2>WinMgr</span><span class=cF0> runs on </span><span class=cF2>Core0</span><span class=cF0> and
<a name="l31"></a>will overwrite raw text from other cores when it updates the screen.
<a name="l32"></a>
<a name="l33"></a>* Use </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KMisc.html#l247"><span class=cF4>SysDebug</span></a><span class=cF0>() to set a flag which you can read with </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KMisc.html#l252"><span class=cF4>IsSysDebug</span></a><span class=cF0>() when you wish to trigger some debug activity. It's just a
<a name="l34"></a>handy simple flag, nothing fancy.
<a name="l35"></a>
<a name="l36"></a>* There are flags for various trace options that can help debugging when there are compiler bugs. Often, you place them in </span><span class=cF2>#exe
<a name="l37"></a>{}</span><span class=cF0> blocks.
<a name="l38"></a> </span><span class=cF4>
<a name="l39"></a> </span><a href="https://tomawezome.github.io/ZealOS/Compiler/CMisc.html#l66"><span class=cF4>Echo</span></a><span class=cF0>() turns on or off raw data going into the lexical analyzer.
<a name="l40"></a> </span><span class=cF4>
<a name="l41"></a> </span><a href="https://tomawezome.github.io/ZealOS/Compiler/CMisc.html#l61"><span class=cF4>Trace</span></a><span class=cF0>() unassembles code generated from the CosmiC compiler.
<a name="l42"></a> </span><span class=cF4>
<a name="l43"></a> </span><a href="https://tomawezome.github.io/ZealOS/Compiler/CMisc.html#l50"><span class=cF4>PassTrace</span></a><span class=cF0>() shows intermediate code coming-out after optimization. The bits ctrl which passes are displayed.
<a name="l44"></a>
<a name="l45"></a>
<a name="l46"></a>* There is a heap check utility which can find leaks. Use </span><a href="https://tomawezome.github.io/ZealOS/System/Utils/HeapLog.html#l83"><span class=cF4>HeapLog</span></a><span class=cF0>(), </span><a href="https://tomawezome.github.io/ZealOS/System/Utils/HeapLog.html#l139"><span class=cF4>HeapLogAddrRep</span></a><span class=cF0>() and </span><a href="https://tomawezome.github.io/ZealOS/System/Utils/HeapLog.html#l174"><span class=cF4>HeapLogSizeRep</span></a><span class=cF0>(). It's a really
<a name="l47"></a>simple program which intercepts </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.html#l391"><span class=cF4>MAlloc</span></a><span class=cF0>() and </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.html#l387"><span class=cF4>Free</span></a><span class=cF0>(). You can customize the code to find other heap issues.
<a name="l48"></a>
<a name="l49"></a>* You can define handler functions for </span><span class=cF2>&lt;CTRL-ALT-letter&gt;</span><span class=cF0> keys with </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KeyDev.html#l201"><span class=cF4>CtrlAltCBSet</span></a><span class=cF0>(). They operate either in a interrupt
<a name="l50"></a>environment or in the window mgr when it queues kbd messages. You can do </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KMisc.html#l257"><span class=cF4>Raw</span></a><span class=cF0>() output. </span><span class=cF2>&lt;CTRL-ALT-letter&gt;</span><span class=cF0> handlers take a
<a name="l51"></a>scan_code as an arg.
<a name="l52"></a>
<a name="l53"></a>* If you recompile </span><span class=cF2>Kernel</span><span class=cF0> with </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootHDIns.html#l24"><span class=cF4>BootHDIns</span></a><span class=cF0>(), you can set the </span><span class=cF4>MemInit</span><span class=cF0>, option to initialize memory to a value at boot, the </span><span class=cF4>HeapIni
<a name="l54"></a>t</span><span class=cF0> option to cause mem alloced off the heap to be initialized or </span><span class=cF4>VarInit</span><span class=cF0> option so both global and local vars will be initialized
<a name="l55"></a>to a value, but global AOT variables are always zero if not initialized. Pick a non-zero value to discover uninitialized var
<a name="l56"></a>bugs. You can set </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelB.html#l145"><span class=cF4>sys_var_init_flag</span></a><span class=cF0>, and </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelB.html#l141"><span class=cF4>sys_heap_init_flag</span></a><span class=cF0> directly after booting.
</span></pre></body>
</html>