CoolFace
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes838downloads
DbgOverview.txt73 linesDownload Raw Back to Doc
1 2                               Debugging Overview3 4* You can enter the debugger with Dbg() or <CTRL-ALT-d>.  You might enter the5debugger through a fault.  Enter G() or G2() to continue execution.  Place a6call to Dbg() in your code at fatal error points to enter the debugger.  If you7see a stk dump, record the label+offset and unassemble, U(). U(_RIP);8 9* U(&FunName+offset) to unassemble mem or Uf("FunName") to unassemble a10function. U(_RIP-16);11 12* While debugging, you specify addresses of assembly routines with just the13label, as in _MALLOC+0x20.  You specify HolyC function names with & before14functions as in &Print+0x10.15 16* I use progress1-progress4 for debugging because they show on the wallpaper.17They're just global int vars.18 19* You can use AdamLog() to send text to the Adam Task window.  It works like20Print().  I never use that.  Instead, I use RawPrint().21 22* D(), DocD(), RawD() to do 16 column hex dump mem with numbering from zero.23With DocD the values are updated continually and you can alter mem by editing.24 25* Dm(), DocDm(), RawDm() to do 16 column hex dump mem with addresses showing.26 27* Da() to do one column address dump (for stk, etc.) with symbolic addresses.28 29* Dr() dumps regs.  You can display and modify regs in the debugger with30var-like labels, _RAX, _RBX, etc.31 32* ClassRep() and the dynamic version ClassRepD() can be used to dump structures.33 34* Prof() and ProfRep() provide code profiling.  See ::/Demo/InFile/InProfile.IN35(This is an InFile.)36 37* Use RawPrint() to print debug info bypassing the window framework.  You pass38these routines a count in milliseconds for how long it should be displayed.  You39can use Raw(TRUE) to make all output bypass the window framework.  The WinMgr40runs on Core0 and will overwrite raw text from other cores when it updates the41scrn.42 43* Use SysDbg() to set a flag which you can read with IsSysDbg() when you wish to44trigger some debug activity.  It's just a handy simple flag, nothing fancy.45 46* There are flags for various trace options that can help debugging when there47are compiler bugs.  Often, you place them in #exe{} blocks.48 49  Echo() turns on or off raw data going into the lexical analyzer.50 51  Trace() unassembles code generated from the HolyC compiler.52 53  PassTrace() shows intermediate code coming-out after optimization.  The bits54  ctrl which passes are displayed.55 56 57* There is a heap check utility which can find leaks.  Use HeapLog(),58HeapLogAddrRep() and HeapLogSizeRep().  It's a really simple program which59intercepts MAlloc() and Free().  You can customize the code to find other heap60issues.61 62* You can define hndlr functions for <CTRL-ALT-letter> keys with CtrlAltCBSet().63 They operate either in a interrupt environment or in the window mgr when it64queues kbd msgs.  You can do Raw() output.  <CTRL-ALT-letter> hndlrs take a65scan_code as an arg.66 67* If you recompile Kernel with BootHDIns(), you can set the MemInit, option to68initialize memory to a value at boot, the HeapInit option to cause mem alloced69off the heap to be initialized or VarInit option so both global and local vars70will be initialized to a value, but global AOT variables are always zero if not71initialized.  Pick a non-zero value to discover uninitialized var bugs.  You can72set sys_var_init_flag, and sys_heap_init_flag directly after booting.73