templeos-info/public/Wb/Doc/DbgOverview.DD.HTML

103 lines
11 KiB
Plaintext
Raw Normal View History

2024-03-23 13:40:50 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
2024-03-23 13:40:50 +00:00
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
2024-03-23 13:40:50 +00:00
<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="/Wb/Kernel/KDbg.HC#l649"><span class=cF4>Dbg</span></a><span class=cF0>() or </span><span class=cF2>&lt;CTRL-ALT-d&gt;</span><span class=cF0>. You might enter the
<a name="l4"></a>debugger through a fault. Enter </span><a href="/Wb/Kernel/KDbg.HC#l444"><span class=cF4>G</span></a><span class=cF0>() or </span><a href="/Wb/Kernel/KDbg.HC#l469"><span class=cF4>G2</span></a><span class=cF0>() to continue execution. Place a
<a name="l5"></a>call to </span><a href="/Wb/Kernel/KDbg.HC#l649"><span class=cF4>Dbg</span></a><span class=cF0>() in your code at fatal error points to enter the debugger. If you
<a name="l6"></a>see a stk dump, record the label+offset and unassemble, </span><a href="/Wb/Compiler/UAsm.HC#l653"><span class=cF4>U</span></a><span class=cF0>(). </span><a href="/Wb/Compiler/UAsm.HC#l653"><span class=cF4>U</span></a><span class=cF0>(</span><a href="/Wb/Kernel/KernelA.HH#l3377"><span class=cF4>_RIP</span></a><span class=cF0>);
<a name="l7"></a>
<a name="l8"></a>* </span><a href="/Wb/Compiler/UAsm.HC#l653"><span class=cF4>U</span></a><span class=cF0>(&amp;FunName+offset) to unassemble mem or </span><a href="/Wb/Adam/ADbg.HC#l254"><span class=cF4>Uf</span></a><span class=cF0>(&quot;FunName&quot;) to unassemble a
<a name="l9"></a>function. </span><a href="/Wb/Compiler/UAsm.HC#l653"><span class=cF4>U</span></a><span class=cF0>(</span><a href="/Wb/Kernel/KernelA.HH#l3377"><span class=cF4>_RIP</span></a><span class=cF0>-16);
<a name="l10"></a>
<a name="l11"></a>* While debugging, you specify addresses of assembly routines with just the
<a name="l12"></a>label, as in </span><span class=cF2>_MALLOC+0x20</span><span class=cF0>. You specify </span><a href="/Wb/Doc/HolyC.DD.HTML#l1"><span class=cF4>HolyC</span></a><span class=cF0> function names with </span><span class=cF2>&amp;</span><span class=cF0> before
<a name="l13"></a>functions as in </span><span class=cF2>&amp;Print+0x10</span><span class=cF0>.
<a name="l14"></a>
<a name="l15"></a>* I use </span><a href="/Wb/Kernel/KernelB.HH#l209"><span class=cF4>progress1</span></a><span class=cF0>-</span><a href="/Wb/Kernel/KernelB.HH#l227"><span class=cF4>progress4</span></a><span class=cF0> for debugging because they show on the wallpaper.
<a name="l16"></a>They're just global int vars.
<a name="l17"></a>
<a name="l18"></a>* You can use </span><a href="/Wb/Kernel/Job.HC#l423"><span class=cF4>AdamLog</span></a><span class=cF0>() to send text to the </span><a href="/Wb/Doc/Glossary.DD.HTML#l171"><span class=cF4>Adam Task</span></a><span class=cF0> window. It works like </span><span class=cF4>
<a name="l19"></a></span><a href="/Wb/Kernel/StrPrint.HC#l890"><span class=cF4>Print</span></a><span class=cF0>(). I never use that. Instead, I use </span><a href="/Wb/Kernel/KDbg.HC#l217"><span class=cF4>RawPrint</span></a><span class=cF0>().
<a name="l20"></a>
<a name="l21"></a>* </span><a href="/Wb/Kernel/KDbg.HC#l172"><span class=cF4>D</span></a><span class=cF0>(), </span><a href="/Wb/Adam/DolDoc/DocPutS.HC#l325"><span class=cF4>DocD</span></a><span class=cF0>(), </span><a href="/Wb/Kernel/KDbg.HC#l234"><span class=cF4>RawD</span></a><span class=cF0>() to do 16 column hex dump mem with numbering from zero.
<a name="l22"></a>With </span><a href="/Wb/Adam/DolDoc/DocPutS.HC#l325"><span class=cF4>DocD</span></a><span class=cF0> the values are updated continually and you can alter mem by editing.
<a name="l23"></a>
<a name="l24"></a>* </span><a href="/Wb/Kernel/KDbg.HC#l204"><span class=cF4>Dm</span></a><span class=cF0>(), </span><a href="/Wb/Adam/DolDoc/DocPutS.HC#l312"><span class=cF4>DocDm</span></a><span class=cF0>(), </span><a href="/Wb/Kernel/KDbg.HC#l250"><span class=cF4>RawDm</span></a><span class=cF0>() to do 16 column hex dump mem with addresses showing.
<a name="l25"></a>
<a name="l26"></a>* </span><a href="/Wb/Kernel/KDbg.HC#l209"><span class=cF4>Da</span></a><span class=cF0>() to do one column address dump (for stk, etc.) with symbolic addresses.
<a name="l27"></a>
<a name="l28"></a>* </span><a href="/Wb/Kernel/KDbg.HC#l328"><span class=cF4>Dr</span></a><span class=cF0>() dumps regs. You can display and modify regs in the debugger with
<a name="l29"></a>var-like labels, </span><span class=cF4>_RAX</span><span class=cF0>, </span><span class=cF4>_RBX</span><span class=cF0>, etc.
<a name="l30"></a>
<a name="l31"></a>* </span><a href="/Wb/Adam/ADbg.HC#l161"><span class=cF4>ClassRep</span></a><span class=cF0>() and the dynamic version </span><a href="/Wb/Adam/ADbg.HC#l183"><span class=cF4>ClassRepD</span></a><span class=cF0>() can be used to dump structures.
<a name="l32"></a>
<a name="l33"></a>* </span><a href="/Wb/Adam/Opt/Utils/Profiler.HC#l27"><span class=cF4>Prof</span></a><span class=cF0>() and </span><a href="/Wb/Adam/Opt/Utils/Profiler.HC#l57"><span class=cF4>ProfRep</span></a><span class=cF0>() provide code profiling. See </span><a href="/Wb/Demo/InFile/InProfile.IN#l1"><span class=cF4>::/Demo/InFile/InProfile.IN</span></a><span class=cF0>
<a name="l34"></a>(This is an </span><a href="/Wb/Doc/Glossary.DD.HTML#l260"><span class=cF4>InFile</span></a><span class=cF0>.)
<a name="l35"></a>
<a name="l36"></a>* Use </span><a href="/Wb/Kernel/KDbg.HC#l217"><span class=cF4>RawPrint</span></a><span class=cF0>() to print debug info bypassing the window framework. You pass
<a name="l37"></a>these routines a count in milliseconds for how long it should be displayed. You
<a name="l38"></a>can use </span><a href="/Wb/Kernel/KMisc.HC#l290"><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>
<a name="l39"></a>runs on </span><span class=cF2>Core0</span><span class=cF0> and will overwrite raw text from other cores when it updates the
<a name="l40"></a>scrn.
<a name="l41"></a>
<a name="l42"></a>* Use </span><a href="/Wb/Kernel/KMisc.HC#l280"><span class=cF4>SysDbg</span></a><span class=cF0>() to set a flag which you can read with </span><a href="/Wb/Kernel/KMisc.HC#l285"><span class=cF4>IsSysDbg</span></a><span class=cF0>() when you wish to
<a name="l43"></a>trigger some debug activity. It's just a handy simple flag, nothing fancy.
<a name="l44"></a>
<a name="l45"></a>* There are flags for various trace options that can help debugging when there
<a name="l46"></a>are compiler bugs. Often, you place them in </span><span class=cF2>#exe{}</span><span class=cF0> blocks.
<a name="l47"></a> </span><span class=cF4>
<a name="l48"></a> </span><a href="/Wb/Compiler/CMisc.HC#l63"><span class=cF4>Echo</span></a><span class=cF0>() turns on or off raw data going into the lexical analyzer.
<a name="l49"></a> </span><span class=cF4>
<a name="l50"></a> </span><a href="/Wb/Compiler/CMisc.HC#l58"><span class=cF4>Trace</span></a><span class=cF0>() unassembles code generated from the HolyC compiler.
<a name="l51"></a> </span><span class=cF4>
<a name="l52"></a> </span><a href="/Wb/Compiler/CMisc.HC#l50"><span class=cF4>PassTrace</span></a><span class=cF0>() shows intermediate code coming-out after optimization. The bits
<a name="l53"></a> ctrl which passes are displayed.
<a name="l54"></a>
<a name="l55"></a>
<a name="l56"></a>* There is a heap check utility which can find leaks. Use </span><a href="/Wb/Adam/Opt/Utils/HeapLog.HC#l73"><span class=cF4>HeapLog</span></a><span class=cF0>(), </span><span class=cF4>
<a name="l57"></a></span><a href="/Wb/Adam/Opt/Utils/HeapLog.HC#l115"><span class=cF4>HeapLogAddrRep</span></a><span class=cF0>() and </span><a href="/Wb/Adam/Opt/Utils/HeapLog.HC#l146"><span class=cF4>HeapLogSizeRep</span></a><span class=cF0>(). It's a really simple program which
<a name="l58"></a>intercepts </span><a href="/Wb/Kernel/Mem/MAllocFree.HC#l387"><span class=cF4>MAlloc</span></a><span class=cF0>() and </span><a href="/Wb/Kernel/Mem/MAllocFree.HC#l383"><span class=cF4>Free</span></a><span class=cF0>(). You can customize the code to find other heap
<a name="l59"></a>issues.
<a name="l60"></a>
<a name="l61"></a>* You can define hndlr functions for </span><span class=cF2>&lt;CTRL-ALT-letter&gt;</span><span class=cF0> keys with </span><a href="/Wb/Kernel/KeyDev.HC#l178"><span class=cF4>CtrlAltCBSet</span></a><span class=cF0>().
<a name="l62"></a> They operate either in a interrupt environment or in the window mgr when it
<a name="l63"></a>queues kbd msgs. You can do </span><a href="/Wb/Kernel/KMisc.HC#l290"><span class=cF4>Raw</span></a><span class=cF0>() output. </span><span class=cF2>&lt;CTRL-ALT-letter&gt;</span><span class=cF0> hndlrs take a
<a name="l64"></a>scan_code as an arg.
<a name="l65"></a>
<a name="l66"></a>* If you recompile </span><span class=cF2>Kernel</span><span class=cF0> with </span><a href="/Wb/Adam/Opt/Boot/BootHDIns.HC#l18"><span class=cF4>BootHDIns</span></a><span class=cF0>(), you can set the </span><span class=cF4>MemInit</span><span class=cF0>, option to
<a name="l67"></a>initialize memory to a value at boot, the </span><span class=cF4>HeapInit</span><span class=cF0> option to cause mem alloced
<a name="l68"></a>off the heap to be initialized or </span><span class=cF4>VarInit</span><span class=cF0> option so both global and local vars
<a name="l69"></a>will be initialized to a value, but global AOT variables are always zero if not
<a name="l70"></a>initialized. Pick a non-zero value to discover uninitialized var bugs. You can
<a name="l71"></a>set </span><a href="/Wb/Kernel/KernelB.HH#l186"><span class=cF4>sys_var_init_flag</span></a><span class=cF0>, and </span><a href="/Wb/Kernel/KernelB.HH#l181"><span class=cF4>sys_heap_init_flag</span></a><span class=cF0> directly after booting.
</span></pre></body>
</html>