ZealOS/docs/Doc/DebugOverview.DD.html
TomAwezome 35ab2c024a Optimize RawPutChar bare-metal performance.
Add ATAPI Format Unit structs, partially implement.
2021-07-29 14:43:33 -04:00

85 lines
13 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.11">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<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://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.html#l750"><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://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.html#l516"><span class=cF4>G</span></a><span class=cF0>() or </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.html#l547"><span class=cF4>G2</span></a><span class=cF0>()
<a name="l4"></a>to continue execution. Place a call to </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.html#l750"><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
<a name="l5"></a>dump, record the label+offset and unassemble, </span><a href="https://zeal-operating-system.github.io/ZealOS/Compiler/UAsm.CC.html#l770"><span class=cF4>U</span></a><span class=cF0>(). </span><a href="https://zeal-operating-system.github.io/ZealOS/Compiler/UAsm.CC.html#l770"><span class=cF4>U</span></a><span class=cF0>(</span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4087"><span class=cF4>_RIP</span></a><span class=cF0>);
<a name="l6"></a>
<a name="l7"></a>* </span><a href="https://zeal-operating-system.github.io/ZealOS/Compiler/UAsm.CC.html#l770"><span class=cF4>U</span></a><span class=cF0>(&amp;FunName+offset) to unassemble mem or </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Debug.CC.html#l330"><span class=cF4>Uf</span></a><span class=cF0>(&quot;FunName&quot;) to unassemble a function. </span><a href="https://zeal-operating-system.github.io/ZealOS/Compiler/UAsm.CC.html#l770"><span class=cF4>U</span></a><span class=cF0>(</span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4087"><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://zeal-operating-system.github.io/ZealOS/Doc/CosmiC.DD.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://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l166"><span class=cF4>progress1</span></a><span class=cF0>-</span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.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://zeal-operating-system.github.io/ZealOS/Kernel/Job.CC.html#l507"><span class=cF4>SysLog</span></a><span class=cF0>() to send text to the </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/Glossary.DD.html#l154"><span class=cF4>System Task</span></a><span class=cF0> window. It works like </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/StrPrint.CC.html#l1110"><span class=cF4>Print</span></a><span class=cF0>(). You could also use </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.html#l232"><span class=cF4>RawPrint</span></a><span class=cF0>().
<a name="l15"></a>
<a name="l16"></a>* </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.html#l183"><span class=cF4>D</span></a><span class=cF0>(), </span><a href="https://zeal-operating-system.github.io/ZealOS/System/DolDoc/DocPutS.CC.html#l366"><span class=cF4>DocD</span></a><span class=cF0>(), </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.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://zeal-operating-system.github.io/ZealOS/System/DolDoc/DocPutS.CC.html#l366"><span class=cF4>DocD</span></a><span class=cF0> the values are updated continually
<a name="l17"></a>and you can alter mem by editing.
<a name="l18"></a>
<a name="l19"></a>* </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.html#l218"><span class=cF4>Dm</span></a><span class=cF0>(), </span><a href="https://zeal-operating-system.github.io/ZealOS/System/DolDoc/DocPutS.CC.html#l352"><span class=cF4>DocDm</span></a><span class=cF0>(), </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.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://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.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://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.html#l371"><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://zeal-operating-system.github.io/ZealOS/System/Debug.CC.html#l216"><span class=cF4>ClassRep</span></a><span class=cF0>() and the dynamic version </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Debug.CC.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://zeal-operating-system.github.io/ZealOS/System/Utils/Profiler.CC.html#l30"><span class=cF4>Prof</span></a><span class=cF0>() and </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Utils/Profiler.CC.html#l61"><span class=cF4>ProfRep</span></a><span class=cF0>() provide code profiling. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/InFile/InProfile.IN.html#l1"><span class=cF4>::/Demo/InFile/InProfile.IN</span></a><span class=cF0> (This is an </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/Glossary.DD.html#l220"><span class=cF4>InFile</span></a><span class=cF0>.)
<a name="l28"></a>
<a name="l29"></a>* Use </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KDebug.CC.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://zeal-operating-system.github.io/ZealOS/Kernel/KMisc.CC.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>
<a name="l31"></a>and 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://zeal-operating-system.github.io/ZealOS/Kernel/KMisc.CC.html#l247"><span class=cF4>SysDebug</span></a><span class=cF0>() to set a flag which you can read with </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KMisc.CC.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>#e
<a name="l37"></a>xe{}</span><span class=cF0> blocks.
<a name="l38"></a> </span><span class=cF4>
<a name="l39"></a> </span><a href="https://zeal-operating-system.github.io/ZealOS/Compiler/CMisc.CC.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://zeal-operating-system.github.io/ZealOS/Compiler/CMisc.CC.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://zeal-operating-system.github.io/ZealOS/Compiler/CMisc.CC.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://zeal-operating-system.github.io/ZealOS/System/Utils/HeapLog.CC.html#l83"><span class=cF4>HeapLog</span></a><span class=cF0>(), </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Utils/HeapLog.CC.html#l139"><span class=cF4>HeapLogAddrRep</span></a><span class=cF0>() and </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Utils/HeapLog.CC.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://zeal-operating-system.github.io/ZealOS/Kernel/Memory/MAllocFree.CC.html#l391"><span class=cF4>MAlloc</span></a><span class=cF0>() and </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/MAllocFree.CC.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://zeal-operating-system.github.io/ZealOS/Kernel/KeyDev.CC.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://zeal-operating-system.github.io/ZealOS/Kernel/KMisc.CC.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://zeal-operating-system.github.io/ZealOS/System/Boot/BootHDIns.CC.html#l25"><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>HeapI
<a name="l54"></a>nit</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
<a name="l55"></a>initialized to a value, but global AOT variables are always zero if not initialized. Pick a non-zero value to discover
<a name="l56"></a>uninitialized var bugs. You can set </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l145"><span class=cF4>sys_var_init_flag</span></a><span class=cF0>, and </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l141"><span class=cF4>sys_heap_init_flag</span></a><span class=cF0> directly after booting.
</span></pre></body>
</html>